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.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

get Image from another page type


5 Posts   569 Views


14 November 2011 at 12:23pm Community Member, 18 Posts

I hve got a PageType with an Image.

class News extends Page{
   static $has_one = array(
      'BannerImage' => 'Image'


My news page has multiple children:

class ArticleCategory extends Page{
   static $has_one = array(

Now I want that all ArticleCategorys have the same BannerImage as News.


14 November 2011 at 1:04pm Community Member, 107 Posts

ok, i dont 100% understand what you need to be done, but i think you trying to pull the image from "News" page to display on the "ArticleCarigory" ?! if this is it, Do the following:
in the Articlegatigory.SS add this: <% control children %> $BannerImage <% end_control %> << this will take the image from the childrent pages & list them on the Articlegatigory.SS page .
If you trying to do something different, please explain more below ;)
good luck


14 November 2011 at 1:12pm Community Member, 18 Posts

Yes thats what I want. But I think I should have explain more in detail. News is the parent and the ArticleCategorys are the children. However you give me the hint to the solution. I used <% control parent %> $BannerImage <% end_control %>

I was pretty sure that it won't be something too complicated. But I haven't expected that it would be that easy. Thanks! :)


14 November 2011 at 1:21pm Community Member, 107 Posts

kk nice, also, from the 1st time istarted SS, i have started collection some samples & code that i use alot, here is the link..

It is not that something big, but it save me having to search for small codes all the time..
If you want,
.. one more, use the live chat as i am there 24/7 for the next few weeks (if no one replay to You( afk) , then come back to forums of course )


15 November 2011 at 8:52am Community Member, 18 Posts

Wow that's quiet a helpful site. Thanks a lot :)