[Radiant] Simplify with Behaviors

Mac Baker squamosity at gmail.com
Mon Aug 14 14:10:13 CDT 2006


Hi all,

I'm almost finished with a site built on radiant (my first). But I  
still don't understand behaviors fully.

I have a sub-navigation which changes based on the URL, But I can't  
help but feel that:
A) there is a easier, cleaner way to do this even without behaviors and
B) It seems like this would be something to write a behavior for (I  
think)

Here is the code, any suggestions?

(also, the if_url to set the class to "activelink" doesn't seem to work.
It works if it is hard coded but the slug doesn't seem to return the  
right value while in the if_url context.)

(and yes I know about the navigation tag, but I'd still need to check  
the url and
iterate through the children to build the array.)

(and....just in case you were wondering why, I don't want to see the  
children of each page, I want to see the children of each section  
throughout each page in the entire section
Area
    Section
        Page
        Page  <-- If here, still show section and section children
           Page
           Page
        Page )



# START  sub-nav snippet

<dl id="sub-nav">
       <r:if_url matches="^/$">
         <r:find url="/membership">
           <r:children:each>
             <dd <r:if_url matches="^/<r:slug />">class="activelink"</ 
r:if_url>><r:link /></dd>
           </r:children:each>
         </r:find>
      </r:if_url>
       <r:if_url matches="^/membership">
         <r:find url="/membership">
           <r:children:each>
             <dd <r:if_url matches="^/membership/<r:slug / 
 >">class="activelink"</r:if_url>><r:link /></dd>
           </r:children:each>
         </r:find>
      </r:if_url>
       <r:if_url matches="^/about">
         <r:find url="/about">
           <r:children:each>
             <dd <r:if_url matches="^/about/<r:slug / 
 >">class="activelink"</r:if_url>><r:link /></dd>
           </r:children:each>
         </r:find>
       </r:if_url>
       <r:if_url matches="^/articles/">
         <r:find url="/articles">
          <r:children:each>
             <dd <r:if_url matches="^/articles/<r:slug / 
 >">class="activelink"</r:if_url>><r:link /></dd>
           </r:children:each>
         </r:find>
       </r:if_url>
       <r:if_url matches="^/resources">
         <r:find url="/resources">
           <r:children:each>
             <dd <r:if_url matches="^/resources/<r:slug / 
 >">class="activelink"</r:if_url>><r:link /></dd>
           </r:children:each>
         </r:find>
       </r:if_url>
       <r:if_url matches="^/community">
         <r:find url="/community">
           <r:children:each>
             <dd <r:if_url matches="^/community/<r:slug / 
 >">class="activelink"</r:if_url>><r:link /></dd>
           </r:children:each>
         </r:find>
       </r:if_url>
</dl>


# end sub-nav snippet

Mac Baker


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.radiantcms.org/pipermail/radiant/attachments/20060814/d9605a1d/attachment.html


More information about the Radiant mailing list