October CMS resources and help articles

Simple and to the point. Optimized by the community.

Use October's AJAX-Framework Extras in the Backend

2
by OFFLINE, last modified on April 9th, 2021

To use the {% framework extras %} in your backend you have to include the CSS and JS files in your Controller.

class YourController extends Controller
{
    public $implement = [
        'Backend.Behaviors.FormController',
        'Backend.Behaviors.ListController',
    ];

    public $formConfig = 'config_form.yaml';
    public $listConfig = 'config_list.yaml';

    public function __construct()
    {
        parent::__construct();

        BackendMenu::setContext('YourVendor.YourPlugin', 'your-main-menu', 'your-sub-menu');

        // Include framework extras.
        $this->addJs('/modules/system/assets/js/framework.extras.js');
        $this->addCss('/modules/system/assets/css/framework.extras.css');
    }

If you don't need the extras on every page the Controller handles, you can of course also add them to the update or create method only.

If you need the extras on every page in the backend, you can add the JS file and CSS file by using events. Add the following code to the boot method of your Plugin.php file.

Event::listen('backend.page.beforeDisplay', function ($controller, $action, $params) {
        $controller->addJs('/modules/system/assets/js/framework.extras.js');
        $controller->addCss('/modules/system/assets/css/framework.extras.css');
});

Discussion

0 comments

We use cookies to measure the performance of this website. Do you want to accept these cookies?