Jump to:

10850 Posts in 2517 Topics by 1793 members

All other Modules

SilverStripe Forums » All other Modules » Image gallery module

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 1036 Views
  • Sibot
    Avatar
    Community Member
    3 Posts

    Image gallery module Link to this post

    I have uploaded and installed the image gallery module (Uncle cheeses one) / swfupload etc etc .

    My request is simple , I need to add another field underneath the "Caption" field called "Info" . Where can I do this ?

    Thanks so much in advance !

    SimonC

  • UncleCheese
    Avatar
    4085 Posts

    Re: Image gallery module Link to this post

    class MyImageGalleryPage extends ImageGalleryPage
    {
    protected $itemClass = "MyImageGalleryItem";
    }

    class MyImageGalleryItem extends ImageGalleryItem
    {
    static $db = array ('Foo' => 'Text');

    public function getCMSFields_forPopup()
    {
    $f = parent::getCMSFields_forPopup();
    $f->push(new TextField('Foo'));
    return $f;
    }
    }

  • Sibot
    Avatar
    Community Member
    3 Posts

    Re: Image gallery module Link to this post

    Thanks uncle cheese for the quick response and also the code

    But, Im fairly noob and have no idea what im doing wrong but I cant seem to get it to work ... this is what I have done .

    1. Created a new file in imagegallery/code called ImageGalleryField.php
    2. Copied the following code in the file :

    <?php

    class MyImageGalleryField extends ImageGalleryPage
    {
    protected $itemClass = "MyImageGalleryItem";
    }

    class MyImageGalleryItem extends ImageGalleryItem
    {
    static $db = array ('Foo' => 'Text');

    public function getCMSFields_forPopup()
    {
    $f = parent::getCMSFields_forPopup();
    $f->push(new TextField('Foo'));
    return $f;
    }
    }

    class MyImageGalleryField_Controller extends ImageGalleryPage_Controller {
       
    }
    ?>

    3. Ran dev/build

    4. I am now getting errors ... http://www.pastie.org/994741

    Thanks again for your help, and time

    Simon C

  • UncleCheese
    Avatar
    4085 Posts

    Re: Image gallery module Link to this post

    No, no.. Never touch anything in the image_gallery directory. That's the whole point of subclassing -- so you don't have to hack the core code. All of these new files should be in your project directory.

    In Silverstripe, your class names have to be the same as the .php file in which they are contained, so "ImageGalleryField.php" and "MyImageGalleryField" isn't going to work.

    Just as a side note, it's a little unusual that you've named your subclass of ImageGalleryPage "ImageGalleryField?" You're subclassing the entire page type.. it has nothing to do with a field. Name it something that is relevant to your customization, for instance, if you're going to have a gallery of cars, call it "AutoGallery extends ImageGalleryPage"...

  • Sibot
    Avatar
    Community Member
    3 Posts

    Re: Image gallery module Link to this post

    Hi again, thanks for that . I see what you are saying ...

    But I am still getting errors .

    I have made the file in mysite/code/PetGalleryPage.php

    <?php

    class PetGalleryPage extends ImageGalleryPage
    {
    protected $itemClass = "MyImageGalleryItem";
    }

    class MyImageGalleryItem extends ImageGalleryItem
    {
    static $db = array ('Foo' => 'Text');

    public function getCMSFields_forPopup()
    {
    $f = parent::getCMSFields_forPopup();
    $f->push(new TextField('Foo'));
    return $f;
    }
    }

    class PetGalleryPage_Controller extends ImageGalleryPage_Controller {

    }
    ?>

    then ran dev/build

    and get these :http://pastebin.com/6iKE8eGz

    I just don't get what could be wrong here....

    thanks again

  • UncleCheese
    Avatar
    4085 Posts

    Re: Image gallery module Link to this post

    Are all those in the same file? The page and its controller should be in one file, but the Item subclass needs to be in its own. Generally, in SS, it's one class per file.

    1036 Views
Page: 1
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.