Jump to:

22997 Posts in 11844 Topics by 2828 members

General Questions

SilverStripe Forums » General Questions » get Image from another page type

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

Page: 1
Go to End
Author Topic: 487 Views
  • Xazen
    Avatar
    Community Member
    18 Posts

    get Image from another page type Link to this post

    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.

  • DesignerX.com.au
    Avatar
    Community Member
    107 Posts

    Re: get Image from another page type Link to this post

    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

  • Xazen
    Avatar
    Community Member
    18 Posts

    Re: get Image from another page type Link to this post

    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!

  • DesignerX.com.au
    Avatar
    Community Member
    107 Posts

    Re: get Image from another page type Link to this post

    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 )

  • Xazen
    Avatar
    Community Member
    18 Posts

    Re: get Image from another page type Link to this post

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

    487 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.