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

DataObjectManager Code Examples


Reply

84 Posts   20999 Views

Avatar
idefix

13 April 2010 at 9:54pm Community Member, 11 Posts

Hi UncleCheese,

I'm looking for an example that allows to show on the frontend the details of the object.
Is there anything available?

Thanks a lot in advance.

Avatar
UncleCheese

14 April 2010 at 2:43am (Last edited: 14 April 2010 2:44am), 4085 Posts

Not sure what you mean?

Avatar
novaweb

14 April 2010 at 8:47am Community Member, 115 Posts

Hi idefix,

I believe what you're trying to do is display all (or some) of the data that you're managing with DataObjectManager on the front end of your site?
If so, in SilverStripe you do this with a "control block" - which makes things pretty easy.

First you need to get the DataObjectSet of whatever DataObject you're wishing to display on your Page type: (Page.php, TestimonialPage.php etc)

Make sure you do this in your Page_Controller class!

function Testimonials() {
$testies = DataObject::get("Testimonials");
return $testies;
}

Then on your Template (Page.ss, TestimonialPage.ss) - you can display the DataObject as follows:

<% control Testimonials %>
$Name
$Date.Nice
$Comment
$Author
<% end_control %>

Hopefully that's what you were after!

Avatar
idefix

15 April 2010 at 9:53pm Community Member, 11 Posts

Hi subvert,

thanks a lot, but how must the link look like to invoke the detail page?

In the backend it looks like this: http://DOMAIN/admin/EditForm/field/OBJECT/item/226/edit

My code in the ss-file is as follows and I'd like to click on one table row to get the whole information about one person

<% if Anmeldungen %>
   <p style="text-align: center;"><strong>Angemeldete Teilnehmer</strong></p>
   <table border="0" cellspacing="0" width="600" align="center" style="border-width: 1px; border-style: solid;">
      <thead>
         <tr style="background-color: #a3bfdb;">
            <td><strong>Nummer</strong></td>
            <td><strong>Vorname</strong></td>
            <td><strong>Nachname</strong></td>
            <td><strong>Status</strong></td>
         </tr>
      </thead>
      <tbody><tr style="background-color: #f0f0ff;">

      <% control Anmeldungen %>
         <% if Even %>
            <tr style="background-color: #f0f0ff;">
         <% else %>
            <tr>
         <% end_if %>

         <td>$Pos</td>
         <td>$vorname</td>
         <td>$nachname</td>
         <td>angemeldet</td>
         </tr>
      <% end_control %>
      </tbody>
   </table>
<% end_if %>

Avatar
innyinskip

24 July 2010 at 1:55am Community Member, 46 Posts

Hi Unclecheese, First of all great job with all this work!

Secondly, should the resource pages work 'out of the box'?

All im trying to do is create a download page from docs uploaded in the admin section.

I have put the php in the code folder and the .ss file within my template/layouts.
Everything seems to work. Can upload files. can publish the page etc. but when going to the page there is no download 'link' as such.
Also after refreshing that page there is a JS error on the admin section and it wont go any further.
Error is here: http://img530.imageshack.us/img530/1282/issue.jpg
Would be really grateful if you could give me a hand on this as my site is almost complete :)
Many Thanks
Craig

Avatar
UncleCheese

24 July 2010 at 2:26am 4085 Posts

What version of DOM and SS are you running? Have you seen the "Code Examples" sticky in this forum? That might be a more reliable source of example code.

Avatar
innyinskip

24 July 2010 at 2:30am Community Member, 46 Posts

Hi,

Im using 2.4 SS and r403 of DOM.
The code im using i got from the top of this thread in your example code zip file.

Thanks
Craig

Avatar
spankmaster79

16 November 2010 at 11:13pm Community Member, 46 Posts

Hi,

would really like to see this working. But apperently it doesn't for me. I'm using r511 and SilverStripe 2.4 (just downloaded)

I extracted the examples from the top of this post and put the php files in the /mysite/code folder and the .ss files in /themes/mytheme/templates/Layout

I can create a Testimonial site but all it gives me is a blank page in the middle and no errors show up, even though 'dev' mode is used.....

Any help???

Greetz
Spanky