CSS body style from template option ?

Skinning and designing Serendipity (CSS, HTML, Smarty)
Post Reply
sonichouse
Regular
Posts: 196
Joined: Sun May 11, 2008 2:53 am
Contact:

CSS body style from template option ?

Post by sonichouse »

I have the following in my style.css
background: url({TEMPLATE_PATH}img/{$template_option.backgroundimg}) no-repeat 0 0 #fff;
The {$template_option.backgroundimg} is correctly expanded to aerodrome.jpg when I print it within index.tpl, but the option does not get expanded in the CSS.

How do I achieve this ?
Steve is occasionally blogging here
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: CSS body style from template option ?

Post by yellowled »

sonichouse wrote:I have the following in my style.css
background: url({TEMPLATE_PATH}img/{$template_option.backgroundimg}) no-repeat 0 0 #fff;
The {$template_option.backgroundimg} is correctly expanded to aerodrome.jpg when I print it within index.tpl, but the option does not get expanded in the CSS.

How do I achieve this ?
Smarty doesn't work in CSS stylesheets (because it's a PHP template system). Inline styles in your index.tpl should work, though. See Bulletproof's index.tpl for an example (<style type="text/css"> at the beginning of it).

Sorry I don't have much time to explain this in detail now.

HTH,
YL
sonichouse
Regular
Posts: 196
Joined: Sun May 11, 2008 2:53 am
Contact:

Post by sonichouse »

Thanks YL, that was the info I required.

Code: Select all

<style type="text/css">
    body {ldelim}background: url({$serendipityHTTPPath}templates/{$template}/img/{$template_option.backgroundimg}) no-repeat 0 0 #fff;{rdelim}
</style>
Works like a charm.
Steve is occasionally blogging here
Don Chambers
Regular
Posts: 3657
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post by Don Chambers »

Steve - I think that will work as just img/{$template_option.backgroundimg} - give it a try.
=Don=
sonichouse
Regular
Posts: 196
Joined: Sun May 11, 2008 2:53 am
Contact:

Post by sonichouse »

Don Chambers wrote:Steve - I think that will work as just img/{$template_option.backgroundimg} - give it a try.
Hi Don,
I lost the {$serendipityHTTPPath} ...
url(templates/{$template}/img/{$template_option.backgroundimg})
Was the only combination that works.
Steve is occasionally blogging here
Post Reply