some notes

Working With Contexts

This document is a work-in-progress. If you need more information please contact me and I'll be happy to expand on it.


Berylium contexts are smart templates. If you've ever worked with Smarty, the concept is similar, but with a different approach: contexts enforce more separation of logic and display. Future versions of Berylium may include an option to use Smarty templates.

Contexts are XML files with three principle areas: PHP code to eval(), a single-view template set, and a list template set. When an object is rendered in context, the PHP code is evaluated first to format the object for display and create runtime properties. Then, depending on whether the object is solo or part of a list, the appropriate template set is rendered and added into the output stack.

Naming Convention

Contexts must conform to the following naming convention:
  • Objtype is either the object type (document, image, etc) or "generic" if it applies to all objects.
  • Method is the method that invokes the context (edit, view, etc). The method is always specified in the HTTP request, unless it is "view".
  • Role is the minimum role required to invoke the context. The role hierarchy is:
    1. anonymous
    2. member
    3. writer
    4. editor
    5. admin
      (The use of custom roles is possible, in which case the requestor must be exactly that role, or admin.)
  • Format is the format from the HTTP request (.html, .jpg). Note that format names are arbitrary, and don't necessarily correspond to a particular mimetype -- .popup is an example of this. (Currently unimplemented, a "generic" format will also be available)

Context Directory Structure

XML Namespace

Objects Available for Processing

Objects Available to Template Sets

Process Conventions

Controlling Rendering: $this->showNull and $this->showNone

Setting showNull=1 will cause the rendering logic to display the Null template, even if the object exists.
Setting showNone=1 will cause the rendering logic to skip the object altogether.

ListProcess Conventions

CBML In Template Sets

By Chris Snyder on August 5, 2003 at 11:00am

jump to top