Loading...

Controller

A controller is called out from router level and that's where we define which controler to call out depending on the path


Path and names of controllers

Controller has to have a name representing structure of an autoloader, that is classes with name "adminMainController", name of the file has to look like this: "adminMainController.class.php". Controllers are in the path or in /app/controller/ or inside of a given plugin that is /app/plugins/OUR_PLUGIN/controller/ Subpaths are also allowed for the controller folder and they are accordingly /do or /ajax. Only from those paths system will download controllers available in our system.


Controller file structure

A controller is coded in object oriented PHP,  that's why it inherits after specified classes, it of course doesn't have to inherit, however we're using a certain standard arising from WinduCORE
Class simpleController Extends htmlController {
	public function index()
	{
		$pagesDB = new pagesDB();
		$this->smarty->assign('pagesDB',$pagesDB);
		$this->pageDisplay('main.tpl');
	}
}
As we can see our simpleController is extended by htmlController, which adds support of smarty and allows displaying of .tpl files. In our simple controller we've created a grip to $pagesDB table and returned it to the template main.tpl in which we can keep on using our table object.
 

Extending controller and setting up paths

It is important to define the folder from which system has to download templates. If we're creating our plugin, this folder has to contain templates in plugin structure. In order to define your own paths you have to extend our controller with a transitional controller. You can do it in the same file but it won't good for easy use if the amount of files grows.

To do so, we create a new controller "simpleMainController" and we extend our base one.
Class simpleController Extends simpleMainController {
	public function index()
	{
		$pagesDB = new pagesDB();
		$this->smarty->assign('pagesDB',$pagesDB);
		$this->pageDisplay('main.tpl');
	}
}


The controller "Main" after which we will extend all the controllers of our plugin
Class simpleMainController Extends htmlController {
	public function __construct(request $request)
	{
		parent::__construct($request);	
		cron::run();
		lang::set('front');
	}
	public function smartyGo()
	{
		parent::smartyGo();
		$this->smarty->template_dir = array_merge(array(__SITE_PATH . '/app/plugins/wp/templates/'),$this->smarty->template_dir);

		$this->smarty->left_delimiter = "{";
		$this->smarty->right_delimiter = "}";
		
		$this->smarty->setCaching(config::get('cache'));
		$this->smarty->setCacheLifetime(config::get('cacheLife'));

		$this->smarty->assign('TEMPLATE_HOME',HOME.'/app/plugins/wp/templates/'.$template);
		$this->smarty->assign('TEMPLATE_PATH',__SITE_PATH . '/app/plugins/wp/templates/');
		
	}	
	public function index(){}
}

When creating a new controller we suggest using an already created one as an example.

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 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 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 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