Jump to:

7940 Posts in 1543 Topics by 946 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, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2 3
Go to End
Author Topic: 2105 Views
  • UncleCheese
    Avatar
    4085 Posts

    Re: How do i call on Images of an ImageGallery Link to this post

    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?

  • Elender78
    Avatar
    Community Member
    22 Posts

    Re: How do i call on Images of an ImageGallery Link to this post

    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.

  • UncleCheese
    Avatar
    4085 Posts

    Re: How do i call on Images of an ImageGallery Link to this post

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

  • Elender78
    Avatar
    Community Member
    22 Posts

    Re: How do i call on Images of an ImageGallery Link to this post

    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?

  • UncleCheese
    Avatar
    4085 Posts

    Re: How do i call on Images of an ImageGallery Link to this post

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

  • Elender78
    Avatar
    Community Member
    22 Posts

    Re: How do i call on Images of an ImageGallery Link to this post

    all nice and smooth now. thank you very much.

    m.

  • Elender78
    Avatar
    Community Member
    22 Posts

    Re: How do i call on Images of an ImageGallery Link to this post

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

    m.

    2105 Views
Page: 1 2 3
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.