Additions to admin panel

Creation of own pages

To create an own page in admin panel follow the next steps:

  1. In "customs/adminpanel/" folder create php file with the name which will go to URL (go without extension), for example "mypage.php".
  2. Now this page will be available by the link "/adminpanel/custom/?view=mypage".
  3. To redirect to this page usually you need to add a button or a link to the page of model, for this create a file (for example "model-index-bottom.php") as described in the Model setting section (insert a code in admin panel).
  4. Include in "mypage.php" file header and footer of the admin interface page as shown on example below. The inner structure of HTML tags can be different, for example for dividing the page into columns, you may take the structure of tags from another page of admin panel.
<?
include $registry -> getSetting("IncludeAdminPath")."includes/header.php";
?>
 
<div id="columns-wrapper">
  <div id="model-form">
    <div class="column-inner">
       <h3 class="column-header">Mypage</h3>
 
       // ...
       //Page content, messages, forms, etc.
       // ...
 
       <input type="button" class="button-light" value="Button 1" />
       <input type="button" class="button-dark" value="Button 2" onclick="..." />
    </div>
  </div>
</div>
 
<?
include $registry -> getSetting("IncludeAdminPath")."includes/footer.php";
?>

Objects of models can be created through classes of models. All properties of Registry are accessible as described in System settings section and also additional properties may be set.

  • AdminPanelPath - URL path from server root to admin panel of the project, on the production server is "/adminpanel/" usually, but may be different if you have changed the path to admin panel
  • IncludeAdminPath - the path from file system root to the folder of admin panel, to include files
//Call the objects of required models
$products = new Products();
$catalogs = new Catalogs();
$producers = new Producers();

//Check of the user rights for a given model
//Parameters: model name in lower case 
//and one of the rights "create", "read", "update" or "delete" 
$system -> user -> extraCheckModelRights("products", "update");

//Messages about errors and successful operations 
echo "<div class="form-no-errors"><p>Data are successfully updated </p></div>";
echo "<div class="form-errors"><p>Error occurred ...</p></div>";