Codeigniter & Joomla Integration – Part 2

Last time we covered how to get a website running on Joomla & Codeigniter.

The next question is, how to access Joomla’s API within any additional controllers you want to create within the Codeigniter framework.

The easiest way is to extend the defualt CI_Controller class and add some core functionality. Create a file called MY_Controller.php and place it in /application/core/ folder.

Let me explain, what we are doing in the above code.

First, we define a few variables in the CI_Controller class to store the Joomla application object, user object, and the authorised user groups as an array.

Next, in the construct, we are initializing the Joomla’s Site application, get the logged in user and there authorised groups if the user is logged in.

Any new controller that you write after this should extend this Class.

Example:

 

Hope this helps.