Hey all,

I've got a problem with using <r:if_url> in a layout for a news (Archive)
page. I am trying to display a snippet based on the URL. Here's the bit of
my layout in question:

        <r:if_url matches="^/news/\d{4}/\d{2}/\d{2}/.">
          <r:snippet name="posted" />

So, in other words, if we're on a news article page (if there is any
character present after the trailing slash), then display the snippet.
Trouble is, the snippet also gets displayed on the monthly archive page,
where the regex doesn't match the URL. However, it *doesn't* display on the
/news/ URL.

I've tried the regex with and without escaping the forward slashes and
tested in both Rubluar and Regex Buddy and there doesn't seem to be any
problem with the regex itself.

I've found the only way to get this working is to use the following;

        <r:if_content part="summary">
          <r:snippet name="posted" />

The logic here being that each article has a summary part whereas the
archive pages do not. This is a bit of a brittle solution, though, because I
don't necessarily want every article to have a summary. I suppose I could
create the summary part every time and leave it empty. Any better ideas?

This reminds me of another question actually: is it possible to generate a
child page with a default set of parts?

Radiant mailing list
Post:   Radiant@radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant

Reply via email to