Page 1 of 1
CSS body style from template option ?
Posted: Wed Dec 10, 2008 9:40 pm
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 ?
Re: CSS body style from template option ?
Posted: Wed Dec 10, 2008 11:22 pm
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
Posted: Wed Dec 10, 2008 11:42 pm
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.
Posted: Thu Dec 11, 2008 12:25 am
by Don Chambers
Steve - I think that will work as just img/{$template_option.backgroundimg} - give it a try.
Posted: Thu Dec 11, 2008 9:18 am
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.