image
TEMPLATING
image  What is QuickSkin?
image  How fast is it?
DOCUMENTATION
image  Change Log
image  Properties
image  Methods
image  Control Structures
image  Extensions
image  Speed, Tip & Tricks
LICENSE
image  License Terms
DOWNLOAD QUICKSKIN
image  Download QuickSkin
image

QuickSkin: Extensions

Search this site: 

QuickSkin Extensions

View List Of QuickSkin Extensions

An important feature of QuickSkin are Extensions. These are user-definable PHP-Functions that are called by a specific template definition with one or more dynamic or static parameters.

Usually an extension is called with a dynamic parameter and returns a string value. This value is inserted into the parsed template at the position of the extension call.

The main purpose of QuickSkin extensions is providing filters to modify dynamic content for customized display. This results in a stronger separation of content and display. Common template engines only provide design around content without any influence on how the core content elements are displayed.

Example: If you want to display any kind of numbers on your site you have to think about display formats. If you run your site in different countries, this may even differ. One million could be displayed as ‘1000000’, ‘1.000.000’, ‘1.000.000,00’, ‘1,000,000.00’, etc. Each number must be formatted (with number_format() or other) before displayed. This usually results in a lot of extra source code that can be saved: Let QuickSkin do this work for you!

Assign an unformatted number to your template variable, eg. VALUE. To display the content of VALUE as a formatted number we can use a QuickSkin extension called ‘number’. The syntax to call an extension with a variable value and print the returned value is {extension:variable}. In our example: {number:VALUE}

The only point where we have to define the output format for numbers is the number-extension. All numbers on our site have the same display format and if we have to change this format, we only have to edit one single definition to affect all applications. You don’t have to bother about any format details especially with calculated numbers. Just assign (10000 / 3) to your template and QuickSkin will print ‘3.333,33‘.

There are a lot of possibilities to reduce coding work if you let your parser do the formating work. Another good example is the handling of local date formats. To read a date from your database and display it in the appropreate local format (24.12.2002, 2002-12-24, 12/24/2002) you don’t have to modify your “select to_char(’dd.mm.yyyy’, CREATE_DATE)” queries any more. Simply read all date variables as standard (british) format or even timestamp and assign them to the template variables using the dateformat extension {dateformat:CREATE_DATE} and all formating work is done. Think of different display formats for different templates. A ‘last modified date’ could be displayed as ‘January 12th, 2003 - 11:80AM’ on an standard HTML page, while ‘12.01.2003’ is more useful for a small WAP/WML Page. All you have to do is delivering a timestamp and the templates will look for themselves.

Custom Extensions

QuickSkin already comes with various predefined extensions ready to use, but you can easily write your own extension, too:

If you want to add your own extension myextension, simply create a file named quickskin_ext__myextension.php in the directory YOUR/PHP/INCLUDE/PATH/quickskin_extensions/.
Create a Function named quickskin_ext_myextension() in this script a save it.
You can now access your own extension in a template with {quickskin_ext_myextension:PARAMETER}.
QuickSkin will call quickskin_ext__myextension( Value of PARAMETER ) and insert the returned value of your function at the current position.

Note: If you have written your own QuickSkin extensions and want to share them to other users, please include a description and send them to: andy.prevost[at]worxware.com.