custom attribute instead of is_featured
Permalink
Hi,
I am looking to use a custom attribute to load pages into my autonav.
I am already using is_featured on another area. Can any one point me in the right direction of the code to replicate this. I am using 5.7 and have been looking on the site. I am sure I have seen this somewhere on here before.
I am looking to use a custom attribute to load pages into my autonav.
I am already using is_featured on another area. Can any one point me in the right direction of the code to replicate this. I am using 5.7 and have been looking on the site. I am sure I have seen this somewhere on here before.
Yes that makes sense, do you know of any how too's to get the extra attribute working?
A couple of docs pages on templates or view overrides:
http://www.concrete5.org/documentation/developers/5.7/working-with-...
https://www.concrete5.org/documentation/developers/5.7/working-with-...
A block controller override should work within the same structure, as per:
https://www.concrete5.org/documentation/developers/5.7/working-with-...
You can see an example of retrieving an attribute in excludeFromNavViaAttribute(). At its simplest, you just want a different attribute handle and to negate the test.
http://www.concrete5.org/documentation/developers/5.7/working-with-...
https://www.concrete5.org/documentation/developers/5.7/working-with-...
A block controller override should work within the same structure, as per:
https://www.concrete5.org/documentation/developers/5.7/working-with-...
You can see an example of retrieving an attribute in excludeFromNavViaAttribute(). At its simplest, you just want a different attribute handle and to negate the test.
Thanks John, i have done my fair share of overrides but i will take a look at this. I just thought things might be a little different in 5.7 but the code in most of the core blocks is the same.
Other than maximum level and parent, the filtering of autonav tends to be by excluding, attributes exclude_nav and exclude_subpages_from_nav.
The list of nav items is created by function getNavItems() in the block controller that internally loops through and filters a list of all possible nav items, within that by, amongst other things, calling function excludeFromNavViaAttribute(), so in a block controller override you could add a new attributes test within the loop or called function.
Beware of the potential for awful performance issues. The autonav list works by getting all pages and then filtering it down. By having a big list of pages filtered to just a few pages, the nav list generation could be extremely inefficient.
You may achieve greater efficiency by working the other way round, creating a custom page list, adding an attribute is_my_featured to the controller, then creating a view that renders like an autonav.