Hi folks, I have a set of navigation tags here: http://svn.artofmission.com/svn/plugins/radiant/plugins/ navigation_tags/
Basically, it lets you build nested navigation like you see here: http://radiant.artofmission.com/blog/ The idea is to expand the navigation below the page that you're currently on. So if you're on the "About" page, you see only the two top-level items, but if you go to the "Blog" page, you see that page's sub-pages in the nav. The trouble is that the tags are very slow - rendering the page can take as long as 2-3 seconds on a big site. (Once the page is cached, it loads very quickly of course.) If anyone would like to help me figure out how to make this work faster, your help would be much appreciated! Here are the snippets that I use to generate that navigation: SNIPPET: nav <div id="nav"> <r:find url="/"> <ul> <r:children:each> <r:snippet name="sub-nav" /> </r:children:each> </ul> </r:find> </div> SNIPET: sub-nav <r:unless_content part="no-map"> <li<r:if_self> class="current"</r:if_self>><r:link /> <r:if_children> <r:if_ancestor_or_self> <ul> <r:children:each> <r:snippet name="sub-nav" /> </r:children:each> </ul> </r:if_ancestor_or_self> </r:if_children> </li> </r:unless_content> As far as I can tell, it's the "if_ancestor_or_self" tag that's slowing it down. Here is the content of navigation_tags.rb: module StandardTags include Radiant::Taggable # Inspired by this thread: # http://www.mail-archive.com/[email protected]/ msg03234.html desc %{ Renders the contained element if the current item is an ancestor of the current page or if it is the page itself. } tag "if_ancestor_or_self" do |tag| tag.expand if (tag.globals.actual_page.ancestors + [tag.globals.actual_page]).include?(tag.locals.page) end desc %{ Renders the contained element if the current item is also the current page. } tag "if_self" do |tag| tag.expand if tag.locals.page == tag.globals.actual_page end desc %{ Renders the contained elements only if the current contextual page has children. *Usage:* <pre><code><r:if_children>...</r:if_children></code></pre> } tag "if_children" do |tag| children = tag.locals.page.children tag.expand if children.size > 0 end end _______________________________________________ Radiant mailing list Post: [email protected] Search: http://radiantcms.org/mailing-list/search/ Site: http://lists.radiantcms.org/mailman/listinfo/radiant
