Jump to:

3372 Posts in 998 Topics by 712 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Multiple Image upload for specific page type

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

Page: 1
Go to End
Author Topic: 621 Views
  • RajBana
    Avatar
    Community Member
    1 Post

    Multiple Image upload for specific page type Link to this post

    Hi

    I am new to silverstripe. I am trying to create a customized multiple image upload field for a specific page type following Silverstripe documentation (http://doc.silverstripe.org/framework/en/trunk/reference/uploadfield). I am using latest Siverstripe framework & cms . Now while running mysite/?flush its showing "Fatal error: Access level to ProductPageFile::$many_many must be public (as in class Page).... ".

    This is my page code:

    <?php

    class ProductPageFile extends Page {
    private static $many_many = array('GalleryImages' => 'Image');

    function getCMSFields() {

    $fields = parent::getCMSFields();

    $fields->addFieldToTab(
    'Root.Upload',
    $uploadField = new UploadField(
    $name = 'GalleryImages',
    $title = 'Upload one or more images (max 10 in total)'
    )
    );
    $uploadField->setAllowedMaxFileNumber(10);

    return $fields;
    }
    }

    class ProductPageFile_Controller extends Page_Controller {
    function NewPublicUploads($FolderName) {
    $FolderName = str_replace(" ","-",$FolderName);
    return DataObject::get(
    $name = 'File',
    $filter = "ClassName = 'Image' and Filename like 'assets/".$FolderName."/%'",
    $sort = "Created DESC",
    $join = "",
    $limit = ""
    );
    }
    }

    class GalleryImageExtension extends DataExtension {
    private static $belongs_many_many = array('Galleries' => 'ProductPageFile');
    }

    Image::add_extension('GalleryImageExtension');

    can you please guide me to build a custom multiple image upload field for specific page type.

    Thank you.

  • kinglozzer
    Avatar
    Community Member
    138 Posts

    Re: Multiple Image upload for specific page type Link to this post

    Hi,

    It sounds like you're following the documentation for 3.1 when you're using 3.0.x. This is the documentation you should be using: http://doc.silverstripe.org/framework/en/reference/uploadfield.

    Change your private static $many_many to be public static $many_many, and do the same for your private static $belongs_many_many - should be public static $belongs_many_many.

    Apart from that, your code looks (at a glance) like it should work.

  • Naren
    Avatar
    Community Member
    21 Posts

    Re: Multiple Image upload for specific page type Link to this post

    Hi all,

    I want to create a page where I can show many products in a single page. There would be an image of product and some desprciption per product managed by CMS, can any one guide me how could I do that.

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