# Simplify with Behaviors

**URL:** <https://www.ruby-forum.com/t/simplify-with-behaviors/64896>\
**Category:** Radiant CMS\
**Created:** [August 15, 2006, 2:20pm UTC](https://www.ruby-forum.com/t/simplify-with-behaviors/64896 "2006-08-15T14:20:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mac\_Baker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b9bd4f/32.png) [@Mac\_Baker](https://www.ruby-forum.com/u/Mac_Baker)\
**Post date:** [August 15, 2006, 2:20pm UTC](https://www.ruby-forum.com/t/simplify-with-behaviors/64896/1 "2006-08-15T14:20:10Z")

</div>

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
 \<dd class="activelink"\> \<dd class="activelink"\> \<dd class="activelink"\> \<dd class="activelink"\> \<dd class="activelink"\> \<dd class="activelink"\> 
# end sub-nav snippet

Mac Baker

---

<div class="post-metadata">

**Author:** ![Mac\_Baker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b9bd4f/32.png) [@Mac\_Baker](https://www.ruby-forum.com/u/Mac_Baker)\
**Post date:** [August 15, 2006, 2:20pm UTC](https://www.ruby-forum.com/t/simplify-with-behaviors/64896/2 "2006-08-15T14:20:20Z")

</div>

/me ports a snippet to markaby for giggles.

dl.sub-nav! do  
r.if\_url\_matches “^/$” do  
r.find\_url("/membership").each do |p|  
dd.send(p.current\_page?) { link\_to p }  
end  
end  
end

Please… for the love of KIS, let’s start to move away from the  
gobbly gook that is radius (at least within the domain of  
radiant.layouts).

🙂

* * *

Caylan

---

<div class="post-metadata">

**Author:** ![Mac\_Baker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b9bd4f/32.png) [@Mac\_Baker](https://www.ruby-forum.com/u/Mac_Baker)\
**Post date:** [August 15, 2006, 2:20pm UTC](https://www.ruby-forum.com/t/simplify-with-behaviors/64896/3 "2006-08-15T14:20:23Z")

</div>

Caylan Van L. wrote:

> Please… for the love of KIS, let’s start to move away from the gobbly  
> gook that is radius (at least within the domain of radiant.layouts).

Not everyone can afford to let users put ruby code in the database.

Your plugin for markaby makes it simple enough, eh? 😉

–  
John L.  
[http://wiseheartdesign.com](http://wiseheartdesign.com)

---

<div class="post-metadata">

**Author:** ![Mac\_Baker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b9bd4f/32.png) [@Mac\_Baker](https://www.ruby-forum.com/u/Mac_Baker)\
**Post date:** [August 15, 2006, 2:20pm UTC](https://www.ruby-forum.com/t/simplify-with-behaviors/64896/4 "2006-08-15T14:20:25Z")

</div>

Okey,

here’s a simple one that I’ve been unable to find in the list  
archives: when using Radiant as a weblog and I display a single post,  
how can I refer to the previous and next pages so I can do the the  
previous/next link thingy? OK, I imagine I can use r:children with an  
offset, but where do I place it so it only renders when viewing a  
single page?

andrew
