Banshee
the secure PHP framework

Adding a page

Banshee has two kind of pages. A module and a virtual page. A module is a page which has a model, a view and a controller file on disk and can be used to create dynamic pages. A virtual page is stored in the database and displayed via the page module, of which the Banshee framework takes care. A virtual page is always static.

Adding a module

To add a module to your website, you can use the 'module' script. It will copy files from the 'templates' directory to the 'controllers', 'models' and 'views' directories. It will add <module name> to 'settings/public_pages.conf' if it's a public page or to 'settings/private_pages.conf' if it's a private page. The new page is accessible via http://hostname.tld/<module name>.

Creating output

Banshee uses XSLT as view templates. Within the controller and model class, the $this->view object can be used to create the XML file, which will be used with the XSLT file to create the output. How to use the view object can be read in the view library documentation. The XSLT view file should import 'banshee/main.xslt' and should have a template which matches the XML tag named 'content'. The 'content' XML tag is created by the Banshee framework and does therefor not need to be created by the controller.

Example view file:

<?xml version="1.0" ?>
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="banshee/main.xslt" />

<xsl:template match="content">
<h1>Page title</h1>
<xsl:value-of select="data" />
</xsl:template>

</xsl:stylesheet>

OO programming

Banshee requires OO programming. The controller and model must both be classes and must extend the 'controller' / 'model' class. The controller class must be named '<module name>_controller', the model class must be named '<module name>_model'. The controller class must have at least a function called 'execute'.

An OO controller file looks like this:

<?php
  
class page_controller extends controller {
    public function 
execute() {
      if ((
$data $this->model->get_data(123)) === false) {
        
$this->view->add_tag("result""Data not found.");
      } else {
        
$this->view->add_tag("data""Data: ".$data["field"]);
      }
    }
  }
?>

An OO model file looks like this:

<?php
  
class page_model extends model {
    public function 
get_data($id) {
      return 
$this->db->entry("table"$id);
    }
  }
?>

Adding a virtual page

To add a virtual page, login as a user which has access to the Page Administation (/admin/page) CMS page. Go to that page and click on the 'New page' button.