5095 Posts in 1518 Topics by 1114 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 374 Views |
-
Populating a "TreeMultiSelectField" with images from Assets Folder

27 October 2011 at 2:27am
Hi there,
In my CMS I want to have a TreeMultiSelectField type dropdown which lists all of the images in the Assets folder & subfolders (in the same way as when you go to add an image via the WYSIWYG editor).
The user should be able to select / check multiple images, which I would then use to display a slideshow of images within the site.
Can anyone point me in the right direction for this? I've tried a few things but its not working at all => I don't know if you can "call" assets in the same way as you call the site tree, e.g.:
public static $many_many = array(
"ChoosePages" => "SiteTree"
);function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.PageList', new TreeMultiSelectField('ChoosePages', 'Select pages to list', 'SiteTree'), '');
return $fields;
}Many thanks,
Linsey
-
Re: Populating a "TreeMultiSelectField" with images from Assets Folder

28 October 2011 at 12:47am Last edited: 28 October 2011 12:51am
Hi,
1) Change relationship in $many_many e.g.
public static $many_many = array(
"MyImages" => "File"
);and /dev/build
2) In getCMSField
...
$fields->addFieldToTab('Root.Content.PageList', new TreeMultiSelectField('MyImages', 'Select your images from list', 'File'), '');
return $fields;Everything works fine but after save contnet you can not see which images will be selected.
I wrote about this in this post, but no answer.
http://www.silverstripe.org/customising-the-cms/show/18385 -
Re: Populating a "TreeMultiSelectField" with images from Assets Folder

28 October 2011 at 7:56am
Thanks so much for your help - I'd already tried "File" in the CMS Fields section, but I had left it as "site tree" in the many>many relationship - what an idiot!
Just wanted to let you know though, that the boxes I check do remain checked after I save / save & publish / exit and return to the page.
Thanks again, L x
| 374 Views | ||
|
Page:
1
|
Go to Top |


