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, simon_w

How do i call on Images of an ImageGallery


Reply

23 Posts   2141 Views

Avatar
UncleCheese

3 December 2009 at 4:13am 4085 Posts

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

3 December 2009 at 4:36am Community Member, 22 Posts

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

3 December 2009 at 4:45am 4085 Posts

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

3 December 2009 at 5:52am (Last edited: 3 December 2009 7:09am), Community Member, 22 Posts

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

3 December 2009 at 6:33am 4085 Posts

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

Avatar
Elender78

3 December 2009 at 7:08am (Last edited: 3 December 2009 7:28am), Community Member, 22 Posts

all nice and smooth now. thank you very much.

m.

Avatar
Elender78

3 December 2009 at 7:36am Community Member, 22 Posts

on last question: how do i distinguish between more than one gallery on a ImageGalleryPage? with control or another dropdown field?

m.