Link to page in template?
Permalink 1 user found helpful
Hello all
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
for the homepage. I'm creating a secondary nav and autonav doesn't do what I want.
Any thoughts?
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.
Any thoughts?
can you please explain more in depth of what you want?
I'll show you the original page which I'm converting:
http://www.scotlawcom.gov.uk/html/about_us.php...
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:
www.www.url.gov.uk/secondary-nav/contact-us...
(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! :)
http://www.scotlawcom.gov.uk/html/about_us.php...
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:
www.www.url.gov.uk/secondary-nav/contact-us...
(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! :)
Any thoughts anyone? I just want to know if there is a 'proper' concrete5 way to link to a page in the template's HTML, other than the standard:
<a href="/contact-us">Contact us</a>
yea, you can do it that way or with the page's id which still works even if the page is moved
>yea, you can do it that way or with the page's id which still works even if the page is moved
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!
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!
basically the exact same thing as that but to get the id you can go to the sitemap go to the page and look at the url, there you go :)
THanks, I did that and it works fine :)
I've come across this problem again.. I've tried the following code, but it doesn't work:
..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.
Any thoughts?
<?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.
Any thoughts?
I also need to know how to do this... anyone?
I need to as well, I'm learning a lot with Concrete5 but have made 3 links on my main index page and want to link them to the new pages I've created. I just need to get the path right. Sounds simple, but not easy to do......anyone?
Add this function at the top of your view:
Then you can just use the function using the page ID number:
<?php function getTheURL($url_id) { $opg = Page::getById($url_id); $url=Loader::helper('navigation'); $canonical=$url->getCollectionURL($opg); $canonical=preg_replace("/index.php\?cID=1$/","",$canonical); echo $canonical; } ?>
Then you can just use the function using the page ID number:
<a href="<?php getTheURL(140); ?>">
Thanks for that useful snippet of code.