Thanks for the help, Will.

I must be misunderstanding this in a fundamental way.
Here's what I have in my layout:

<r:if_url matches="^/">
<r:snippet name="slider" />
<r:snippet name="main" />
<r:content part="sidebar" inherit="true" />
<r:snippet name="foot" />
</r:if_url>
<r:unless_url matches="^/about$">
<r:snippet name="main" />
<r:content part="sidebar" inherit="true" />
<r:snippet name="foot" />
</r:unless_url>

By my reckoning, that should render all the snippets -- including the
slider, which has the About Me info -- on every page except the /about
page, for which the above code is intended to remove the slider. But
what happens in the above scenario is that the snippets are rendered
twice on every page (This creates such a messy page that I have not
even looked for the slider snippet to see if it is rendered twice. I
think I should fix the reproduction first.)

What am I missing?

On Feb 23, 9:16 am, William Ross <w...@spanner.org> wrote:
> On 23 Feb 2011, at 17:01, rosslaird wrote:
>
>
>
>
>
>
>
>
>
> > In the radiant wiki over on github (I am posting this here because the
> > wiki on github seems to have very low readership), the conditional
> > tags page show this example code:
>
> > <head>
> > <r:if_url matches="^/$">
> >  <title>Radiant Handbook</title>
> > </r:if_url>
> > <r:unless_url matches="^/$">
> >  <title><r:title/> - Radiant Handbook</title>
> > </r:unless_url>
> > </head>
>
> > The documentation goes on to say that "the code above would set the
> > page title as “Radiant Handbook” on the homepage, but for all subpages
> > it would use the title of the page, then “… – Radiant Handbook”.
>
> > Now, when I look at the url regexp in the first bit (if_url matches),
> > then I look at the regexp in the second bit (unless_url), these two
> > expressions look *exactly the same* to me. Each one is "^/$". Am I
> > blind, or are they the same? And if they are the same, should they be?
> > And if not, what should they be?
>
> The lack of an else clause in radius makes for rather clumsy notation 
> sometimes: this is really just an if/then/else construction to check for 
> rootpageness. In radius that has to be written as if and then unless with the 
> same condition. In this example the path stays the same so that the same 
> condition is applied first positively then negatively.
>
> > I am trying to show an "About Me" link (in an id that slides in and
> > out with JS) on my site on every page except the /about page (which
> > already is about me...). It seems that if_url and unless_url are the
> > way to go here, but I can't seem to get it to work. And I'm wondering
> > is the reason for that has to do with the example code I've been
> > adapting. I just changed the unless_url link to <r:unless_url
> > matches="^/about/$">, but no dice. The About Me link still shows on
> > that page.
>
> Your regex should work for /about/, but it does depend on the url that is 
> requested. It's a rails quirk that /about and /about/ are considered the same 
> path, for example. Partial matches are fine so if the site is simple you 
> might have better results with <r:unless_url matches="^/about">. Depending on 
> the server, you may also want to set ignore_case="true".
>
> best,
>
> will

Reply via email to