Confusion with Autonav Attribute(s)
Permalink
Ok, so I'm trying to pull a custom attribute to display within the autonav block, but I'm baffled as to why is going on.
I've played with it for about a good hour or so but still can't figure out what is going on.
I've created two (2) custom attr called 'mega_thumbnail' and 'mega_text' and I'm pulling it into the autonav via;
...and displaying them like this for... (for texting purposes)
it works perfectly :) happy days!
But now if I want to push the boundaries and display the same thing under '$ni->hasSubmenu', it doesn't work. No attributes seems to display properly.
Don't understand why, can anyone shine some light on this and stop my head hurting, please?
I've played with it for about a good hour or so but still can't figure out what is going on.
I've created two (2) custom attr called 'mega_thumbnail' and 'mega_text' and I'm pulling it into the autonav via;
// MY CUSTOM ATTRUBITE $targetPage = $ni->cObj; $megaText = $targetPage->getAttribute('mega_text'); $ih = Loader::helper('image'); $img = $ni->cObj->getAttribute('mega_thumbnail'); if ($img) { $thumb = $ih->getThumbnail($img, 500, 500, false); $megaThumb = $thumb->src; }
...and displaying them like this for... (for texting purposes)
<?php defined('C5_EXECUTE') or die("Access Denied."); $navItems = $controller->getNavItems(); $c = Page::getCurrentPage(); foreach ($navItems as $ni) { $classes = array(); if ($ni->isCurrent) { $classes[] = 'nav-selected'; } if ($ni->inPath) { $classes[] = 'nav-path-selected'; } if (!empty($ni->attrClass)) { $classes[] = $ni->attrClass; } $classes[] = 'nav-item-' . $ni->cID;
Viewing 15 lines of 48 lines. View entire code block.
it works perfectly :) happy days!
But now if I want to push the boundaries and display the same thing under '$ni->hasSubmenu', it doesn't work. No attributes seems to display properly.
<?php defined('C5_EXECUTE') or die("Access Denied."); $navItems = $controller->getNavItems(); $c = Page::getCurrentPage(); foreach ($navItems as $ni) { $classes = array(); if ($ni->isCurrent) { $classes[] = 'nav-selected'; } if ($ni->inPath) { $classes[] = 'nav-path-selected'; } if (!empty($ni->attrClass)) { $classes[] = $ni->attrClass; } $classes[] = 'nav-item-' . $ni->cID;
Viewing 15 lines of 53 lines. View entire code block.
Don't understand why, can anyone shine some light on this and stop my head hurting, please?
UPDATE: Or an attribute does display, but not in the correct location. For example, it would be displaying the attribute results within the NEXT <ul> and not it's proper <ul>. It would be like a LOOP which has a delay of displaying attribute results until the 2nd LOOP, apart from in the 2nd LOOP it would display the attribute results from the 1st LOOP.... and so on :(