Dummy - The Framework for Dummies! - Complete View Reference

As default, $Dummy loads your templates using the View template engine. Tags inside your HTML are delimited by braces ({}), and can be simple ({like_this}) or for content ({_tag}This is the content{/tag}). 


A good practice is to create your HTML files only for the body part, or even better, only the central content (without menu, headers and footers that are common to all the site, henceforth called the frame). In your controller, after the template is loaded, you can put this inside your main frame, which contains the full HTML, usually called frame.html, using the function envelope. Here is an example

Your page Frame Result after envelope('frame.html','{CONTENT}');

<p>Hello! This is the page! Welcome {name}</p>


{_} metas ... by the way, this is a comment in the template engine {/}
<div>{_} menu {/_}</div>



{_} metas ... by the way, this is a comment in the template engine {/}
<div>{_} menu {/_}</div>

<p>Hello! This is the page! Welcome {name}</p>


Tag Formatting

Simple tags can be formatted by adding the format (and parameters) separated by a "|", like {variable|number|2} will format "variable" as a numeric value with 2 decimal numbers.

Bellow, all formatting options:

  • integer - alias to number, but rounds the number to integer
  • number (alias float) prints out as numeric values, have 3 optional parameters:This, a tag formated like {tag|number|2|-|x} where tag is 1.000,123 would output 1x000-23
    1. number of decimal numbers
    2. Decimal separator (default ",")
    3. Thousands separator (default ".")
  • each - works as a mapping in case of a loop. It basically calculates the mod of the numeric value of the tag to calculate which to serve. Options are:
    1. List of number and what to output, comma delimited
    2. Default if not in the list
    For {#|each|2=even,5=fives|others} will output, where # is a number, from 1 to 5:
    1: others
    2: even
    3: others
    4: even
    5: fives
  • truncate - truncates a string (UTF-8 compatible) by default 50, though you can set several options:
    Therefore, {variable|truncate|10|...} were variable is "This has 22 characters" would output "This ha...". Note how it cuts before 10 because it fits the "..." (tip: use the UTF-8 character "…" instead, thus consuming only one character)
    1. Number of characters
    2. Elipses to be added in the end
    3. If should strip HTML tags (anything in this field means true
    4. When stripping HTML, preserve end of line - will turn end of line as a <br/> (anything in this field means true
  • nl2br - self explanatory
  • onnull or on_null - if the variable is null or empty, shows the parameter instead, so:
    {variable|onnull|This is empty} will show the variable if it is set, but "This is empty" if it is empty or not set.
  • toplain - simple translation of &lt; to &lt;lt; and &gt; to &gt;gt;
  • html - Uses htmlspecialchars on the variable, and also translates &amp; to &amp;amp;. If the only parameter is set, removes single quote ('). Useful to fill variables inside an html input field
  • textarea - similar to toplain, translates &lr; to &lt;tl; and &amp; to &amp;amp;
  • htmlentities - runs the internal LazyDummy::htmlentities_ex, which basically translates some language characters (like ñ) and then applies htmlentities
  • url - Tries to normalize a string that should be a valid HREF. It will attempt like this:

    If variable is empty, returns a #
    If variable does not have a protocol (http:// or https://), but is a valid folder+page with .html, or .php, pre-pends a "/" to the variable
    If can't detect folders and extension, and does not start with "/", pre-pends "http://" to the variables
    If have a protocol, outputs as is.
  • deutf - returns the variable with utf8_decode
  • uc or ucwords - returns the variable in lowercase and applies ucwords
  • up - returns the variable in uppercase
  • nohtml - totally strips any HTML out. If the only parameter is set, also removes quotes
  • map - similar to each, but rather maps anything, not only numbers. IMPORTANT: Big mappings are causing PHP to loop out of control, I cannot find why, avoid using this for now. 


    {variable|map|one=1,two=⚋,three=III,four=➃|others} will output depending on variable value:
    zero = others
    one = 1
    two = ⚋
    three = III
    four = ➃
    five = others
  • select or selected - if the field is as defined (or simply set), outputs "selected='selected'", which is useful for loops on html select options. Example: {variable|select|5} will output "selected='selected'" only if variable=5
  • check or checked  - same as selected, but outputs "checked='checked'"
  • date - outputs in the internal date format defined in $stdDate or as defined in the parameter
  • datetime - same as above, but datetime (uses $stdDatetime)
  • math - performs a simple math on top of the variable. The first parameter is the operator, which can be +, -, *, / or %. Example for variable=10:

    {variable|math|+10} = 20
    {variable|math|-3} = 7
    {variable|math|%2} = 0


... soon