Forum: Radiant CMS Tags in stylesheets

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Marshal L. (Guest)
on 2007-04-16 03:46
(Received via mailing list)
Hi all.

I'm putting together a site with Radiant (love the ease of use and
flexibility -- thanks to everyone involved in the project). From what
I've read in the mailing list archives, I should be able to use radius
tags in my stylesheet, just like other pages, to dynamically
create/change the content.

For example, if I wanted the background color of the "about" page to
be different than the other pages, something like this should work:

   body {
     background-color: #d7dba9;
    <r:if_url matches="/about/">background-color: #009a3b;</r:if_url>
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 80%;

but it doesn't.

My stylesheet is a Radiant page, just like the style.css created with
the type 3 (styled blog) install of Radiant. When I view the generated
css file in my browser, a blank line appears in place of the line with
the tags:

   body {
     background-color: #d7dba9;

    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 80%;

Any ideas? Have I missed something obvious? Thanks for any help.

PS. This is a trivial example. I could get the different colored
background easily with
   <body id="<r:slug />"> in the page layout and
   body#about { background-color: #009a3b; } in the stylesheet.
Sean C. (Guest)
on 2007-04-16 04:02
(Received via mailing list)
Keep in mind that your stylesheet is rendered just like a Radiant page.
If you're linking it in the traditional pattern, <r:if_url /> will try
to match the URL of the stylesheet, not the HTML page being viewed. This
is because the request to get the stylesheet is not the same request as
the one to get the page.

You might try putting some code like this in your main layout:

<style type="text/css">
<r:content part="styles" inherit="true" />

Then in your pages that need specific changes to the style, make a
"styles" tab/part and dump the special styles in there.  So on the
"About" page that has the url "/about/", you could put this:

body {
  background-color: #009a3b;

This would accomplish what you want, and be more flexible.

Marshal L. (Guest)
on 2007-04-16 07:49
(Received via mailing list)
Thanks Sean. I thought it might be something like that. Appreciate
your explanation.
This topic is locked and can not be replied to.