Relative Link to Home (or any other page)

Permalink 5 users found helpful
I would like to hard-wire a link into my template that includes a button. This button links to the homepage, and is reproduced on all pages. While I could just as easily just do an absolutehttp://www.mysitehere.com link, I'd like to know if it'd be possible to do it with a few PHP lines and a relative link—just to be extra bulletproof.

I've read up on the URL helpers and some other topics on the subject, but I couldn't see an answer quite to this specific problem. I'm a novice at PHP though, so I was wondering if there was a simple couple of lines of PHP that would build a relative path from wherever the current page is in the site tree.

Proteus
 
Mnkras replied on at Permalink Best Answer Reply
Mnkras
<?=$this->url('');?>

will go to the homepage of the site
<?=$this->url('sitemap');?>

goes to <c5root>/sitemap

etc
Proteus replied on at Permalink Reply
Proteus
Thanks Mnkras, had found that answer before but didn't understand it due to the context.

Works perfectly.
zoinks replied on at Permalink Reply
Man, this is great! This is what I've wanted to know for the last year, but I guess I never phrased my question correctly. Thanks, Mnkras!
nickodalton replied on at Permalink Reply
nickodalton
or

<?php echo $this->url('');?>


if your server requires the full monty!
jordanlev replied on at Permalink Reply
jordanlev
or
<a href="<?php echo DIR_REL; ?>/">Home Page</a>