Документация InstantCMS

для администраторов и разработчиков

Инструменты пользователя

Инструменты сайта


en:dev:controllers:backend:flag

A Universal Action for Switching a Field State

When generating Tables in the control panel, if a field has the flag option, in the flag_toggle option, you can enter a link to the universal action responsible for switching the field state. Taking the «image upload» controller as an example, a link to this action has the following view:

/admin/controllers/edit/images/toggle_item/1/images_presets/is_square

and is generated in the following way:

'is_square' => array(
    'title' => LANG_IMAGES_PRESET_SQUARE,
    'flag' => true,
    'flag_toggle' => href_to($controller->root_url, 'toggle_item', array('{id}', 'images_presets', 'is_square')),
    'width' => 80
),

Let’s draw an analogy.

Part of URLMatch in the code
/admin/controllers/edit/images/
$controller->root_url
toggle_itemtoggle_item is the universal action’s title
/1/images_presets/is_square
array('{id}', 'images_presets', 'is_square')

these are the universal toggle_item action’s parameters

This is what is passed to the action parameters

  • entry id (in the {id} example);
  • a table title without a prefix (in the images_presets example), please note that you should write the {users} prefix for user tables;
  • a title of the field whose state needs to be changed from 0 to 1 or vice versa (the field is called is_square in the example).
en/dev/controllers/backend/flag.txt · Последнее изменение: 03.05.2017 15:11 — murlysja

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki