Drupal 6: $base_path doesn't always point to the frontpage
Heine Sun, 2009/05/17 - 20:13
Dear themers,
.... in page.tpl.php breaks Home functionality on many multilingual sites.
Consider a multilingual site with English (prefix 'en') as the default language and Dutch (prefix 'nl') as a second language. While browsing the site in Dutch (eg http://example.com/nl/node/5), the homelink created with $base_path
leads to http://example.com/, which is the default English content. Quite an unpleasant surprise for your visitors.
The correct URL to the homepage is $front_page. As this variable holds a URL, you still need to convert it to HTML by calling check_url on it:
If you maintain a theme on Drupal.org that doesn't use $front_page, please consider this a bugreport. Thanks.
Comments
Theme resources...
Submitted by Nicholas Thompson (not verified) on Mon, 2009/05/18 - 09:51Good point - the URL to the frontpage should be $front_page (/me goes off to check Abessive!)...
But $base_path has its place; access to theme resources. Shouldn't you link to images using:
Also - should you use $base_path or base_path()?
$base_path, $directory
Submitted by Heine on Mon, 2009/05/18 - 12:25In page.tpl.php
$base_path
is available, so by all means, use$base_path
there. In other .tpl.php files you need to callbase_path()
yourself, or make your own$base_path
variable in template.php.template_preprocess() always fills
$directory
—why not$base_path
is beyond me—, so there's no need to callpath_to_theme()
.Now, theme_image accepts as path: "Either the path of the image file (relative to base_path()) or a full URL." The code above should read: