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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Row number in DataObjectManager


Go to End


6 Posts   1651 Views

Avatar
JL

Community Member, 10 Posts

23 October 2010 at 3:04am

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

Avatar
UncleCheese

Forum Moderator, 4102 Posts

23 October 2010 at 3:10am

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

Community Member, 10 Posts

23 October 2010 at 3:25am

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

Forum Moderator, 4102 Posts

23 October 2010 at 3:37am

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

Community Member, 10 Posts

23 October 2010 at 4:01am

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

Forum Moderator, 4102 Posts

23 October 2010 at 4:42am

Anything is {$Pos}sible in Silverstripe.

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