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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Data Model Questions /

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

Multiple Image upload for specific page type


Go to End


3 Posts   3194 Views

Avatar
RajBana

Community Member, 1 Post

3 September 2013 at 11:26pm

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.

Avatar
kinglozzer

Community Member, 187 Posts

4 September 2013 at 2:56am

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.

Avatar
Naren

Community Member, 21 Posts

22 October 2013 at 9:46pm

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.