PHP help needed on very simple issue
Permalink<style> #content: background-image: url(images/art2.jpg); </style>
and my php, like this:
and it doesn’t work. I've tried, I really have. I've analyzed the semicolons and the parens and Im lost. Im calling it in the header, of course.
Help,
steve

<style> #content{ background-image: url(<?php echo $c->getAttribute('background')->getVersion()->getRelativePath());?>) } </style>
I thought it was php.
this is without the code because if I put that in the page doesn’t render.
steve
<style type="text/css"> #content{background-color: red;} </style>
but that’s not what I need. An image would have to be called from its attribute.
<style> #content{ background-image: url(<?php echo $c->getAttribute('background')->getVersion()->getRelativePath();?>) } </style>
BTW, Im loving your new blocks.
steve
Fatal error</b>: Call to a member function getVersion() on a non-object in <b>/home/harris7/public_html/greenpedals/themes/theme_greenpetals/elements/header.php</b> on line 17
Line 17 is the code line between the style calls.
Thanks,
steve
page or the attribute isn't installed- can you check that?
On 5/12/11 10:18 PM, Concrete5 Community wrote:
http://cantanogames.com/c5/attributes.html...
For your example, all you should need is this:
<? if($file = $c->getAttribute('background') ) { ?> <style> #content{ background-image: url(<?=$file->getRelativePath();?>); } </style> <? } ?>
You don't need getVersion()->, because if you take a look at getRelativePath, it automatically takes care of it for you.
Also note, that I test to make sure that the attribute exists before using it. Very important you do that with all code.
Yes, I use short tags :p
So I'm taking it that if you call an attribute you have to test as to whether it exists or not. I thought that if it didn’t find anything it would just skip it.
I understand php a little better since starting project.
Thanks again,
steve