Custom Attribute to filter in Autonav Template

Permalink
Hello everybody

I'm looking for an opportunity in the Autonav View filter on attributes in c5 5.7. In my case I want some navitems only in a meta navigation to spend and not in the main navigation. Can someone help me or give a tip?

Thanks
Marcus

View Replies: View Best Answer
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi marcusm,

I am afraid I don't understand the question.

Please provide more details for what you are trying to accomplish.
marcusm replied on at Permalink Reply
Hi MrK

Ok, in concrete5 5.6 i set a custom page attribute (checkbox) with value 'only_metanavigation'. In autnav view i do this:
$aBlocks = $controller->generateNav();
   $c = Page::getCurrentPage();
   echo("<ul id=\"topnav\">");
   $nh = Loader::helper('navigation');
   $isFirst = true;
   foreach($aBlocks as $ni) {
      $_c = $ni->getCollectionObject();
      if ($_c->getCollectionAttributeValue('only_metanavigation')) {


I'm using $_c->getCollectionAttributeValue('only_metanavigation) to get the value in concrete5 5.6 but whats the best practice to do this in concrete5 5.7?

I hope now you can understand my question?

Greets
Marcus
MrKDilkington replied on at Permalink Best Answer Reply 1 Attachment
MrKDilkington
@marcusm

I believe I understand what you are looking to do.

I have attached a custom template for the Auto-Nav block.
application\blocks\autonav\templates\meta_navigation\view.php

These are the main changes:
foreach ($navItems as $ni) {
    if ($ni->cObj->getCollectionAttributeValue('only_metanavigation')) {
        echo '<li class="' . $ni->classes . '">'; //opens a nav item
        echo '<a href="' . $ni->url . '" target="' . $ni->target . '" class="' . $ni->classes . '">' . $ni->name . '</a>';
    }
}

As you loop through the $navItems array, you will get the individual nav item's collection object. You then call the getCollectionAttributeValue() method on the collection object to get the value of the "only_metanavigation" attribute.
marcusm replied on at Permalink Reply
MrKDilkington that's it!

Many thanks