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=^/$
titleRadiant Handbook/title
/r:if_url
r:unless_url matches=^/$
titler: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