PAX offers a way to have PHP code in either your content file or template that differs from the use of the
{SCRIPT} method. With PAX turned on in the admin panel, templates and content files alike will
be preprocessed by the PAX module before being parsed by phpCMS. PAX strips PHP code from these files,
processes it and stores its results for later inclusion into the page after it has been parsed by phpCMS.
This ensures smooth operation of phpCMS and allows for further development of the PAX module without the need
for major modifications to phpCMS' core routines.
PAX works similar to the {SCRIPT} inclusion method that comes with phpCMS. {SCRIPT} allows you to include scripts into content files but not templates. PHP scripts included via {SCRIPT} are dynamically inserted into a page at runtime. While the static part of a page may be cached on the server (if caching is turned on in the admin panel), scripts are inserted into the page each time the page is requested. PAX works similar to {SCRIPT} inclusion as far as caching is concerned, but may be used to insert scripts into templates as well.
PAX may be used to include PHP into templates.
PAX also offers a variety of TAGS (PAXTAGS) that perform special tasks.
It is important to note that debugging is not available when including scripts via PAX!
Inclusion of PHP in templates is achieved quite easily and at your own risk:
Example:
<!-- PAXPHP name_of_code_block
echo 'Hello World!';
PAXPHP name_of_code_block -->
if "php in templates" is turned on in your parser gui you should see: "Hello World!"
Hello World!
As you will see from the examples below, it is easy to include PHP code via PAX.
PAXTAGS add some interesting features to phpCMS.
With PAXINC you may include additional templates or external files (not! scripts) into your template or content files.
Note that within those templates/files included via PAXINC links are NOT being checked.
TAG:
PAXINC
SYNTAX:
<!-- PAXINC /path/from_root/to/template/or/file.html -->
or
<!-- PAXINC http://www.domain.xyz/data.html -->
Example:
<!-- PAXINC http://phpcms.de/phpcms/doku/paxtest_en.html -->
with PAXTAGS turned on will result in:
Of course, you may also use additional PAXTAGS within those templates/files you include via PAXINC.
PAXHIGHLIGHT prints out a syntax highlighted version of the code you included using the colors defined in the built-in syntax highlighter for PHP.
TAG:
PAXHIGHLIGHT
SYNTAX:
<!-- PAXHIGHLIGHT /path/from_root/to/template/or/file.php -->
or
<!-- PAXHIGHLIGHT http://www.domain.net/data.php -->
Example:
with PAXTAGS turned on you should see the highlighted php source code of the file "/demo/user.php".
PHP:
PAXMENU gives you the ability to call on any menu class or field.
PAXMENU is only fully supported in stealth-mode !
TAG:
PAXMENU
SYNTAX:
<!-- PAXMENU FIELDNAME,CLASS -->
simple example:
Suppose you want to create a link to a specific item of your menus within a template or file. This is how you would do it:
<a href="<!-- PAXMENU LINK,00.08.10.12 -->"><!-- PAXMENU MNAME,00.08.10.12 --></a>
This would create a link to the menu item with class 00.08.10.12. The link text would be what you have defined for MNAME for that menu.
Actual output with PAXTAGS turned on is a link back to this document: PAX
Example for a link with "title" and "target" attributes, and an on mouseover status message:
<A HREF="<!-- PAXMENU LINK,00.08.10.12 -->" TARGET="<!-- PAXMENU TARGET,00.08.10.12 -->" onmouseover="window.status='<!-- PAXMENU TEXT,00.08.10.12 -->';return true;" title="<!-- PAXMENU TEXT,00.08.10.12 -->"><!-- PAXMENU MNAME,00.08.10.12 --></a>
Actual output with PAXTAGS turned on: PAX
In the above example the menu fields are as follows:
LINK and CLASS - these fields and their exact spelling are required by phpCMS, and may not be changed!
TARGET: the "target=" frame/window for LINK
TEXT: message to be displayed in the status bar on mouseover.
MNAME: the actual text that is turned into a link
Summing up you may call on any menu field, that has been defined in your .mnu file (the menu definition file).
The menu must have a unique name! If any of your menu names (e.g. SUB1) is used more than once, display errors are inevitable!
Links are generally created relative to "$home".
Note that currently PAXCOMBO only works as intended in non-stealth-mode !
TAG:
PAXCOMBO
SYNTAX:
<!-- PAXCOMBO MENUNAME,FIELDNAME,VALUES,SELECTED,SIZE,MULTI,ONCHANGE,FIRSTENTRY -->
MENUNAME | Name of the menu - as defined in your .mnu file - that is used to create the drop down menu. MENU:MAIN -> thus MAIN would be appropriate here. This name must only be used once! |
FIELDNAME | Field - as defined in your .mnu file - whose content is to be displayed in the drop down menu. E.g. LINK, TEXT, NAME, etc... |
VALUES | optional: Field - as defined in your .mnu file - whose content is to be used as value for the drop down's <option> tags. This comes in handy to create link lists, for example. By default (if empty) VALUES uses the same setting as FIELDNAME. |
SELECTED | optional: line number of your drop down menu that should get focus on initial page load. |
SIZE | optional: height of menu selection box. Default value is 1. A value of 1 usually creates a "true" drop down menu, while in most browsers values higher 1 display as selection box with scroll a bar. |
MULTI | (on/off) optional: allow multiple selections from drop down menu? |
ONCHANGE | (on/off) optional: Adds a JavaScript OnChange handler. This may be used to automatically take the user to a selected page in a link list. |
FIRSTENTRY | optional: text to be displayed as first entry. E.g.: ~ select an entry ~ |
Example:
<!-- PAXCOMBO SUB1, TEXT, LINK,, 1, off, on, ~ select your favorite ~ -->
with PAXTAGS set to "on" this will result in
PAXCOMBOALL may be used to automatically create a drop down menu from all of the menus you have defined.
TAG:
PAXCOMBOALL
SYNTAX:
<!-- PAXCOMBO FIELDNAME,SIZE,MULTI,ONCHANGE,FIRSTENTRY -->
FIELDNAME | Field - as defined in your .mnu file - whose content is to be displayed in the drop down menu. E.g. LINK, TEXT, NAME, etc... |
SIZE | optional: height of menu selection box. Default value is 1. A value of 1 usually creates a "true" drop down menu, while in most browsers values higher 1 display as selection box with scroll a bar. |
MULTI | (on/off) optional: allow multiple selections from drop down menu? |
ONCHANGE | (on/off) optional: Adds a JavaScript OnChange handler. This may be used to automatically take the user to a selected page in a link list. |
FIRSTENTRY | optional: text to be displayed as first entry. E.g.: ~ select an entry ~ |
Example:
<!-- PAXCOMBOALL TEXT, 1, off, on, phpCMS Documentation -->
TAG:
PAXLASTMOD
SYNTAX:
<!-- PAXLASTMOD M d Y - H:m:s -->
Example:
<!-- PAXLASTMOD M d Y - H:m:s -->
with PAXTAGS set to "on" this will result in:
Jun 10 2003 - 22:06:06
The output is formatted according to the rules defined in the PHP date function.
DYNATAGs are TAGS within your TAG file that are not being replaced simply by some text string but that use and execute PHP code as their replacement.
---------------
Example of a DYNATAG within the TAG file:
Current date and time on every page (thanks to Dirk)
Open your TAG file and create a new TAG:
<CURDATE>:= <!-- PAXPHP datetime $date = date("M d Y"); $time = date("H:i"); echo $date," - ",$time," h"; PAXPHP datetime -->From now on you may display the current date and time in either your template or in separate content files simply by inserting the DYNATAG <CURDATE>.
Within PHP code included via PAXPHP you have access to all global variables that were defined prior to the page being parsed by phpCMS/PAX. A list of global variable that are accessible can be found in the phpCMS documentation.
Note that not all global variables accessible to plug-ins are also accessible via PAX. So you may need to experiment a little.
$PHP_SELF is also accessible via PAX. This way the execution of code, or the display of certain parts of the code, could be made dependant on the page that is being displayed.
Currently none known. If you stick to the general guidelines of phpCMS, PAX and PHP everything should work just fine.
Tips&Tricks&FAQ for PAX at Lemon.ac Forum
Enjoy
... Wernhard