How to run custom JavaScript in Expression engine admin
<?php
/*
I hope you all know how expression engine works. This article shows you
how to develop an accessory module for expression engine to run custom
javascript in expression engine admin.
Here are steps to go:-
Stop direct access to your module by writing
*/
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
on first line.
Directory structure and file name:-
You need to store your plugin files in directory “system/expressionengine/third_party”,
Your module folder name must match your module id
Your module file name must have “acc.” Prefix followed by your module id
One Time Setup:-
Now you need to define all variable that are necessary for a module and Your class name
must match to your module id followed by “_acc”, that tells expression engine that this
class is for accessories.
For e.g
*/
class Emerico_acc
{
var $name = 'Emerico';
var $id = 'emerico';
var $version = '1.0';
var $description = 'For Admin Smoothness';
var $sections = array();
}
/*
Get the instance of Expression Engine
Define constructor of class and get the instance of expression engine with
in it, this is almost same in all modules.
*/
function __construct()
{
$this->EE =>get_instance();
}
/*
This object allow us to access different built in methods of expression engine.
Define your javascript / code
Create set_section function to run your javascript code. Set section function allow
you to create a array of section for your module to populate content. each element
of array defines a section and key of array define heading for that section.
Now in this function you can use
*/
ee()->cp->add_to_foot('');
/*
to add your javascript to footer of expression engine.
After completing all the steps you got your module tab under add on >accessories tab
in expression engine admin.
*/