Correct code for image attribute
Permalink 1 user found helpfulI have problem with code to call the image attribute in page list.
I put a code:
<img width="250px" src=<?php echo($c->getAttribute('okladka')->getVersion()->getRelativePath());?>>
The site works perfect. But when I try to add page by form this error occur:
Call to a member function getVersion() on a non-object.
I'm using Concrete 5.7
Call to a member function getRelativePath() on a non-object
I notice that the problem appears when there is no value to the attribute.
$c = Page::getCurrentPage();
this is the code what I have on my site:
<?php $this->inc('elements/header.php'); ?> <h1><?php echo $c->getCollectionName() ?></h1> <?php $c = Page::getCurrentPage(); ?> <table cellpadding="10" style="width: 100%" class="tekst"> <tr> <td width="250px" valign="top"> <img width="250px" src=<?php echo($c->getAttribute('okladka')->getRelativePath());?>> </td> <td> <!--Opis--> <?php echo $c->getAttribute('Opis');?> <!--Opis--> </td> </tr> </table>
THANK YOU VERY MUCH!:)
Did you try it without getVersion()?