Jump to:

7935 Posts in 1536 Topics by 943 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » DataObjectManager Code Examples

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2 3 4 5 6 7 8 9 10 11
Go to End
Author Topic: 20473 Views
  • idefix
    Avatar
    Community Member
    11 Posts

    Re: DataObjectManager Code Examples Link to this post

    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.

  • UncleCheese
    Avatar
    4085 Posts

    Re: DataObjectManager Code Examples Link to this post

    Not sure what you mean?

  • novaweb
    Avatar
    Community Member
    111 Posts

    Re: DataObjectManager Code Examples Link to this post

    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!

  • idefix
    Avatar
    Community Member
    11 Posts

    Re: DataObjectManager Code Examples Link to this post

    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 %>

  • innyinskip
    Avatar
    Community Member
    46 Posts

    Re: DataObjectManager Code Examples Link to this post

    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

  • UncleCheese
    Avatar
    4085 Posts

    Re: DataObjectManager Code Examples Link to this post

    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.

  • innyinskip
    Avatar
    Community Member
    46 Posts

    Re: DataObjectManager Code Examples Link to this post

    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

  • spankmaster79
    Avatar
    Community Member
    46 Posts

    Re: DataObjectManager Code Examples Link to this post

    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

    20473 Views
Page: 1 2 3 4 5 6 7 8 9 10 11
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.