PHP Classes

File: examples/productcount.php

Recommend this page to a friend!
  Classes of philippe thomassigny   Box Model   examples/productcount.php   Download  
File: examples/productcount.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Box Model
Create Web applications based on boxes
Author: By
Last change:
Date: 11 years ago
Size: 2,395 bytes


Class file image Download
// have to put this into a php block or the <?xml will be put as a PHP syntax error on extended code escape
echo '<?xml version="1.0" encoding="UTF-8"?>';
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="" xml:lang="en" lang="en">
  <!-- Generic browser family -->
  <title>Box Model Demos, a WebAbility&reg; Network Project</title>
  <meta http-equiv="PRAGMA" content="NO-CACHE" />
  <meta http-equiv="Expires" content="-1" />

  <meta name="Keywords" content="Box Model, Pattern, WebAbility" />
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <meta name="Charset" content="UTF-8" />
  <meta name="Language" content="en" />
  <link rel="stylesheet" href="/skins/css/boxmodel.css" type="text/css" />


<div class="container">

<a href="../index.html" class="back">&#xAB; Back to the index</a><br />
<br />

<h1>Product Count box Example</h1>

This is a very simple box:<br />
The box gets no input, and only one param which is the category.<br />
The output gives us the quantity of product in our category.<br />
The box simulates a database with 2 product categories:<br />
- 'main', with 5 products,<br />
- 'other', with 3 products.<br />
<br />

-----<br />
| |<br />
-----<br />

<hr />

We simulate the parameter CATEGORY comes from the URL with value 'main'.<br />
Result of the box:


// We assure any Box library we call will be automatically loaded
include_once '../include/__autoload.lib';

setlocale(LC_ALL, 'es_MX.UTF8');

define('WADEBUG', false);

$boxdef = array(
'boxes' => array(
'productcount' => array(
'name' => 'productcountBox',
'params' => array(
'CATEGORY' => array('source' => 'local', 'data' => 'main')
'inputs' => null,
'outputs' => array(
'quantity' => Box::INTEGER
'links' => null,
'output' => array('box' => 'productcount', 'output' => 'quantity')

$be = new boxEngine($boxdef, $category);
$result = $be->getOutput();


<br />
<br />
<br />
<br />

<a href="../index.html" class="back">&#xAB; Back to the index</a><br />