Is there anyway to display a row number column in the DataObjectManager? Thanks!
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
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 %> <% 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
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?
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
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.
Anything is {$Pos}sible in Silverstripe.
--------------------
SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com