[support] theming primary links, or absolute paths when drupal is in a sub-directory

Amanda B Hickman amanda at velociraptor.info
Wed Oct 31 17:46:03 UTC 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


> If you hard code /news/ in then it will always go to /news/ whether 
> you're in a subdirectory or not - it gets interpreted by the browser, 
> not by drupal or anything else.

That is correct, but that means forgoing the content management aspect
of incorporating drupal into part of the site. I'd really like to be
able to edit our primary navigation from within drupal, so that I can
tell everyone that the first rule is you do not touch the template. Hard
coding it, by actually manually spelling out my primary navigation in
the template itself, is less than ideal.

> If you want it to go to news in drupal whether your drupal is at root or 
> in a subdirectory then you want to use
> <?php print base_path()?>news/ (you may need a slash in front of news 
> can't remember)

I do not want to go to /drupal/news/ I want the link to point to /news/

> that way if the base of drupal is at root nothing will get added but if 
> it's /drupal/ and you therefore want it to go to /drupal/news/ then 
> /drupal/ will be added automagically.

It is that automagic that I would like to undo. I want to be able to use
drupals menus to point outside of drupal to other parts of my site. In a
similar vein, if I use drupal's inner workings to set the URL of our
favicon, I end up with a lot of file not found errors because
/drupal//graphics/favicon.ico can't be found. I don't want to have to
keep a duplicate favicon.

- -Amanda

> .s
> 
> Amanda Bee wrote:
> I don't want drupal to do anything. If I set the path to "/news/" I want
> drupal to make a link that says <a href="/news/">Foo</a> and not <a
> href="/drupal//news/">Foo</a>.
> 
> This is obviously some kind of rocket science like I never imagined.
> 
> 
> Cog Rusty wrote:
>>>> On 10/31/07, Amanda B Hickman <amanda at velociraptor.info> wrote:
>>>> Thanks for taking a stab at it. Here are some responses that I hope will
>>>> clarify my troubles a wee bit ...
>>>>
>>>> Cog Rusty wrote:
>>>>>>> Generally, if you access your Drupal site as
>>>>>>> http://www.example.com/drupal/ then that's your site's web root.
>>>> Right, that is my drupal site's root.
>>>>
>>>>>>> If you use a fully qualified URL in a menu to take you to
>>>>>>> http://www.example.com/news that will take you outside Drupal, unless
>>>>>>> you have set up a Drupal site for http://www.example.com.
>>>> Right: a fully qualified URL will do that, but I'd have to include the
>>>> domain name (http://www.example.com). The site is moving around,
>>>> however, and the domain name could be any of ...
>>>>
>>>> http://www.example.com
>>>> http://staging.example.com
>>>> http://example.local
>>>>
>>>> And I want to be able to test out the menus and other changes on a
>>>> staging site before I push the drupal section live.
>>>>
>>>>
>>>>> I still don't understand. You want that menu link to change, based on
>>>>> what? If you are in a http://www.example.com/drupal site, how could
>>>>> the menu link switch to any other domain? Based on what?
>>>>> If you manage to use an apache rewrite, what condition is that going
>>>>> to check for changing domain?
>>>>> I don't see any other way except depending on the domain of the Drupal
>>>>> site that you are currently in.
>>>>>>> I am not sure I completely understand what you are trying to achieve
>>>>>>> and what you are running in your http://www.example.com site, but the
>>>> The rest of the site uses a frightening home-brewed content management
>>>> system developed over many years by many programmers. I'm in the process
>>>> of streamlining that, but first I'd like to get a few things into drupal
>>>> and working well (our forums, for one thing).
>>>>
>>>>>>> usual method of using multiple domain names is to point all domain
>>>>>>> names to Drupal's installation directory and set up respective
>>>>>>> settings.php files for the different domains to use the same database
>>>>>>> ($db_url).
>>>> Drupal works fine under each of these domain names, and the separate
>>>> settings.php files in sites/example.local and sites/staging.example.com
>>>> do a fine job of pointing it off to different databases depending on
>>>> where I'm accessing it from. That part works fine.
>>>>
>>>>
>>>>>>> Consider
>>>>>>> - setting up Drupal sites for all the domains or subdomains you want
>>>>>>> (see http://drupal.org/node/147828),
>>>>>>> - don't set up a Drupal site for http://www.example.com/drupal/,
>>>>>>> - and use your .htaccess file to make Drupal leave alone certain paths
>>>>>>> of your other application (http://drupal.org/node/30334).
>>>>>>>
>>>>>>> There was a discussion about using some .htaccess tricks
>>>>>>> (http://drupal.org/node/144643) but I wouldn't go there before trying
>>>>>>> all the standard methods. This kind of .htaccess tricks tend to make a
>>>>>>> setup fragile.
>>>> I'm not dying to go the .htaccess route, I promise, but I can't figure
>>>> out how to persuade drupal that a path in the menu like "/news/" is
>>>> relative to the whole site, not relative to drupal.
>>>>
>>>>
>>>>>>> On 10/30/07, Amanda Bee <amanda at velociraptor.info> wrote:
>>>>>>> I'm still working on this, though I suspect from my reading that the
>>>>>>> real solution lies in .htaccess rewrite rules.
>>>>>>>
>>>>>>> I thought this:
>>>>>>>
>>>>>>> RewriteRule ^/drupal//(.*) /$1 [L]
>>>>>>>
>>>>>>> Would work -- take paths that have the double slash and bump them up a
>>>>>>> level to the root of the site -- but it doesn't seem to be taking. For
>>>>>>> bonus fun I tried quirky variations like ...
>>>>>>>
>>>>>>> RewriteRule ^/drupal//(.*) /drupal/foo/$1 [L]
>>>>>>>
>>>>>>> And didn't get anywhere either. Am I even making sense here?
>>>>>>>
>>>>>>> Thanks,
>>>>>>> amanda
>>>>>>>
>>>>>>> (http://drupal.org/node/187647)
>>>>>>>
>>>>>>>
>>>>>>> Amanda B Hickman wrote:
>>>>>>>>>> I'm puzzling through a few things at once and starting to hit walls on
>>>>>>>>>> this one as well.
>>>>>>>>>>
>>>>>>>>>> I've got drupal set up in a subdirectory of a larger site. That larger
>>>>>>>>>> site is in subversion and I run a staging site and a few local
>>>>>>>>>> incarnations of it, which means that the site's domain name changes
>>>>>>>>>> periodically, from "staging.example.com" to "example.local" or
>>>>>>>>>> "www.example.com"
>>>>>>>>>>
>>>>>>>>>> Right now, I've got the site's overall primary links in drupal as
>>>>>>>>>> primary links, and I'd like to keep them there, but drupal is gobbling
>>>>>>>>>> up the absolute paths even though they're absolute:
>>>>>>>>>>
>>>>>>>>>> I gave the menu path as
>>>>>>>>>>
>>>>>>>>>> "/news/" and drupal points to
>>>>>>>>>>
>>>>>>>>>> "http://staging.example.com/drupal//news/"  when I'm aiming for
>>>>>>>>>>
>>>>>>>>>> "http://staging.example.com/news"
>>>>>>>>>>
>>>>>>>>>> I spent a lot of time monkeying with clean URLs on the theory that
>>>>>>>>>> they'd fix this, only to discover ... nope.
>>>>>>>>>>
>>>>>>>>>> I've looked around for a themeable function that would let me wrestle
>>>>>>>>>> links into being relative to the site as a whole, not relative to
>>>>>>>>>> drupal, but I'm not seeing it.
>>>>>>>>>>
>>>>>>>>>> This doesn't appear to be controlled by "theme_menu_links"
>>>>>>>>>> http://api.drupal.org/api/function/theme_menu_links/5
>>>>>>>>>>
>>>>>>>>>> Any suggestions?
>>>>>>>>>>
>>>>>>>>>> Thanks,
>>>>>>>>>> Amanda
>>>>>>>>>>
>>>>>>>>>>

- --
Amanda B Hickman
(p) 917 655 2579
(s) amandabee
(a) amandahlinc
(w) http://velociraptor.info
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHKL9brxDTsWdh5zkRAjG+AKCaLscpHge0ypYICKxW5CQGQvPIswCdEqzD
WCV+ms1nak9yL2PRo9Zv9no=
=sDZV
-----END PGP SIGNATURE-----


More information about the support mailing list