Link to page in template?1 user found helpful
I'd like to add links to some pages within my template, without using a block (because I want these links to appear always, and for editors not to have to add a block manually to a new page).
Something along the lines of
<?php echo DIR_REL; ?>
for the homepage. I'm creating a secondary nav and autonav doesn't do what I want.
I'm looking to create the links on the top-right corner. They appear on every page which uses the template, which is why I'd either like to hard-code in an autonav block, or hardcode the links without a block into the template.
I experimented with autonav by creating a page called 'Secondary nav', then creating children aliases to all the pages that I want to link to, which looked right in terms of the correct links showing up - but the URLs linked to looked like this:
(I don't want the 'secondary-nav' to appear in the URL, which is why I thought hardcoding would be the way forward).
Hope that is a bit clearer, twas late last night when I first posted! :)
<a href="/contact-us">Contact us</a>
that's precisely what I want to do (with IDs). How do I do it?! I can't find any info in the documentation! Such a simple thing!
<?php $oPage = Page::getById(68); $nh = Loader::helper('navigation'); $sRelUrl = $nh->getLinkToCollection($oPage);?>
..it always goes to the homepage, even though the page with ID 68 is a different page.
The reason I want to do this is i am developing the site on a temp URL, so i want the links to automatically flip over when I enable pretty URLs on the final domain, without having to manually go through and change them. I should be able to use c5's API to do that.
Then you can just use the function using the page ID number:
<a href="<?php getTheURL(140); ?>">