Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » position in front-end according to sortorder

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 482 Views
  • Stefdv
    Avatar
    Community Member
    110 Posts

    position in front-end according to sortorder Link to this post

    Hi UC,

    I'm using your SortableDataObject::add_sortable_many_many_relation(). Everything is working great. My question concerns the use in a template.

    On my page i need to order the DataObjects according the Value of the SortOrder. I managed to do just that, but i like to think there's a nicer way to do so.

    right now i'm using a lot of if - loops to place my DO's in a table. Now this table has a lot of combined fields so i have to build the table step-by-step ( rowspans , it's a table for a pedigree);

    ----------------------------------------------------------
        <table >
    <% control Stamboom %>
    <tr>
    <td rowspan="4">
             <% control StamboomPugs %>
       <% if SortOrder = "0" %>
       <% if Titel %>
             <span class="champtitel">$Titel</span>
       <% else %>
       <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
       <% end_if %>
    <% end_if %>
    <% end_control %>
    </td>
       
    <td rowspan="4">
    <% control StamboomPugs %>
       <% if SortOrder = "0" %>
       $KennelNaam <br />
                      ($Color)
    <% end_if %>
    <% end_control %>
       </td>
    <td rowspan="2">          
             <% control StamboomPugs %>
       <% if SortOrder = "2" %>
       <% if Titel %>
             <span class="champtitel">$Titel</span>
       <% else %>
       <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
       <% end_if %>
    <% end_if %>
    <% end_control %>
    </td>
       <td rowspan="2">
    <% control StamboomPugs %>
       <% if SortOrder = "2" %>
       $KennelNaam <br /> ($Color)
    <% end_if %>
    <% end_control %>
       </td>

    <td >    
             <% control StamboomPugs %>
       <% if SortOrder = "6" %>
       <% if Titel %>
             <span class="champtitel">$Titel</span>
       <% else %>
       <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
       <% end_if %>
    <% end_if %>
    <% end_control %>
    </td>
    <td>
    <% control StamboomPugs %>
       <% if SortOrder = "6" %>
       $KennelNaam <br /> ($Color)
    <% end_if %>
    <% end_control %>
    --------------------------------------------------------------
    etc. you get the idea

    Is there a way to do such a thing in a nicer way?

  • UncleCheese
    Avatar
    4085 Posts

    Re: position in front-end according to sortorder Link to this post

    The control block doesn't replicate the sort order that is specified in the backend? It should.

    482 Views
Page: 1
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.