This site uses cookies in order for our service to work better. Learn more I understand

Plugin creation

1. Create plugins folder and basic structure of files

Create "our_plugin" folder in path ./app/plugins/

Create folder structure
  • ./app/plugins/pluginname/config/
  • ./app/plugins/pluginname/controller/
  • ./app/plugins/pluginname/model/
  • ./app/plugins/pluginname/resources/
  • ./app/plugins/pluginname/templates/
 

2. Create configuration files

In the folder ./app/plugins/your_plugin/config/ create corresponding files

config.php - file contains additional constants which the system will add to our config

css.ini - file contains tables of css files which are supposed to be added to resources of a loader, system will include them in the proper spot in a view. It's important that a key is unique, numbers signify the load order of rescources.
1.pluginname.bootstrap = "{$HOME}app/plugins/pluginname/resources/css/bootstrap.min.css"
2.pluginname.bootstrapext = "{$HOME}app/plugins/pluginname/resources/css/bootstrap-extends.css"
3.pluginname.icons = "{$HOME}app/plugins/pluginname/resources/css/icons.css"

In template call out following code to load up CSS
{foreach resourceManager::loadAdminCSS() as $cssFile}
	{$cssFile}?ver={config::get('revision')}
{/foreach}	

js.ini - like css.ini but does it to js files
1.pluginname.jquery = "{$HOME}app/plugins/pluginname/resources/js/jquery.js"
2.pluginname.jqueryui = "{$HOME}app/plugins/pluginname/resources/js/jquery-ui.js"

In template we're calling out this code to load ups js
{foreach resourceManager::loadAdminJS() as $jsFile}
	{$jsFile}?ver={config::get('revision')}"
{/foreach}


router.ini - file contains the structure of paths and defines which path should call out to what
[/pluginpath/]
name=pluginmain
controller=pluginController

[/pluginpath/#action/]
name=pluginmain-action
controller=pluginController

[/pluginpath/#action/#id/]
name=pluginmain-action-id
controller=pluginController


3. Create controllers

Create the controller file in proper folder of our plugin
  • ./app/plugins/pluginname/controller/ - for normal controllers
  • ./app/plugins/pluginname/controller/do/ - for action controllers
  • ./app/plugins/pluginname/controller/ajax/ - for controllers called out by ajax
Our file according to the router should be named: pluginController.class.php and its full path to the file should look like  ./app/plugins/pluginname/controller/pluginController.class.php


Example content of our controller
Class pluginController Extends htmlController {
  public function smartyGo()
  {
    parent::smartyGo();
    $this->smarty->template_dir = array_merge(array(
      __SITE_PATH . '/app/plugins/pluginname/templates/',
      __SITE_PATH . '/app/plugins/wp/templates/mail/'),$this->smarty->template_dir);

    $this->smarty->left_delimiter = "{";
    $this->smarty->right_delimiter = "}";

    $this->smarty->assign('TEMPLATE_HOME',HOME.'/app/plugins/pluginname/templates/');
    $this->smarty->assign('TEMPLATE_PATH',__SITE_PATH . '/app/plugins/pluginname/templates/');
  }	
  public function index()
  {
    $pagesDB = new pagesDB();
    $this->smarty->assign('pagesDB',$pagesDB); 
    $this->pageDisplay('main.tpl');
  }
}

Warning! It's very important to add an smartyGo method extension to our contorller and set in it paths to our folder with templates


4. View creation

Create a file with extension *.tpl in a folder with views, according to what you declared ./app/plugins/pluginname/templates/main.tpl

To create views we're using the SMARTY engine, you can of course make the plugins without any template engine and without extending controller after html controller and doing your own views on any system.

In our controller we can always use methods from WinduCORE.

Help Center

Do you have a technical problem?