7911 Posts in 1354 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » How do i call on Images of an ImageGallery
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 | ||
| Author | Topic: | 1686 Views |
-
Re: How do i call on Images of an ImageGallery

3 December 2009 at 4:13am
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?
-
Re: How do i call on Images of an ImageGallery

3 December 2009 at 4:36am
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.
-
Re: How do i call on Images of an ImageGallery

3 December 2009 at 4:45am
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());
-
Re: How do i call on Images of an ImageGallery

3 December 2009 at 5:52am Last edited: 3 December 2009 7:09am
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?
-
Re: How do i call on Images of an ImageGallery

3 December 2009 at 6:33am
You're missing a closing parenthesis. Please be sure to check your syntax before posting code.
-
Re: How do i call on Images of an ImageGallery

3 December 2009 at 7:08am Last edited: 3 December 2009 7:28am
all nice and smooth now. thank you very much.
m.
-
Re: How do i call on Images of an ImageGallery

3 December 2009 at 7:36am
on last question: how do i distinguish between more than one gallery on a ImageGalleryPage? with control or another dropdown field?
m.
| 1686 Views | ||
| Go to Top |

