By Anonymous (not verified) on
I understand that Drupal uses <front> to designate the frontpage but how do I use this in an <a href> tag or do I have to hardcode the site's full root url in there instead?
TIA
I understand that Drupal uses <front> to designate the frontpage but how do I use this in an <a href> tag or do I have to hardcode the site's full root url in there instead?
TIA
Comments
To link to your front page,
To link to your front page, there many way.
but my favorite is :
hope this help you.
l() function
It depends a little on where you need it. "<front>" is something you would use in admin forms, like the menu system or a block configuration page. When I need this somewhere in php code, I use drupal's l() function:
print l('front','');or, if you want an absolute link including the http:// and the domain name:
print l('front','',array('absolute'=>true));See http://api.drupal.org/api/function/l for more info on the l() function.
a far-far better way
If you want to link to your front, DON'T use php in the node as then your content admins have to either use PHP, or get granted permission to use that input-format... instead just do this:
The forward slash is correctly interpreted to be your front page by Drupal.
Voila!
Not always this is a better way
It won't work if drupal site is hosted in a directory (like example.com/mydrupalsite).
A Keeper!
Thanks to both of you.
This advice is really helpful and worth keeping somewhere on a quick reference sheet.
Does such exist?
There are several cheat
There are several cheat sheets, aimed at different audiences (themers, coders, end-users). Just search Google for "drupal cheat sheet".