in this tutorial you will learn 

  • inserting plugin information into database and plugin information.
  • inserting or registering plugin's section if needed.
  • inserting meta link information if the plugin has meta link for front pages.
  • creating table for the plugin if plugin extends existing cart21. 

File name: /admin/controllers/plugins/plugin_key.php


Register plugin info (required)

code below shows an example of resigtering plugin info to database

function index(){

/// Register plugin info ///





     "title"=>"Plugin Title - latest product",

     "publisher"=>"Developer Title",



     "p_key"=>"plugin_key", /// same as library file name

     "content"=>"description about plugin",



    "param"=> serialize($param)




if($check_plugin->num_rows==0 ){





echo "already installed ! new files uploaded All Plugins";


/// Register plugin info ///




Plugin info attributes 

      "p_key"=>"plugin_key",  represent unique key for the plugin and  some plugin file name shoul be same name 

  • /admin/controllers/plugins/plugin_key.php
  • /admin/libraries/plugins/plugin_key.php
  • /front/libraries/plugins/plugin_key.php

     "title"=>"Plugin title ", visible to admin user and it can be modified under the plugin edit form

     "publisher"=>"plugin developer name it is a text",

     "plugin_type_id" =>2: plugin_type_id is constant already registered by default cart21 and it represents plugin category and enable admin user to filter plugins by its category related (template, modules, payment, shipping,order,language, default) 

     "pub_email"=>"", plugin developer's  email 

     "content"=>"description about plugin",

    "status"=>0, status should be 0 (zero) at first  after inastallation if you open (activate) modification file will write changes otherwise it is probable to have conflict

    "positional"=>0, when set 1 it mean this plugin assignable to page position on the plugin edit from page posions will be visible (example latest product is positional is 1 it could be assigned to any page positions)

    "manage_link"=>"admin/anycontroller", it means if this plugin has management page in the admin panel you set here the link after it will be visible on the left menu of admin panel under plugins. 

    "param"=> serialize($param) parameter that plugin's use for settings  ( example; width, height, limit etc.)  




Register section(s) (optional)

Registering section is optional when the plugin has admin controller to manage data you have to register section(s) permission_sections db table for system to load languages and permissions for admin user groups.

Example : below sample multiple section addinginside index() function,  if section already exists it would't register new one. 

//// SECTIN INFO ////






foreach($sections as $m){

if(! $this->db->get_where("permission_sections",array("name"=>"download_release"))->num_rows ){


echo "new section added";


echo "new section already exist";



  //// SECTIN INFO ////



Register meta(s) (optional)

Registering meta info for page is optional for plugin development, also it can be registered manually in admin panel under "admin/meta/add" link. However if you require to register meta(s) during plugin installation below code is an example of registering meta inside index() function.

 //// META INFO ////


"title"=>"Page Title Example",






foreach($meta as $m){

if(! $this->meta_model->meta($m)->num_rows ){



if( $m["type"]==1){




/// already exist do nothing


//// META INFO ////



Plugin related mysql table(s) (optional)

Plugin related mysql table is creation of table that plugin use for data,  usually using create table sql code query. Below an example of database qurey creating a mysql database table inside index() function.



CREATE TABLE IF NOT EXISTS `example_category` (

  `example_category_id` int(11) NOT NULL AUTO_INCREMENT,

  `title` varchar(255) CHARACTER SET utf8 DEFAULT NULL,

  `slug` varchar(255) CHARACTER SET utf8 DEFAULT NULL,

  `status` int(11) DEFAULT '1',

  `sort_order` int(11) DEFAULT '10',

  `keywords` varchar(255) DEFAULT NULL,

  `description` varchar(255) DEFAULT NULL,

  PRIMARY KEY (`example_category_id`)






Posted by: Müslüm ÇEN
Date Added: 21/02/2016
Last Update:

Not Commented Yet !
Please login in order to comment . Login