Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Row number in DataObjectManager

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 914 Views
  • JL
    Avatar
    Community Member
    10 Posts

    Row number in DataObjectManager Link to this post

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

  • UncleCheese
    Avatar
    4085 Posts

    Re: Row number in DataObjectManager Link to this post

    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

  • JL
    Avatar
    Community Member
    10 Posts

    Re: Row number in DataObjectManager Link to this post

    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?

  • UncleCheese
    Avatar
    4085 Posts

    Re: Row number in DataObjectManager Link to this post

    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

  • JL
    Avatar
    Community Member
    10 Posts

    Re: Row number in DataObjectManager Link to this post

    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.

  • UncleCheese
    Avatar
    4085 Posts

    Re: Row number in DataObjectManager Link to this post

    Anything is {$Pos}sible in Silverstripe.

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

    914 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.