7911 Posts in 1354 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » [DataObjectManager] Output To Table
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: | 1046 Views |
-
[DataObjectManager] Output To Table

8 May 2009 at 8:15pm
This might be kind of a silly question, but I am using the Data Object Manager, and wondering if there is an easy way to filter the output into a table? Instead of an ordered list, I need my Data Titles to show up 3 to a row, with an indefinite number of rows.
Something like this:
[Title 1] [Title 2] [Title 3]
[Title 4] [Title 5] [Title 6]
[Title 7] [Title 8] [Title 9]Displaying content is easy, but I can't figure out how I can pull these titles out 3 at a time, and wrap my <tr> tags around them.
-
Re: [DataObjectManager] Output To Table

9 May 2009 at 1:41am
Is this for your frontend website? Or are you trying to change the way DOM displays in the CMS?
-
Re: [DataObjectManager] Output To Table

9 May 2009 at 1:46am
Sorry Uncle Cheese, I should've specified. This is for the front end of my website.
-
Re: [DataObjectManager] Output To Table

9 May 2009 at 1:58am
So let's assume your DOM is managing the object RelatedObject.
In RelatedObject.php:
function Third() { return !$this->iteratorPos % 3; }
on the template:
<tr>
<% control RelatedObjects %>
<td>$Title</td>
<% if Third %></tr><% end_if %>
<% if Last %><% else %><tr><% end_if %>
<% end_control %>Something like that oughta work.
-
Re: [DataObjectManager] Output To Table

12 May 2009 at 9:25am
Thanks Uncle Cheese. Worked like a charm. How could I go about sorting my data in alphabetical order as I pull it into the table?
-
Re: [DataObjectManager] Output To Table

12 May 2009 at 9:40am
Assuming you do not have drag-and-drop sorting set up in the DOM, you can add this to RelatedObject.php
static $default_sort = "Title ASC";
That is, if the title field is named "Title."
-
Re: [DataObjectManager] Output To Table

12 May 2009 at 10:13am
Great Uncle Cheese, thanks.
The sort works, except I am getting my sorting results like this
1
10
19
2I know that it's sorting like that because in Ascending order, 19 comes before 2. Is there a way to sort in "logical ascending order", to get the proper sort for numbers?
-
Re: [DataObjectManager] Output To Table

12 May 2009 at 11:46am Last edited: 12 May 2009 2:09pm
Make sure the field is cast as an integer.
| 1046 Views | ||
|
Page:
1
|
Go to Top |
