So in your ArticlePage class, you want
$has_one = array (
'Gallery' => 'GalleryPage'
);
Then on the template, you can do <% control Gallery %>
Are you using the ImageGallery module or the Gallery module?
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Sean, Ed, biapar, Willr, Ingo, swaiba
So in your ArticlePage class, you want
$has_one = array (
'Gallery' => 'GalleryPage'
);
Then on the template, you can do <% control Gallery %>
Are you using the ImageGallery module or the Gallery module?
I'm using the ImageGalleryModule.
I have just to copy
$has_one = array (
'Gallery' => 'GalleryPage'
);
in my ArticlePages? Page or Page_controller? There's nothing with static or something like this to be added?
M.
No, I'm just giving you the basic idea. Of course you have to use the correct syntax.
static $has_one = array ('Gallery' => 'ImageGalleryPage');
Then you just need to set up a dropdown menu on your ArticlePage to choose which gallery you're associating.
new DropdownField("GalleryID","Gallery", DataObject::get("ImageGalleryPage")->toDropdownMap());
Where do i put the code exactly? After Inserting this i've got this error:
Parse error: syntax error, unexpected ';' in {}
Here is my code:
<?php
class Page extends Page {
static $db = array (
"Date" => "Date",
"Author" =>"Text",
"Notes" => "Text"
);
static $has_one = array (
"Gallery" => "ImageGalleryPage",
"Rating" => "Image"
);
function getCMSFields () {
$fields = parent::getCMSFields ();
$fields -> addFieldToTab ("Root.Content.Main", new CalendarDateField ("Date"), "Content");
$fields -> addFieldToTab ("Root.Content.Main", new TextField ("Author"), "Content");
$fields -> addFieldToTab ("Root.Content.Main", new TextField ("Notes"), "Content");
$fields -> addFieldToTab ("Root.Content.Images", new ImageField ("Rating"));
$fields -> addFieldToTab ("Root.Content.Galerie", new DropdownField("GalleryID","Gallery", DataObject::get("ImageGalleryPage")->toDropdownMap());
return $fields;
}
}
class ArticlePage_Controller extends Page_Controller {
}
?>
Where's my error?
You're missing a closing parenthesis. Please be sure to check your syntax before posting code.
all nice and smooth now. thank you very much.
m.
on last question: how do i distinguish between more than one gallery on a ImageGalleryPage? with control or another dropdown field?
m.