Jump to:

1840 Posts in 1563 Topics by 557 members

Blog Module

SilverStripe Forums » Blog Module » BlogEntry is not an array problem

Discuss the Blog Module.

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

Page: 1
Go to End
Author Topic: 420 Views
  • TomMiller
    Avatar
    Community Member
    26 Posts

    BlogEntry is not an array problem Link to this post

    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

    420 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.