Jump to:

23459 Posts in 18906 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » Cannot Reference Banner Image more than Once

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: 1015 Views
  • tigger
    Avatar
    Community Member
    3 Posts

    Cannot Reference Banner Image more than Once Link to this post

    *** newbie/noob question (sorry) ***

    I have extended SiteTree in my Page.php to provide support for banner images on pages within my site - and this works as intended, for example:

    class Page extends SiteTree {

    public static $db = array(
    );

    public static $has_one = array(
    'BannerImage' => 'Page_BannerImage',
    );

    function getCMSFields() {
    $fields = parent::getCMSFields();
    $fields ->addFieldsToTab(
    'Root.Content.Banner',
    new ImageField('BannerImage', 'Banner')
    );

    return $fields;

    }

    function getBannerImageRecursive() {
    $page = $this;
    $banner = $this->BannerImage();
    while(!$banner->ID && $page->ParentID !=0) {
    $page = $page->Parent();
    $banner = $page->BannerImage();
    }

    return $banner;

    }

    The obstacle I have encountered is that once an image is selected from the File Store and attached to a page, that image is no longer referenced in the File Store list and cannot (apparently) be used as an attachment for another page. Yes, I know that I can attach an image from my file system (workaround?) yet, I am looking for a method that continues to enumerate the files/images on the File Store list.

    Any ideas???

  • dendeffe
    Avatar
    Community Member
    135 Posts

    Re: Cannot Reference Banner Image more than Once Link to this post

    I'm also having this problem a lot. I tend to use the Image DataObjectManager instead.

  • tigger
    Avatar
    Community Member
    3 Posts

    Re: Cannot Reference Banner Image more than Once Link to this post

    dendeffe - Thanks for the tip on an alternative method! Now, (and since I am a novice here) would you explain how I might go about implementing the Image DataObjectManager class? Or at least point me to some explanatory documentation? - thanks in advance.

  • dendeffe
    Avatar
    Community Member
    135 Posts

    Re: Cannot Reference Banner Image more than Once Link to this post

    It’s part of the Data Object Manager extension: http://www.silverstripe.org/dataobjectmanager-module/

    which has pretty good documentation.

    You can also check out UncleCheese’s (who develops it) screencast: http://www.leftandmain.com/silverstripe-screencasts/2010/08/23/a-quick-look-imagegallery-module/

  • tigger
    Avatar
    Community Member
    3 Posts

    Re: Cannot Reference Banner Image more than Once Link to this post

    Thank you! I will evaluate this alternative and let you (and everyone in the forum) know how it turns out!

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