Forum: Radiant CMS Tags in stylesheets

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
791449df6678fbf08b87857130fa5f12?d=identicon&s=25 Marshal Linfoot (Guest)
on 2007-04-16 01: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%;
    etc...
  }

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%;
    etc...
  }

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.
8802b1fa1b53e2197beea9454244f847?d=identicon&s=25 Sean Cribbs (Guest)
on 2007-04-16 02: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:

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

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.

Sean
791449df6678fbf08b87857130fa5f12?d=identicon&s=25 Marshal Linfoot (Guest)
on 2007-04-16 05: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.