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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

How do i call on Images of an ImageGallery


Go to End
Reply


23 Posts   2553 Views

Avatar
UncleCheese

Forum Moderator, 4102 Posts

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?

Avatar
Elender78

Community Member, 22 Posts

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.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

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());

Avatar
Elender78

Community Member, 22 Posts

3 December 2009 at 5:52am

Edited: 03/12/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?

Avatar
UncleCheese

Forum Moderator, 4102 Posts

3 December 2009 at 6:33am

You're missing a closing parenthesis. Please be sure to check your syntax before posting code.

Avatar
Elender78

Community Member, 22 Posts

3 December 2009 at 7:08am

Edited: 03/12/2009 7:28am

all nice and smooth now. thank you very much.

m.

Avatar
Elender78

Community Member, 22 Posts

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.

Go to Top