CoolBrew User Guide Version 1.3
Based on CodeIgniter Version 1.5.4


Tags

The get() Function

Tags are standard PHP calls to the get() function defined in the coolbrew.inc.php file that you include at the top of each of your website pages. CoolBrew's get() function acts as a gateway through which your website pages talk to the CoolBrew modules. A tag looks like this:

<?php get("core.view.load", 'view-file', $data); ?>

The first parameter is a combination of the module name, the controller name and the function name, so in this instance it's saying "I want to call the "load" function in the "view" controller of the "core" module. After that, any listed items (e.g. 'view-file' and $data) are the parameters to be sent to the specified function.

Note: Tag parameters are not passed directly to the function specified in the tag since CodeIgniter is designed to send URI variables to controller functions. To access the the tag's parameters, use the Tag Class.

The three bits of information that the get() function needs to route your request are:

  1. the module name
  2. the controller or class name
  3. the method or function name

Shortened Tags

You can shorten the tag a bit if you have a controller that is the same name as the module. Let's say, for instance, that you have a 'products' module with a controller also called 'products'. To access the "detail" function, you could write the tag like this:

<?php get("products.detail"); ?>

Which is equivalent to this tag:

<?php get("products.products.detail"); ?>

Application Tags

If only one component is specified, CoolBrew assumes that you want to run an application, similar to how CodeIgniter works by default. As such, CoolBrew expects you to supply the controller and method as part of the URL. See the Emulating CodeIgniter section in this guide for more information.

<?php get("products"); ?>

Mixing Application and Regular Tags

If you want to mix application and regular tags on the same page -- to load header and footer templates, for example -- you need to tell CoolBrew so it can interpret the URI properly. Just include the following line below where you include the coolbrew.inc.php file:

$COOLBREW['uri_is_complete'] = TRUE;

This will tell CoolBrew to remove the first two segments of the URI before it routes the regular tags.