|
[TEMPLATE__ name
^MYSQL = define
^WHERE = define
^IF = define
^CELL = define (updated!)
^CODE = define
^TABLE = define
^ID = define
^LIMIT = define
^UPDATE = define (new!)
^CASE = define (new!)
^CACHED (new!)
]
Since it is "Template Engine" tag , then, in the current version, there
can only be FT tags inside.
You can use this SET__ structure to describe your templates:
Example:
In this example we request two databases: "cd" and "urls" and then show all CD's type and titles, but if the type of CD ='mp3', we will show 10 related URLs.
| |
<? include(“./sp/sp_start.php”); ?>
[SET__CDs
^MYSQL : SELECT * FROM cd
]
[SET__MyTemplate
^MYSQL : SELECT * FROM urls
^WHERE : status = 'Active' and cdid=VAR(CDs.ID) LIMIT 10
^CELL : CELL(2)
^CASE: VAR(CDs.type)=='mp3'
]
<html>
<body>
[TEMPLATE__$CDs]
{ID} {type} {title}
[TEMPLATE__$MyTemplate]
ID: {cdid}, URL: {url}
[END__TEMPLATE__MyTemplate]
[END__TEMPLATE__CDs]
</body>
</html>
<? include(“./sp/sp_end.php”); ?>
|
| |
<? include(“./sp/sp_start.php”);
?>
[SET__FindCurrentCategory
^MYSQL : SELECT ID,alias,title,type FROM sp_news
^WHERE : type = 'Category' AND status = 'Active' LIMIT 5
]
[SET__FindStaticNews
^MYSQL = SELECT *, UNIX_TIMESTAMP(LogTS)
AS mytime FROM sp_news
^WHERE type = 'Post' AND
category = VAR(FindCurrentCategory.ID) ORDER
By LogTS LIMIT 20
^TABLE = sp_news
^ID = ID
]
<html>
<body>
[TEMPLATE__$FindCurrentCategory]
Category ID: {ID}, Category: {title}
my text
[TEMPLATE__$FindStaticNews]
Article ID: {ID}
Author: {author} - Date: {mydate} -
Article title: {title} <br> {text} <br>
[END__TEMPLATE__FindStaticNews]
my text
[END__TEMPLATE__FindCurrentCategory]
my text
</body>
</html>
<? include(“./sp/sp_end.php”); ?>
|
^MYSQL
MySQL query for data output. It is possible to use "VAR(varname)"
construction inside,
where "varname" is [ POST.,GET.,TemplateName.] Name [=default value ]
- Name - sSearch Name in php array $_POST, if not found – in the current record of current template table, otherwise - '' and error
- POST.Name - Search Name in php array $_POST, otherwise
returns "" ( empty ) value and error.
- GET.Name - Search Name in php array $_GET , if not
found in php array $_POST , otherwise returns "" ( empty ) value and
error.
- TemplateName.Name - Search Name in the last processed
template's record
TemplateName ($ row _ data [ TemplateName ][ Name ]) , if not
found – in the PHP array $_POST , otherwise returns"" ( empty
value ) and error.
- default value – if Name was not found, returns default
value instead of an error. If the returning value is not a number, returns
result in quotation marks.
^WHERE - a part of MySQL query, VAR(varname)
can also be used
^IF
checking on data output. Use like in PHP expressions ( ==, > etc.).
VAR(varname) structure can also be used (see above)
^CELL
is used for so called “inside” output. Smart Parser duplicates block's
content inside the template body.
<!--## comment -->
…
<!--endd-->
if indicated CELL : N - blocks are repeated N times, regardless of the number of records.
if indicated CEIL : CELL ( N ) - blocks are repeated N times, script outputs
parsing results for this template, CELL blocks are repeated again N times, template
is put out, and so on. It means that template body will be put out N times
^CODE name.php
The name of php file, which will be called every time after receiving data from
the table but before the template output.
Values from the table are located in $row_data array as $row_data[TemplateName][FieldName]
CODE file can be used for data processing by changing $row_data[TemplateName][FieldName] or for setting“new” fields, e.g.
$row_data[TemplateName][GeneratedFieldName] = $row_data[TemplateName][FieldName]
+ 10;
In template you can call this field as {GeneratedFieldName}
^TABLE name
The name of the table, corresponding to current form. It is required if form or template contains {IMG__}, {CHECK__DELETE}, ^UPDATE tags (see below).
^ID fieldname
key field name. It is required if form or template contains {IMG__}, {CHECK__DELETE}, ^UPDATE tags (see below).
^LIMIT number
Page output parameter means how many records to show on one page. It is used
together with
PREV __, NEXT __, FIRST __, LAST __, PAGES __
^CACHED
Use this tag if you cann the same template 2-3-N times on the page and
the look of output is the same for all template's calls. It will save a time
on MySQL queries.
There are following structures for output of table record values inside the template
body:
{fieldname} – value of the the database field "fieldname".
Use this tag {} to output fields values.
{#} - output current number of a record in the query.
{ENC __ fieldname} – php function (urlencode) result ( fieldname )
{DATE__ fieldname (format=define)} –
php function date. Result - date(format,fieldname)
{CHK__ fieldname} – if { fieldname }==0,
output No , otherwise - Yes
{TXT__ fieldname[(start=val, end=val [,symbol [ = 'character'] ] [,bbcodes] ) ] }
<textarea> text fields output with replacing /n for <br>.
Example: {TXT__mytext (start=1000,end=2000, symbol = ';', bbcodes) }
If start and end are present, then the section from start to end position is chosen
If start is indicated, end is omitted – then end is considered as last position
If end is indicated, start is omitted – then start is considered as first position
If symbol = ' character ' is indicated - then' character ' is a splitter.
If symbol indicated without the value, then 'charaster' = ‘.' (dot)
If bbcodes is included into the set – text is looking for bbcodes
presence (see below) and parse this text accordingly.
{IMG__ fieldname( x=val, y=val, color=44555, link=val )}
Picture output. It works with SP.DE table structure, i.e. for the tables created by Fsave (Database Engine Interface) only. It is required to include ^Table and ^ID structures into the ^TEMPLATE SET.
If dimensions are set it will be the thumbnail of the picture with predefined size (x,y)
x – horizontal size
y – vertical size
color - color in HEX format,
link - a link for image. VAR() can also be used
Example:
{IMG__imagefield} - unchanged image
{IMG__imagefield(x=100,y=100,bbcodes)} - will try to show the image the best possible way,
will use X OR Y to create a thumbnail
{IMG__imagefield(x=100,y=200,color=333333,bbcodes)} - willl use X OR Y to create a thumbnail, but image will be 100x200 as unused part will be filled by color (#333333)
{RADIO__ fieldname}
FP will replace this with <input type='RADIO' name=' fieldname '
value='{fieldname}'>
{CHECK__ fieldname}
FP will replace this with <input type='checkbox' name=' fieldname[] '
value='{fieldname}'>
{SUBMIT__ fieldname} -
this is not the same as [SUBMIT__name]
FP will replace this with <input type='SUBMIT' name=' fieldname '
value='{fieldname}'>
*** where {fieldname} is a value of "fieldname"
field.
{CHECK __ DELETE} - SP.DE will show a checkbox for deleting
records from the table, this structure will be replaced with
<input type='checkbox' name='TemplateName__delete[]' value='{ID}'>
SP.DE is checking the availability of similar values in $POST and make them deleted.
Note: if checkbox is not marked, POST array is empty.
{SPArrayName[$fieldname]} - use it to
call a value from SP array.
Multy-dimensions is allowed, i.e.
SPArrayName [‘ table '][ $ field 1 ][$ field 2 ]
|