Содержание
Control Panel’s Controller
A component needs a control panel controller to be configured in the InstantCMS Control panel.
The controller is located in the /system/controllers/{component title}/backend.php file.
The backend{ComponentTitle} class that is inhereted from the cmsBackend system class is defined inside the file. An example for the example component:
class backendExample extends cmsBackend { }
Please note that if a controller has an underscore sign (_), its class title should be as follows, an example for the my_example component:
class backendMy_example extends cmsBackend { }
Controller Actions
Actions can be defined inside the controller class. The actions are queried via URL: /admin/controllers/edit/component/action. For example, let’s define the hello action in the example component’s control panel:
class backendExample extends cmsBackend { public function actionHello(){ echo 'Hello world'; } }
You can query this action via this URL: http://site/admin/controllers/edit/example/hello
This URL is accessible to administrators only.
The actions can have incoming parameters, by analogy with frontend actions.
Index Action
The actionIndex() method will be requested if a URL contains only component’s title and an action is not mentioned.
Actions in External Files
A control panel, just as the frontend, can have actions defined in External Files. These files should be located in the /system/controllers/{component title}/backend/actions folder. Their description and work is similar to that in the frontend.
Predefined Actions
To accelerate the development, the cmsBackend class already contains the logic for the three most popular actions - Forms with Options, Configuration of Access Rights and a Universal Action for Switching Field State. Find the description of how to use these actions in the correponding sections.