I wanted to post a follow-up on my original email on building dynamic
navs.  Thanks to the several folks who have posted their own
solutions.  I chatted a couple times with Sean and came up with an
almost all snippet/tag solution.  The only trick is I need this new
tag based on a recent patch by Sean that exposes the
tag.globals.actual_page.  Here's the tag:

        tag "if_ancestor_or_self" do |tag|
                tag.expand if (tag.globals.actual_page.ancestors +
[tag.globals.actual_page]).include?(tag.locals.page)
        end

So this guy essentially will expand his contents if the current page
matches the comparing page or one of its parents.

Here is the snippet code that I use to build my left nav:

        <div id="nav">
                <r:find url="/">
                        <ul>
                                <r:children:each>       
<r:snippet name="sub-nav" />
                </r:children:each>
                        </ul>
                </r:find>
        </div>
        
And the sub-nav snippet looks like this:
<r:unless_content part="no-map">
        <li><r:link />
                <r:if_ancestor_or_self>
            <ul>
                                <r:children:each>
<r:snippet name="sub-nav" />
              </r:children:each>
                        </ul>
                </r:if_ancestor_or_self>
        </li>
</r:unless_content>     

What all this builds is a nested unordered list of links found off the
root page.  I filter out pages that I don't want by putting a no-map
page part on them.  This also plays nicely with Sean's original
sitemap snippet.  This pretty much meets my needs but it may also be
better expressed as its own tag.  For one the html output has tons of
extra space as well as an empty <ul> for the lowest level children.

Cheers,
Marty
_______________________________________________
Radiant mailing list
Post:   [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant

Reply via email to