Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Attach Image to Page with Uploadify

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 335 Views
  • Tama
    Avatar
    Community Member
    119 Posts

    Attach Image to Page with Uploadify Link to this post

    We want to use Uploadify so CMS users can simply upload images that are then attached to Pages. At the basic level this is the code:

    class Page extends SiteTree {

       static $has_many = array(
          "PageImages" => "PageImage"
       );

       function getCMSFields(){
          $fields = parent::getCMSFields();
          $fields->addFieldToTab("Root.Content.PageImages", new MultipleFileUploadField('PageImages','Add Images to Page'));      
          return $fields;
       }
    }

    class PageImage extends Image {
       
       static $has_one = array(
          "Page" => "Page"
       );
       
    }

    However when a file is Uploaded through the "Upload New" tab it isn't automatically attached to the page. We thought this would be the default behaviour.

    Instead CMS users have to click on the "Choose existing" tab and select/ Import the images they are after.

    I'm guessing we've missed something very very simple, any help would be appreciated.

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