General Principles of Plugins

The purpose of applying plug-ins in MV is the necessity of using additional objects and methods that don't need the full functionality of models and Admin Panel interface.

  1. The class of plug-in should be inherited from the class "Plugin" with the name of "name.plugin.php" format.
  2. The file of a class should be located in "/plugins/" folder in the project root.
  3. The table of a plug-in should match the name of a plug-in.
  4. To activate the plug-in its name should be specified in "config/plugins.php" file.
  5. The object of a plug-in will be accessible in "$mv -> plugin_name" object.

Built-in properties and objects

  • table - the current table of a plug-in, matches the name of a plug-in in the lower case (for the plug-in to have a table is not mandatory)
  • registry - an object of access to settings from configuration files, read more in System settings
  • db - object - the database manager performing Direct queries to a database

Available methods

  • All methods of Query Constructor section
  • resizeImage($image, $width, $height) - resize the image, returns "img" tag
  • cropImage($image, $width, $height) - resize and crop the image, returns "img" tag (read more Files and images section)
  • extractImages($value [, $no-comments]) - extraction of images from a "multi_images" field
  • getFirstImage($value) - extraction of the first image from an array of the image ("multi_images" datatype)


//File location "plugins/cart.plugin.php"
//Plugin name is added into "config/plugins.php" file

class Cart extends Plugin
    //Array of cart product as "product_id" => "product_quantity"
    private $items = array();

    private $products_model;

    public function __construct()
        //The constructor can be extended
        parent :: __construct();

        //Object of products model
        $this -> products_model = new Products();
    public function addItemToCart($id, $quantity)
        $this -> items[$id] = $quantity;


//Example of use 
$mv -> cart -> addItemToCart(56, 2);