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


Reply


5 Posts   592 Views

Avatar
Xazen

Community Member, 18 Posts

14 November 2011 at 12:23pm

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(
      'BannerImage'=>'Image'
}

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

Avatar
DesignerX.com.au

Community Member, 107 Posts

14 November 2011 at 1:04pm

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

Avatar
Xazen

Community Member, 18 Posts

14 November 2011 at 1:12pm

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! :)

Avatar
DesignerX.com.au

Community Member, 107 Posts

14 November 2011 at 1:21pm

kk nice, also, from the 1st time istarted SS, i have started collection some samples & code that i use alot, here is the link..
http://www.sspaste.com/paste/show/4ebe879fe1f63

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 http://irc.silverstripe.org/cgi-bin/irc.cgi 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 )

Avatar
Xazen

Community Member, 18 Posts

15 November 2011 at 8:52am

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