Add Custom Field to Admin Area Members List

Discussion in 'Subrion Open Source CMS Core' started by AJPhoenix, May 4, 2016.

  1. AJPhoenix

    AJPhoenix New Member

    The page I am working on is located at /admin/members/ and is the member listing inside of the admin area.

    I have looked through the following files:
    members.js located in ../js/admin/
    ia.admin.grid.php located in ../includes/classes/

    I need to add a field to this listing that is searchable, sortable and pulls information from another table similar to the way the Usergroup field is shown.

    Am I even close to looking in the right places?
    Is it even possible to add a custom field to this members list that is searchable and sortable?

    I am skilled with php and smarty and about average with JS. Any help that you could offer would be greatly appreciated.

    Regards,

    Bob
  2. Janur_J.

    Janur_J. Staff Member

    Hi Bob!

    Regarding your task, I may say that you, first, should look into the following file: admin/members.php

    Basically, you need to take 4 steps:
    - overload the method '_gridQuery' from the parent class, rewrite this method to be calling your custom SQL query. You also have to set an alias to the table 'members' and then specify it in the class variable (#1).
    - as you want it to be sortable, do modify the $_gridSorting variable (#2)
    - in order to make it searchable, you have to manually add these controls to the grid's panel in Javascript (members.js you already mentioned). The easiest way to do it is just copy one of already existing controls (say, "Username, Fullname or Email")
    - to make the new field visible in the grid, you need to describe this field in the 'columns' array (members.js file again, at the top of this file)

    #1
    Code (Text):

    protected $_gridQueryMainTableAlias = 'myaliasforthememberstable';
     
    #2
    Code (Text):

    protected $_gridSorting = array('location' => array('mycolumnname', 'mycustomtablealias'));
     
    This line specifies that when sorting will be requested by 'location' field, then actually it will be performed by the 'mycolumnname' field of the table aliased as 'mycustomtablealias'.

    Hope this helps!
  3. AJPhoenix

    AJPhoenix New Member

    Janur,

    Thank you very much for the input on this issue. I am going to take your example and try this on my sandbox site today. I will let you know how it all turns out.

    Thank you, once again, for your time.

    Regards,

    Bob
  4. Janur_J.

    Janur_J. Staff Member

    Not at all, Bob! Glad to help!

Share This Page