Get Custom Attribute Value within Autonav Block

Permalink 2 users found helpful
I have a custom attribute on some pages called 'navDescription' and want to use the value in that attribute's field as part of an Autonav template.

What do I need to add to the autonav template? I'm guessing it is something along the lines of:
foreach ($navItems as $ni){
   $customAttribute = $ni->getAttribute('navDescription');
   echo $customAttribute;
}


but I'm getting the error "Fatal error: Call to undefined method stdClass::getAttribute()." Please help!

cramaekers
View Replies:
cramaekers replied on at Permalink Reply
cramaekers
Well I got it working, but still want to know if there is a better/cleaner/more efficient way to do this.

Here is what I ended up doing:
foreach ($navItems as $ni) {
   $targetPage = $ni->cObj;
   $navDescription = $targetPage->getAttribute('navDescription');
   echo $navDescription;
}
Chrouglas replied on at Permalink Reply
Thanks for posting your solution. I came across it when I was trying to create an auto nav with a dead link. I needed the parent of a set of nav items to be displayed but not go anywhere when clicked. I can now have my autonav check a custom attribute to see if its link should be included. Thanks again.

Cheers,
C
cramaekers replied on at Permalink Reply
cramaekers
I'm glad this was of assistance to you!