1. Home
  2. Docs
  3. Simpods MVC
  4. Tutorials
  5. Controllers
  6. How To Create An Admin Controller

How To Create An Admin Controller


Admin controllers are located in the /mvc/admin/control/ directory and must extend the Ctrl_MVC_Admin_Controller class. The class name must be Ctrl and the file name is based on the post type being edited or the admin page URL prefixed with ctrl_mvc_admin_ and an extension of .class.php, or simply something.php, post lists and editors use the same controller. The rule is that if it is a post type, it will be post_type.php; if not and the variable “page” exists in the url, it will be $_GET[‘page’].php; else, it will just use the request script name, e.g. script.php. The Show Admin Controller Path setting on the Custom Controllers settings page can be used to show the correct filename.

Naming Examples

Type/Page Controller Filename
Standard posts post.php or ctrl_mvc_admin_post.class.php
Custom post type (slug: sample-item ) sample-item.php or ctrl_mvc_admin_sample-item.class.php
Users user.php or ctrl_mvc_admin_user.class.php
General settings options-general.php or ctrl_mvc_admin_options-general.class.php
Plugin/Theme admin page (e.g. The simpods settings page) simpods-settings.php or ctrl_mvc_admin_simpods-settings.class.php

Example File

A minimal template is located in the /mvc/admin/control/ctrl_mvc_admin_target-name.class.php file.