Hide Blog posts from autonav - Exclude From Nav

Permalink Browser Info Environment
Hello,

Great plugin so far, go it integrated nicely with site I'm currently working on. Just one question - how can I hide the blog posts from my navigation? I want to have the blog section link in my nav, but not the sub pages (i.e. the posts).

I don't want the site editor to have to go and manually set the exclude from nav attribute every time he posts a new blog article.

Thanks you!

Type: Discussion
Status: New
mrjcgoodwin
View Replies: View Best Answer
RadiantWeb replied on at Permalink Best Answer Reply
RadiantWeb
check out this video:

http://vimeo.com/35577674

ChadStrat
mrjcgoodwin replied on at Permalink Reply
mrjcgoodwin
Thanks Chad for the quick reply. This is a good work around.

Is this the only way to achieve this though? The problem being that I am using custom attributes on my site map for some other styling/functionality that affects my nav, and as far as I can tell I can't apply custom attributes to the external links or aliases?
mrjcgoodwin replied on at Permalink Reply
mrjcgoodwin
Bit hacky, but this thread has a quick solution for this problem:
http://www.concrete5.org/index.php?cID=39089&editmode=...
yulolimum replied on at Permalink Reply
yulolimum
ChadStrat's way is a perfect way of doing this. However, I didn't want to have a secondary parent page on a website that I am making because it features multiple blogs and multiple categories in dropdowns - the sitemap would just be a mess (i hate mess). This is a very simple solution that I came up with involving a simple if statement and some css (and optional jquery).

I would first copy the concrete/blocks/autonav/view.php into blocks/autonav/view.php.

Find:
echo '<li class="' . $ni->classes . '">'; //opens a nav item


and replace with:
if ($ni->cObj->vObj->ctHandle == "pb_post") {
   echo '<li class="hidden">'; 
} else {
   echo '<li class="' . $ni->classes . '">'; //opens a nav item
}


This adds a class to nav items that have the pb_post template (which is the pro blog template).

Now use some CSS to hide the class:
.hidden {
  display: none;
}


You are done at this point. Any nav link that is a problog post will be hidden.


Optional:
The only problem that remains is that if your dropdown menu has a border, it will be visible when you hover on your parent nav item. I am using some jQuery to completely get rid of the pb_post list item, and then check and see if the dropdown has anything, and if it doesn't, get rid of it as well:
$('.hidden').remove();
  $('nav ul').each(function(){
    if ($(this).is(':empty')) {
      $(this).remove();
    }
  });
jamesleech replied on at Permalink Reply
jamesleech
Is this still valid with the current version of concrete?
I tried to locate this but can't spot in the view.php file
yulolimum replied on at Permalink Reply
yulolimum
andrewgstreet replied on at Permalink Reply 1 Attachment
andrewgstreet
If you need a code solution, let me offer up this hack.

In your autonav view.php (or your autonav template), just before the loop, where you see

foreach($aBlocks as $ni)


Add the following block of code

//This is sort of a hack, but we'll remove any blocks whose parent
//has an "exclude_nav_children" attribute set to true
foreach($aBlocks as $outer) {
   $outerCollection = $outer->getCollectionObject();
   if ($outerCollection->getCollectionAttributeValue('exclude_nav_children')) {
      //This item is set to exclude children. Let's find and remove them
      $targetId = $outerCollection->cID;
      $count = 0;
      foreach($aBlocks as $inner) {
         $innerCollection = $inner->getCollectionObject();
         //Found one! Let's nix it.
         if ($innerCollection->getCollectionParentID() == $targetId) {
            unset($aBlocks[$count]);
         }
         $count++;


After this, go into Attributes, under pages and themes and add an attribute with:

Handle: exclude_nav_children
Name: Exclude Children When Top Level
Set: Navigation and Indexing.
Type: Boolean

Now set this attribute to true on each page where you want to hide the children.

If you don't have a specific autonav template, copy view.php from concrete > blocks > autonav > view.php to blocks > autonav > view.php and add the code to this version.

I'm sure there is some more elegant approach such as an update to the autonav controller.php. But this is the best hack I could come up with in 15 minutes.

Hope this helps.

--Andy
RadiantWeb replied on at Permalink Reply
RadiantWeb
Greetings C5 users,

For support, please direct all questions and issue to the products "support" area.

For pre-sales, please direct your questions to the products "pre-sales" area.

Thanks again for being a ChadStrat product supporter.

Blessings,
ChadStrat

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.