[MAGNOLIA-1223] SimpleNavigation: allow filters Created: 21/Nov/06  Updated: 23/Jan/13  Resolved: 07/Aug/08

Status: Closed
Project: Magnolia
Component/s: taglibs
Affects Version/s: 3.0 Final
Fix Version/s: 3.6.2, 3.6.3

Type: Improvement Priority: Major
Reporter: Luc Girardin Assignee: Jan Haderka
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File Add_a_contentFilter_to_SimpleNavigation.patch     Text File SimpleNavigationTag.patch    
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Date of First Response:

 Description   

The current simpleNavigation tag ignores entries that have hideInNav flag set to true. This is typically interesting for having pages that should be made visible to a limited audience (i.e. only people who know the URL can access it). However, if one goes to such a page (or sub-page), then the entry in the navigation also remains hidden. The proposed improvements, modifies this behavior by showing the hidden nodes in the navigation if they are parents of the active node. Here is a example from our website:

http://www.macrofocus.com/public/products/cartorama/

With the proposed modification, the Cartorama entry remains only visible when it is part of the selected path.

The modified SimpleNavigationTag class can be found at:

http://www.macrofocus.com/tmp/magnolia/SimpleNavigationTag.java

Would be great if this behavior could be integrated into the next release of Magnolia!



 Comments   
Comment by Sean McMains [ 22/Nov/06 ]

This actually would sabotage our usual use-case for hiddenInNav, which is simply that we don't want a page to be displayed in the navigation at all. We most commonly use it for things like news articles which we'd like to be able to link to, but not have reflected in the navigation.

I wouldn't object to adding a parameter to the SimpleNavigation tag to allow this change to be activated as needed, but changing the way existing sites with this tag work would probably be pretty disruptive.

Comment by Boris Kraft [ 24/Nov/06 ]

I agree that we should not change the existing behaviour of this. Maybe make hideInNav multivalued

  • yes - show never
  • no - show always (same as not present)
  • maybe - show when parent is displayed
Comment by Oliver Lietz [ 24/Nov/06 ]

please avoid double negation and change hideInNav to showInNav:

  • yes - show always (default)
  • no - show never (same as not present)
  • inherit (from parent)/maybe - show when parent is displayed
Comment by Philipp Bracher [ 28/Nov/06 ]

hide in nav means: this is not a menupoint at all (never)

If you like to create the menu depending on permissions, please use permissions instead of hacking the hideInNav flag. Inheritance is already supported (if the parent is not a menupoint all subpages aren't neither)

Perhpas we could refactor the tag so that you can pass a filter. This would make it realy dynamic.

Comment by Ryan Gardner [ 22/Feb/08 ]

This adds a contentFilter attribute to the simpleNavigation tag, which points to a variable in the pageContext that contains a contentFilter.

Comment by Ryan Gardner [ 22/Feb/08 ]

I just attached a patch that should solve this issue. It is used like so:

<simpleNavigation ... contentFilter="contextFilterVar" />

I don't know of an easy way to create a contentFilter and set it to a pageContext attribute yet - so in my case, I did so using a scriptlet:

<jsp:directive.page import="info.magnolia.cms.core.Content" />
<jsp:directive.page import="info.magnolia.cms.util.CollectionBasedContentFilter" />
<jsp:directive.page import="java.util.Collection"/>

<jsp:scriptlet>
Collection col = (Collection) pageContext.getAttribute("curPageCollection");
CollectionBasedContentFilter contentFilter = new CollectionBasedContentFilter(col);
pageContext.setAttribute("contentFilter", contentFilter);
</jsp:scriptlet>
<cmsu:simpleNavigation startLevel="0" endLevel="2" contentFilter="contentFilter"/>

(The CollectionBasedContentFilter is a new content filter that I am going to upload on a separate ticket - but from this you can see a simple useage of it)

Comment by Jan Haderka [ 07/Aug/08 ]

Please note that default behaviour of the tag was NOT changed. Optional filter makes the tag more flexible when the default behaviour is not enough to fulfil all the needs.

Thanks for the patch.

Generated at Mon Feb 12 03:24:51 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.