How to use a controller function anywhere in you project/site


Open main.php file. Default file path is protected > config > main.php

Add One line in import array that is  ’application.controllers.*’,

After Add that code like

  1. // autoloading model and component classes
  2.     ‘import’=>array(
  3.         ‘application.models.*’,
  4.         ‘application.components.*’,
  6.         ‘application.controllers.*’,
  8.         ‘application.extensions.niceditor.*’,
  9.         ‘application.extensions.multiple-file-upload.*’,
  10.         ‘application.extensions.prettyPhoto.*’,
  11.     ),

See line number 6. Now Save this file.

Now it’s ready to use.


Suppose you want to use a function name is “PartyBill” and controller name is “CommonController”. It is very easy to use.

The Code is :

  1. $PartyBill = CommonController::PartyBill();
  3. echo $PartyBill;

Enjoy !  !!


Rajib Kumar Rakhmit

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>