Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Blog Module /

Discuss the Blog Module.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

BlogEntry is not an array problem


Go to End


1249 Views

Avatar
TomMiller

Community Member, 26 Posts

25 November 2011 at 9:09pm

Hi all,
i want to extend a blogentry with a picture. I tried this code:
in BlogEntry.php i wrote a new function:
function NewsImage() {

$actualBlogEntry = DataObject::get_by_id($this->ClassName, $this->ID);
if (var_dump(isset($newsImage["NewsPicture"]))) {
return true;
};

return false;
}

and in BlogEntry.ss
<% if NewsImage %>
<img class="newsimage" src="assets/newsimages/$NewsPicture" alt="$Title" title="$Title"/>
<% end_if %>

Unfortunately i can't access $actualBlogEntry as an array like $actualBlogEntry[NewsPicture].
When using print_r $actualBlogEntry i can see NewsPicture.
Is it somehow possible to access the Blogentrymember "NewsPicture"?

TIA Tom