Loading...

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.

We are continually working to improve Windu CMS!

By visitng the Windu website you will be kept up to date on new developments concerning the CMS.

2014-05-19 00:00:00 Battle Report

Since the release of Windu 3.0 we have we have done a lot of stuff to our CMS. The most important event in the near future will be the upgrade to version 3.1, which means a...

2014-03-25 00:00:00 Windu 3.0 - list of changes

After many months of challenges, new version of our CMS is finally out! We've decided to drop the idea Windu 2.4 and go for 3.0 straight away due to amount of changes...

2013-06-17 00:00:00 Update - Windu CMS rev 1432

New Windu CMS update is available for download at update server! Update includes several changes in our system: Pinning of tabs - allows fast navigation between open...

Buy a PRO license!

Activate loads of add-ons in your windu!

Buy a PRO license