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

Image Gallery - Latest Images on HomePage?


Reply


23 Posts   4026 Views

Avatar
UncleCheese

Forum Moderator, 4093 Posts

20 August 2009 at 1:13am

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";
}

Avatar
boombox

Community Member, 44 Posts

20 August 2009 at 2:50pm

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

Avatar
UncleCheese

Forum Moderator, 4093 Posts

21 August 2009 at 1:09am

Change
$Image.SetWidth(100)

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

Avatar
UncleCheese

Forum Moderator, 4093 Posts

21 August 2009 at 1:10am

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.

Avatar
FireMe!

Community Member, 74 Posts

21 August 2009 at 4:33am

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

Avatar
UncleCheese

Forum Moderator, 4093 Posts

21 August 2009 at 5:10am

Check for javascript errors?

Avatar
FireMe!

Community Member, 74 Posts

21 August 2009 at 5:20am

Error: uncaught exception: Unknown player: img

?whats that about

Avatar
boombox

Community Member, 44 Posts

21 August 2009 at 3:21pm

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