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

Row number in DataObjectManager


Reply

6 Posts   985 Views

Avatar
JL

23 October 2010 at 3:04am Community Member, 10 Posts

Is there anyway to display a row number column in the DataObjectManager? Thanks!

Avatar
UncleCheese

23 October 2010 at 3:10am 4085 Posts

You can use $Pos for that.

In your theme or project /templates/ directory, create DataObjectManager.ss

Copy the contents over from /dataobject_manager/templates/DataObjectManager.ss

Make the following change:

         <% control Items %>
            <li class="data" id="record-$Parent.id-$ID"> <!-- added this -->$Pos <!-- /end -->
                  <div class="fields-wrap">
                  <% control Fields %>
                  <div class="col" {$ColumnWidthCSS}><div class="pad"><% if Value %>$Value<% else %>&nbsp;<% end_if %></div></div>
                  <% end_control %>
                  </div>
                  <div class="actions col">
                        <% include Actions %>
                  </div>
            </li>
         <% end_control %>

--------------------
SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

Avatar
JL

23 October 2010 at 3:25am Community Member, 10 Posts

Thanks for the quick reply, UncleCheese. I put the template in /mysite/templates/DataObjectManager.ss and it works. However, all the DOM in my CMS is showing the $Pos now. I am still quite new to SS, is it possible to use different template for different instances of DOM?

Avatar
UncleCheese

23 October 2010 at 3:37am 4085 Posts

Hmm.. no, not much you can do there, unless you subclass DataObjectManager.

MyDataObjectManager.php

class MyDataObjectManager extends DataObjectManager {
protected $template = "MyDataObjectManager";
}

Then you can rename the template "MyDataObjectManager.ss"

That will probably work!

--------------------
SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

Avatar
JL

23 October 2010 at 4:01am Community Member, 10 Posts

Subclassing sounds like a reasonable solution. I guess the other way is to add a css class to show/hide the $Pos value as necessary. Thanks for pointing out the $Pos possibility.

Avatar
UncleCheese

23 October 2010 at 4:42am 4085 Posts

Anything is {$Pos}sible in Silverstripe.

--------------------
SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com