8 February 2010 at 4:44pm
I have an odd gallery implementation, so I've decided to use the ImageDataObjectManager.
I've added it to Page.php so I could have a separate gallery for each page. It seems to be working when I look at the CMS (it's only showing the images I've uploaded for that specific page). But when viewing the site, every page is outputting all photos that were added no matter what page they were uploaded to.
9 February 2010 at 1:45am
The problem is your Lightbox getter method.
Since you're doing return DataObject::get('GalleryPhoto'); without any where clause you will get all the gallery photos back.
If all you want is to get the Gallery photos related to the current page then you don't need to write your own method.
Just write this in your template instead.
<% control PhotoGallery %>
<% end_control %>
If you're going to use a DOM to manage relationships on subclasses, you need to set its parent class. Think about it -- you're passing $this as the controller, so on the class PageSubclass, the DOM will try to set the PageSubclassID for that object, when in fact, it should be a PageID.