Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Image Gallery - Latest Images on HomePage?

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: 3919 Views
  • UncleCheese
    Avatar
    4085 Posts

    Re: Image Gallery - Latest Images on HomePage? Link to this post

    This is another area of ImageGallery that is going to get a good overhaul -- syndication of images to other pages.

    Until those changes are implemented, I would just handle that with some display logic on the template.

    <% if Pos lt 5 %>

    <% end_if %>

    Looks like you've extended the Album class. Make sure you isolate your changes in a new class so updates will not overwrite your changes. This would be a good opportunity for you to create your own GalleryItems function, too.

    class MyImageGalleryAlbum extends ImageGalleryAlbum
    {
    static $db = array ('Featured' => 'Boolean');

    function GalleryItems($limit)
    {
    return DataObject::get("ImageGalleryItem","AlbumID = $this->ID", $limit);
    }
    }

    class MyImageGalleryPage extends ImageGalleryPage
    {
    protected $albumClass = "MyImageGalleryAlbum";
    }

  • boombox
    Avatar
    Community Member
    44 Posts

    Re: Image Gallery - Latest Images on HomePage? Link to this post

    Hi - thanks for this info

    I added the template code as follows
    <% control GalleryItems %>
    <% if Pos lt 5 %>
       <li>
             <a id="ViewLink-$ID" rel="$RelAttr" class="$ClassAttr" title="$Caption" href="$ViewLink">$Image.SetWidth(100)</a>
       </li>
    <% end_if %>
    <% end_control %>

    Is this correct? I get the following error
    Parse error: syntax error, unexpected '}' in C:\Windows\Temp\silverstripe-cacheC--wamp-www-Clients-buffaloclub-www\.cacheC..wamp.www.Clients.buffaloclub.www.themes.buffaloclub.templates.Layout.HomePage.ss on line 163

    Does Pos lt 5 mean limit to 5? do I need to add a limit variable in my code?
    Thanks

  • UncleCheese
    Avatar
    4085 Posts

    Re: Image Gallery - Latest Images on HomePage? Link to this post

    Change
    $Image.SetWidth(100)

    to
    <% control Image %>$SetWidth(100)<% end_control %>

  • UncleCheese
    Avatar
    4085 Posts

    Re: Image Gallery - Latest Images on HomePage? Link to this post

    No, this isn't an authentic limit clause. "Pos" is the position of the iterator. So the loop will run through all the images, but the display of the image is controlled by a check on the iterator position. Kind of a hack.

  • FireMe!
    Avatar
    Community Member
    74 Posts

    Re: Image Gallery - Latest Images on HomePage? Link to this post

    Hi, I am having another problem displaying the latest images on the homepage, I did have it all working but when I added latest video as well to the homepage, It stop using lightbox for the images, Is this because the video popup uses shadowbox. because when you click on a video it popups and plays fine. When I go to click on an image, the screen dims like the lightbox is about to come up but does not?

    Is this a bug that you cannot have shadowbox and lightbox on the same page or something. I tried just using shadowbox but it is still the same.

    FireMe

  • UncleCheese
    Avatar
    4085 Posts

    Re: Image Gallery - Latest Images on HomePage? Link to this post

    Check for javascript errors?

  • FireMe!
    Avatar
    Community Member
    74 Posts

    Re: Image Gallery - Latest Images on HomePage? Link to this post

    Error: uncaught exception: Unknown player: img

    ?whats that about

  • boombox
    Avatar
    Community Member
    44 Posts

    Re: Image Gallery - Latest Images on HomePage? Link to this post

    Hi
    I updated template to <% control Image %>$SetWidth(100)<% end_control %>
    but still getting the same error

    Parse error: syntax error, unexpected '}' in C:\Windows\Temp\silverstripe-cacheC--wamp-www-Clients-buffaloclub-www\.cacheC..wamp.www.Clients.buffaloclub.www.themes.buffaloclub.templates.Layout.HomePage.ss on line 163

    I tried a different method based on this post
    http://www.silverstripe.org/archive/show/118042?start=0#post118116

    In my homepage.php - this is a extension of Page as this has several modules being pulled in
    (Event Calendar Module (this weeks event) | Image Gallery Module (Featured Images) | Featured Event)

    public function GalleryItems($limit = 3)
    {
       $images = DataObject::get("ImageGalleryItem","AlbumID = $this->ID", $limit);
       //Debug::show($images);
       return $images;
    }

    And in Homepage.ss file

    <% control GalleryItems %>
    <li>
    <a id="ViewLink-$ID" rel="$RelAttr" class="$ClassAttr" title="$Caption" href="$ViewLink"><% control Image %>$SetWidth(100)<% end_control %></a>
    </li>
    <% end_control %>

    But still not getting any limit control on images

    3919 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.