replace_link_with_first_in_nav - Can it be used outside of the autonav?
Permalink
Hey all,
I'm calling a few links to pages like this:
I've got the replace_link_with_first_in_nav attribute on a few of the links I'm calling - Can that attribute be used in the instance above? Or is it just restricted to the Autonav?
I know its a bit of a goofy question, but would like to know if its possible. Cheers.
I'm calling a few links to pages like this:
I've got the replace_link_with_first_in_nav attribute on a few of the links I'm calling - Can that attribute be used in the instance above? Or is it just restricted to the Autonav?
I know its a bit of a goofy question, but would like to know if its possible. Cheers.
![juddc](/files/avatars/110914.jpg)
Also - Anyone know if its possible with a Page List block?
Yes, replace_link_with_first_in_nav is just another page attribute so it can be retrieved in this case by calling:
It's a boolean/checkbox, so it returns a true or false value.
You can use it in page_list block templates, in those you would just call somewhere in the foreach loop:
(there are some useful examples of how to retrieve page attributes in the default template)
In both cases once you have it retrieved you can use it however you like in your output logic.
$replace_first = $p->getAttribute('replace_link_with_first_in_nav');
It's a boolean/checkbox, so it returns a true or false value.
You can use it in page_list block templates, in those you would just call somewhere in the foreach loop:
$replace_first = $page->getAttribute('replace_link_with_first_in_nav');
(there are some useful examples of how to retrieve page attributes in the default template)
In both cases once you have it retrieved you can use it however you like in your output logic.
I think thats my problem - as more of a design-type, I'm stabbing around in the dark regarding the output.
Expanding on this, once you've fetched the attribute, you could really just retrieve the first child page when required in the loop, outputting a different url and/or title. So in a page list template:
You could comment out the $title line if you want to keep it the original page title, but point the actual url to the first child page.
// put this before you output your page link $replace_first = $page->getAttribute('replace_link_with_first_in_nav'); if ($replace_first) { $subPage = $page->getFirstChild(); if ($subPage instanceof Page) { $url = $nh->getLinkToCollection($subPage); $title = $subPage->getCollectionName(); } }
You could comment out the $title line if you want to keep it the original page title, but point the actual url to the first child page.