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] Output To Table


Reply

8 Posts   1182 Views

Avatar
DanStephenson

8 May 2009 at 8:15pm Community Member, 115 Posts

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.

Avatar
UncleCheese

9 May 2009 at 1:41am 4085 Posts

Is this for your frontend website? Or are you trying to change the way DOM displays in the CMS?

Avatar
DanStephenson

9 May 2009 at 1:46am Community Member, 115 Posts

Sorry Uncle Cheese, I should've specified. This is for the front end of my website.

Avatar
UncleCheese

9 May 2009 at 1:58am 4085 Posts

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.

Avatar
DanStephenson

12 May 2009 at 9:25am Community Member, 115 Posts

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?

Avatar
UncleCheese

12 May 2009 at 9:40am 4085 Posts

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."

Avatar
DanStephenson

12 May 2009 at 10:13am Community Member, 115 Posts

Great Uncle Cheese, thanks.

The sort works, except I am getting my sorting results like this

1
10
19
2

I 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?

Avatar
UncleCheese

12 May 2009 at 11:46am (Last edited: 12 May 2009 2:09pm), 4085 Posts

Make sure the field is cast as an integer.