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   1248 Views

Avatar
DanStephenson

Community Member, 116 Posts

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.

Avatar
UncleCheese

Forum Moderator, 4096 Posts

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?

Avatar
DanStephenson

Community Member, 116 Posts

9 May 2009 at 1:46am

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

Avatar
UncleCheese

Forum Moderator, 4096 Posts

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.

Avatar
DanStephenson

Community Member, 116 Posts

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?

Avatar
UncleCheese

Forum Moderator, 4096 Posts

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

Avatar
DanStephenson

Community Member, 116 Posts

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

Forum Moderator, 4096 Posts

12 May 2009 at 11:46am

Edited: 12/05/2009 2:09pm

Make sure the field is cast as an integer.