Custom attribute using CSS

Permalink
Hi - I have a template which using a similar layout structure throughout however the background colours/designs change via css in five different ways in the content area div and the footer.

I wanted to avoid making 5 different templates by making a custom attribute to two of the divs.

They are marked up like this

<div id="content" class="blue-gradient">
 <div class="blue-gradient-footer" id="lowerFooter">


Is there a way of setting up a custom attribute to call in the different coloured divs to save having to make a new template each time?

Not sure which attribute type I should use or how to implement it?

Any ideas would I'd be really grateful for...

chassa2556
 
jbx replied on at Permalink Reply
jbx
Use a select box attribute. Call it something like 'color'. Have the different colors available in the select box (Red, Blue, Green etc.).

Then, in your page, you can do this:
<div id="content" class="<?php echo $c->getCollectionAttributeValue('color') ?>-gradient">


Would that work?

Jon
chassa2556 replied on at Permalink Reply
chassa2556
Thanks for this John its not seeming to call it yet though I've set up the attribute color and given the values of red, green etc which relate to the class names. Its not pulling in the names though.
<div id="content"class="-gradient"

Any ideas am I doing something wrong here.
jbx replied on at Permalink Reply
jbx
Is this in a page type file or a block view? And have you made a selection in the page properties?

Jon
chassa2556 replied on at Permalink Reply
chassa2556
I have edited my template .php file for the page type with this code. Yes I made a selection in the properties panel.
jbx replied on at Permalink Reply
jbx
Should work then - put this in your page and let me know if it outputs anything...
<?php var_dump($c) ?>
chassa2556 replied on at Permalink Reply
chassa2556
It's coming up with a whole lot of errors when I do this. I am working on my local machine using MAMP. Could this be the reason?
jordanlev replied on at Permalink Reply
jordanlev
Try adding this line before the one jbx suggests:
<?php global $c; ?>