7921 Posts in 1359 Topics by 933 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » Getting proper data from Nested DOM
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 597 Views |
-
Getting proper data from Nested DOM

20 August 2010 at 4:18pm
I'm having issues getting the correct data with my Nested DOM. All works except that, so far, I've attached 3 photos to the first room, and it's returning those 3 photos for every Room. I figured that I needed a filter by ID of some sort for the GetRoomPhotos(), but nothing I tried worked.
My RoomsPage lists multiple Rooms (DOM). Each Room has it's own RoomPhoto gallery (Image DOM).
class RoomsPage_Controller extends Page_Controller {
function GetRooms() {
return DataObject::get('Room');
}
function GetRoomPhotos() {
return DataObject::get('RoomPhoto');
}
}In the Template (RoomsPage.ss)
<% control GetRooms %>
...
<% control Top.GetRoomPhotos %>...<% end_control %>
<% end_control %>Here's the full source from the 3 PHP pages if it helps... http://pastie.textmate.org/private/a8scxavuf4v8puuc5wfs5w
Thank you
-
Re: Getting proper data from Nested DOM

21 August 2010 at 1:45am
Look at your two functions. They both return the world of all Rooms or Photos, without regard to the containing object. Get rid of both of those functions.
RoomsPage.ss.
<% control Rooms %>
$RoomName
<% control RoomPhotos %>
$Attachment
<% end_control %>
<% end_control %> -
Re: Getting proper data from Nested DOM

22 August 2010 at 6:38am
Hey Uncle C,
Thanks for your help. I tried ditching the functions and changing the template but it wasn't showing any of the photos, the room info was displaying properly.
I then changed 2 things,
- Room.php: my nested ImageDataObjectManager to FileDataObjectManager
- RoomPhoto.php: Attachment => Image to Attachment => FileAnd it started working. Trying to get it to break again, I then restored my files to the earlier versions but it still works. So I'm not sure what was going on.
| 597 Views | ||
|
Page:
1
|
Go to Top |

