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 absolute 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.

View Replies: View Best Answer
Mnkras replied on at Permalink Best Answer Reply

will go to the homepage of the site

goes to <c5root>/sitemap

Proteus replied on at Permalink Reply
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

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

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