Jan 18th, 2018
21:43 PM PST
 
diana       sean                         martha  
email   blog code files links photos email

email

 
 
  
shrum.net /sean/code/cats

 

  
 
 
documentation files templates support
 
filter
 
 
shrum.net :: Code :: CATS :: Template Tokens

Template Tokens

Tokens: 'what' they are, 'how' to use the predefined ones or implement your own, and 'where' in the templates you can use them. This document contains the thinking behind tokens and discusses the different types of 'wrappers' and their associated 'words'.


Introduction

CATS uses search-&-replace on tokens located in your template files to insert content into the final, composited page.  Each token is made up of two parts: the token wrapper and the token word


Token Wrappers

There are a number of different types of tokens and as such, there are different wrapper characters for each.

 

Wrapper

Description

Example
 
 $

VAR, template, and keyword tokens$foo$ 

 *

Script-specific tokens*foo* 

 #

Database table details and pagination tokens#foo# 

 !

Query string / cats.ini [defaults] tokens!foo! 
 
   

Token Words

Server / environment variables, cats.ini [keywords], and date / time ( $ )

SERVER_VARS and ENV_VARS are PHP and HTTPD server internal key/value pairs that holds information about the script engine and HTTPD server.  Below are a couple of the *many* keys that are common.  Date and time tokens are set according to the machine on which the script is run (unless the time parameter is used to modify this).  These types of tokens are wrapped in dollar signs ( $ ; $foo$ ).  It's recommended that you make use of PHP's phpinfo() on your server to get a definitive listing of the VAR key/value pairs available to you.

 
Token

Description

Currently

 
 HTTP_HOST

returns the current host namewww.shrum.net 

 REMOTE_ADDR

returns the visiting users IP address54.90.237.148 

 REMOTE_PORTreturns the visiting users port number59534 

 subdomainreturns the subdomain portion of the host name$subdomain$ 

 domainreturns the domain portion of the host name$domain$ 

 secseconds, w/ leading 020 

 minminutes, w/ leading 043 

 hour_24hours, in 24-hour format, no leading 021 

 hour_0_24hours, in 24-hour format, w/ leading 021 

 hour_12hours, in 12-hour format, no leading 09 

 hour_0_12hours, in 12-hour format, w/ leading 009 

 AM_PMcurrent am/pm time specifier; uppercasePM 

 am_pmcurrent am/pm time specifier; lowercasepm 

 timeofdaytime of day, depending on current timeevening 

 timezonecurrent time zone of machinePST 

 monthcurrent month nameJanuary 

 moncurrent month name, abbreviatedJan 

 mnum_0number of the current month, w/ leading 001 

 mnumnumber of the current month, no leading 01 

 daysinmonththe number of days in the current month31 

 weekdaycurrent day name of the weekThursday 

 wkdaycurrent day name of the week, abbreviatedThu 

 mdaythday of the month with 'st', 'nd', 'rd', or 'th', no leading 0 18th 

 mdayth_0day of the month with 'st', 'nd', 'rd', or 'th', w/ leading 018th 

 mdayday of the month, no leading 018 

 mday_0day of the month, w/ leading 018 

 yearcurrent year, expressed in 4 digit format2018 

 yrcurrent year, expressed in 2 digit format18 

 ydaycurrent day number in the year18 

 epochsecsnumber of seconds elapsed since last epoch1516340600 

 isdstdisplays if it is daylight savings time 

 last_monthlast month nameDecember 

 last_monlast month name, abbreviatedDec 

 last_mnum_0number of the last month, w/ leading 012 

 last_mnumnumber of the last month, no leading 00 

 last_month_yearlast months year, expressed in 4 digit format2017 

 last_month_yrcurrent year, expressed in 2 digit format18 

 last_yearlast year, expressed in 4 digit format2017 

 last_yrlast year, expressed in 2 digit format17 

 next_monthlast month nameFebruary 

 next_monnext month name, abbreviatedFeb 

 next_mnum_0number of the next month, w/ leading 002 

 next_mnumnumber of the next month, no leading 02 

 next_month_yearnext month year, expressed in 4 digit format2018 

 next_month_yrnext month year, expressed in 2 digit format18 

 next_yearnextyear, expressed in 4 digit format2019 

 next_yrnext year, expressed in 2 digit format19 
 
   

Script tokens ( * )

Script tokens are used to display information about the script itself or internal details of the script such as timing benchmarks.  Script tokens are wrapped with asterisks ( * ; *foo* ).

 
TokenDescriptionCurrently
       
 absoluteabsolute location of script/home/shrumnet/public_html 

 authorname of authorSean Shrum 

 createdscript creation date2005.07.21 

 distributescript distribution URLhttp://cats.shrum.net 

 emailemail address of authorsean@shrum.net 

 executiontime, in seconds, to execute script*execution* 

 modifiedscript last modified date2017.01.24 

 namename of the script filecats.php 

 versionversion number of the script4.06 

 releaserelease status of scriptrelease 

 relativerelative location of script/ 

 statusstatus of scriptopen source 
 
   

Recordset and pagination tokens ( # )

Recordset tokens are used to display information about the database table both before and after the SQL query is applied.  Pagination tokens are primarily used in your table template and allow visitors to your site to navigate the data that you're going to display.  You can restrict visitor navigation by omitting various pagination tokens from your templates. Recordset and pagination tokens are wrapped with pound signs ( # ; #foo# ).

 
TokenDescription
 
 totalthe total number of records in the table currently being queried

 matchthe number of matching records (pre-LIMIT)

 returnthe number of records returned from the complete SQL query

 rownumused to display row number; mainly used in record templates

 colnumused to display column number; mainly used in record templates

 recordnumdisplays the record number; used in record templates

 startstarting record number minus 1 ( record 1 = 0 )

 firststarting record number

 endnumber of records returned in the recordset

 lastlast record number

 sliceoffsetnumber of records to display per page

 slicecountnumber of data slices required to display all the data

 slicenavhyperlinks to each slice; returns blank if slicecount = 1

 sliceallcomplete URL for a single data slice; if slicecurrent = slicecount, returns current URL

 slicecurrentcurrent slice number

 slicefirstcomplete URL for the first data slice; if slicecurrent = slicecount, returns current URL; for use as a navigational element to first page of results

 sliceprevious complete URL for the previous data slice; if slicecurrent = 1, returns current URL; for use as a navigational element to previous page of results

 slicenextcomplete URL for the next data slice; if slicecurrent = slicecount, returns current URL; for use as a navigational element to next page of results

 slicelastcomplete URL for the last data slice; if slicecurrent = slicecount, returns current URL; for use as a navigational element to last page of results

 sortdesccomplete URL with modified (or appended) sort parameter for descending order; for use as a navigational element to descending order display of results

 sortasccomplete URL with modified (or appended) sort parameter for ascending order; for use as a navigational element to ascending order display of results
 
   

Query string and cats.ini [defaults] tokens ( ! )

Query string  and cats.ini [defaults] tokens are any key/value pair that is passed on the current query string or pre-defined in the cats.ini file under the [defaults] section.  This includes all the script parameters, reserved and unreserved.  These can be used in conjunction with tokens in templates to control text that is displayed in the final page.  Query string  and cats.ini [defaults] tokens are wrapped in exclamation marks ( ! ; !foo! ).

See Script Parameters - A to Z for a complete listing of currently supported parameters that can be used in this manner.

 
 
 
documentation files templates support
 
top

bookmark

feedback print

back

 
 
Cats v.4.06 [open source] Plug-in: "text" Template size: 80 kb Script: 0.0065 secs Plug-in: 0.0010 secs Overall: 0.0075 secs