# Troubles with \<r:if\_self\>

**URL:** <https://www.ruby-forum.com/t/troubles-with-r-if-self/140685>\
**Category:** Radiant CMS\
**Created:** [June 17, 2008, 2:46pm UTC](https://www.ruby-forum.com/t/troubles-with-r-if-self/140685 "2008-06-17T14:46:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nancy\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/90db22/32.png) [@Nancy\_C](https://www.ruby-forum.com/u/Nancy_C)\
**Post date:** [June 17, 2008, 2:46pm UTC](https://www.ruby-forum.com/t/troubles-with-r-if-self/140685/1 "2008-06-17T14:46:55Z")

</div>

Hmmm, there is obviously something I am missing with regards to  
\<r:if\_self\> and \<r:if\_ancestor\_or\_self\> and Radiant 0.6.6.

I’ve made a little menu, and it works just fine, except that all cases  
of \<r:if\_self\> are simply ignored, and a blank space is inserted in my  
rendered html.

In the case of \<r:if\_ancestor\_or\_self\> a:  
“

**undefined method `url’ for nil:NilClass**
”  
is rendered for each child element, and the class is also not inserted  
here either.

---- My Menu —

 \<li id="\<r:slug /\>" class="current" \> 
 \<li id="\<r:slug /\>" class="here" \> 

* * *

Anybody know why this isn’t working like I expect it to? I imagine it’s  
an assumption of mine…

In any case, thanks in advance!  
Nancy

---

<div class="post-metadata">

**Author:** ![Nancy\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/90db22/32.png) [@Nancy\_C](https://www.ruby-forum.com/u/Nancy_C)\
**Post date:** [June 17, 2008, 3:21pm UTC](https://www.ruby-forum.com/t/troubles-with-r-if-self/140685/2 "2008-06-17T15:21:37Z")

</div>

Nancy,

I’m not sure why they do not work for you or where that error comes  
from, but here’s a couple tips.

Your inner \<r:unless\_content\> is a duplication of logic from the outer  
scope. I think you probably want it on the inside of the inner  
\<r:children:each\>.

If you want to use the title of the page in a link to the page, just use  
\<r:link /\>, not \<r:link\>\<r:title /\>\</r:link\>. The title is the default  
text of the link.

Using \<r:title /\> in the id attribute for the submenu might break the  
prohibition on spaces in that attribute. \<r:slug /\> would be a better  
choice.

Sean

---

<div class="post-metadata">

**Author:** ![Nancy\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/90db22/32.png) [@Nancy\_C](https://www.ruby-forum.com/u/Nancy_C)\
**Post date:** [June 17, 2008, 4:13pm UTC](https://www.ruby-forum.com/t/troubles-with-r-if-self/140685/3 "2008-06-17T16:13:57Z")

</div>

Hi Sean,  
Thanks for your tips! I’ve applied them all except the one about  
\<r:unless\_content\>. I have pages on both levels that I would prefer not  
show up in the menu, and I couldn’t convince the outer one to filter the  
inner ones as well. Unfortunately, nothing has changed with regard to  
\<r:if\_self\> et al.

I’ll keep trying though, and thanks again.  
Nancy

Sean C. schrieb:
