7912 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » ImageDataObjectManager
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
| Go to End | Next > | |
| Author | Topic: | 1183 Views |
-
ImageDataObjectManager

22 February 2011 at 6:43pm
Hi everyone
So i am trying to set up the ability to manage Banners. I need the ability for different pages to have different banners and in different orders. It would be nice so that when i add a Banner for a certain page, this banner is also automatically available for another page type. So my idea is to loop through a folder in assets, and link every image to that page.
I have created a BannerImage class and currently have it working so that when i upload an image, other pages can see this image. However if i rearrange this image on one particular page, it changes in all the other pages
Can anyone help please?
-
Re: ImageDataObjectManager

23 February 2011 at 10:52am
Sounds like you want a ManyManyFileDataObjectManager? That will allow you to upload banners from every page, and choose which banners you want, new or existing, to appear on any given page.
-
Re: ImageDataObjectManager

23 February 2011 at 12:05pm
Ok so i think i have this set up.....so when i add an image, i can see this image on all pages. But if i change the order of the images on one page, it changes the order on every other page
Can you please help me in setting this up properly
-
Re: ImageDataObjectManager

23 February 2011 at 12:38pm
Yeah, I think somewhere in this forum you'll see a write up on SortableDataObject::add_sortable_many_many_relation();.. I think it's in a sticky.
-
Re: ImageDataObjectManager

23 February 2011 at 1:31pm
I cant seem to find anything and what is a sticky
-
Re: ImageDataObjectManager

23 February 2011 at 4:30pm
Can you see where i am going wrong
BannerImage.php
-------------------------------------------------------------------------------------<?php
class BannerImage extends DataObject {
static $db = array(
'Title' => 'Text',
'URL' => 'Text'
);
static $has_one = array(
'BannerImage' => 'Image'
);
static $belongs_many_many = array(
'Pages' => 'Page'
);
public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('URL'),
new FileIFrameField('BannerImage')
);
}
}?>
Page.php
-----------------------------------------------------<?php
class Page extends SiteTree {public static $db = array(
);public static $has_one = array(
);
static $many_many = array(
"BannerImages" => "BannerImage"
);public function getCMSFields() {
$fields = parent::getCMSFields();$idom = new ManyManyFileDataObjectManager (
$this,
'BannerImages',
'BannerImage',
'BannerImage',array(
'URL' => 'URL'
),
'getCMSFields_forPopup'
);$idom->setUploadFolder("BannerImages");
$fields->addFieldToTab("Root.Content.Image", $idom);
return $fields;
}_config.php
-----------------------------------------------------And i added this to the config file
SortableDataObject::add_sortable_many_many_relation('Page', 'BannerImage');
-
Re: ImageDataObjectManager

23 February 2011 at 4:44pm
I think the second argument is the relation name..
SortableDataObject::add_sortable_many_many_relation('Page', 'BannerImages');
| 1183 Views | ||
| Go to Top | Next > |

