Skip to main content
page last edited on 13 January 2015

ItemsList options in admin area

Version: 5.4 and early

Introduction

This article explains main options of ItemsList widget in admin area: how to create Remove and Create buttons, define look of columns, etc.

This guide has two parts:

  • The first is about parameters of columns in the ItemsList;
  • the second is about parameters of ItemsList itself.

In order to be able to play with settings which will be described below, we recommend installing a simple ItemsList module and try to change it according to options below.

Column parameters

ItemsList columns are defined by the defineColumns() method, that returns an array of arrays, each of them representing a column. and there are two mandatory fields that must exist in each column:

  • static::COLUMN_NAME
    • value type: string;
      • defines the column name that will be displayed in the table's header.
  • static::COLUMN_ORDERBY
    • value type: integer;
      • defines the column position: the greater the value, the lower it will sit.

You can also define other parameters for a column:

  • static::COLUMN_MAIN 
    • value type: boolean;
      • defines whether this is a main column. The main column will soak up all unused space of the ItemsList.
  • static::COLUMN_SORT
    • value type: string;
      • defines a sorting option for this column. More info about implementing sorting in ItemsLists.
  • static::COLUMN_TEMPLATE
    • value type: string, path to a template;
      • defines a specific template for displaying column cell. Typical value is like modules/Developer/Module/tempalte.twig and it will pick up the skins/admin/modules/Developer/Module/tempalte.twig template.
  • static::COLUMN_HEAD_TEMPLATE
    • value type: string, path to a template;
      • similarly to above, defines a specific template for displaying head cell of a table.
  • static::COLUMN_CLASS
  • static::COLUMN_PARAMS
    • value type: array;
      • defines parameters for FormField class defined in static::COLUMN_CLASS parameter.

ItemsList parameters

ItemsList parameters are defined as methods in the ItemsList class and the mandatory ones are:

  • defineRepositoryName() method that points an ItemsList to a Model class;
  • defineColumns() method defines what columns exist in this ItemsList.

Aside from these two, you can define:

  • isSwitchable() method. If it returns true, it will add enable/disable icon to an ItemsList and this icon will work with $enabled property of the model class. If you want to change a field that is responsible for this icon, you need to work with getSwitcherField() method;

  • isRemoved() method. If it returns true, ItemsList will have remove icon:  

  • isInlineCreation() method defines whether to show Create button in the ItemsList: This method can return static::CREATE_INLINE_NONE and the button will not be displayed (default option). If it returns static::CREATE_INLINE_TOP, then the button will be displayed at the top of the table. If it returns static::CREATE_INLINE_BOTTOM, then the button will be displayed in the bottom of the table. If you want to change the label for create button, then the desired text should be returned by the getCreateButtonLabel() method.

  • getCreateURL() method is used in conjunction with isInlineCreation() method and it defines URL of the page where new record will be created. If it is the same page, where your ItemsList sits on, then a new item will be created right in the table without reloading the page. Otherwise, you will be redirected to the page returned by the getCreateURL() method. Typical implementation of this method is:

       protected function getCreateURL()
    {
    return \XLite\Core\Converter::buildUrl('your_target');
    }

    where your_target is a target of a page.