pclib  3.0.0
Lightweight PHP framework
Common attributes of template tags

These attributes can be used in any template tag (element):

  • default "value" Default value of the element
  • noprint Element will not be rendered.
  • onprint "callback" replace default print-handler. See PClib callback functions.
  • noescape Prevent html escaping when config parameter 'pclib.security.tpl-escape' is enabled.
  • escape It escapes html using Tpl->escapeHtmlFunction

You can use following tag modificators:

  • {TAGNAME.value} It will return plain value of TAGNAME. Any actions and formatting in element handler are skipped.
datasource attributes
These attributes can be used in following elements: bind, select, check, radio, listinput
  • list
  • query
  • lookup
  • datasource

These attributes specify datasource of the element. The data are used for generating of select options, group of radio buttons or checkboxes or as lookup table for lookup field (bind).

Use attribute 'notranslate' if you do not want translate lookup values.

Datasource can be specified as

  • text-list in template ( list "y,Yes,n,No" )
  • sql-query in template ( query "select ID,LABEL from TABLE" ) (*)
  • lookup name ( lookup "categories" )
  • callback or route

Examples:

  • select AGREE list "1,Yes,2,No" //create HTML SELECT with two items: Yes, No.
  • select AGREE lookup "agree" //Read data from LOOKUPS table
  • select AGREE datasource "Lookups::getAgree" //static call of Lookups::getAgree();
  • select AGREE datasource "lookups/agree" //call LookupsController->agreeAction();

Lookup table is loaded into associative array $tpl->_FIELD->items. You can set this array even directly, if you need special treatment. Ex: $tpl->_AGREE->items = [1 => 'Yes', 2 => 'No'];

Warning
Lookup tables are loaded into memory when template is printed. It can be resource intensive if you are using big lookup tables.

(*) Note: You can use any template tag {TAG} in lookup query. Ex: query "select ID,LABEL from TABLE where CATEG='{CATEG}'"