Documentation 1.x

Model View Controller (MVC)

ImpressPages CMS has equivalents for all three parts of MVC structure. However, not very strictly. Read about new MVC implementation in ImpressPages 2.X.

Model

ImpressPages suggests to use db.php and module.php files for model related tasks: communicate with database and supply information about plugin.

View

Views are template.php files. They are PHP classes with static methods that generates and returns HTML.

Controller

Controllers are actions.php files. They have strict structure:

<?php

namespace Modules\plugin_group\plugin_name  //define namespace. Include real plugin group and plugin name.

if (!defined('CMS')) exit; //check if file is not accessed directly

class Actions {

  function makeActions () {
    
    //required actions output Json or do anything else.

    //if you want to output current page content, then just return.

    //if you like to stop render the page and exit, disconnect from database and exit
    \Db::disconnect();
    exit;
  }
}
?>

Function makeActions is executed before any output, when this url is accessed:

http://www.example.com/?module_group=plugin_group&module_name=plugin_name&addAnyOtherParameters=1

Write a comment

You must be logged in to comment.