Correct code for image attribute
Permalink 1 user found helpful
Hello!
I have problem with code to call the image attribute in page list.
I put a code:
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
I 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
Yes I did and there is an error:
Call to a member function getRelativePath() on a non-object
I notice that the problem appears when there is no value to the attribute.
Call to a member function getRelativePath() on a non-object
I notice that the problem appears when there is no value to the attribute.
Are you including this before you get the attribute?
$c = Page::getCurrentPage();
Yes i did and have the same error (Call to a member function getRelativePath() on a non-object)
this is the code what I have on my site:
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>
Viewing 15 lines of 19 lines. View entire code block.
That works perfect!!!
THANK YOU VERY MUCH!:)
THANK YOU VERY MUCH!:)
Did you try it without getVersion()?