Object oriented Smart Templates Engine
Smart Template Engine
Installation / Tips Database Engine Interface Smart Parser Engine
Step by step installation
Database (DE) mode FAQ
Templates (TE) mode FAQ
Examples
Tips
Admin interface
Actions Editor
Jump Editor
Mailing Editor
Key Fields
Syntax
How to use TE
How to use DE

(*) DE - Database Engine
(*) TE - Template Engine
            How to use "Template Engine".

Assume that you have the MySQL table and want to create a script to output results.
First table structure - News (ID, title, author, author_email, text, date, image.itype)

SP.DE picture's table corresponding to it, was created automatically by a "Database Engine"
Second table structure - News_image ( ID, image, itype, x, y)

Main question: How to create this script?

1) Include sp_start.php script in the beginning of news.php
<?include(“./sp/sp_start.php”);?>

2) Include sp_end script in the end of the file
<?include(“./sp/sp_end.php”);?>

3) For more convenience describe SET in the beginning of the file ( but after
<? include (“./sp/sp_start.php ”);?>)

 

<? include(“./sp/sp_start.php”); ?>

[SET__
News
^MYSQL : SELECT * FROM News
^WHERE :
^TABLE : News
^ID : ID
^LIMIT : 4

]

<html>
<body>

[TEMPLATE__$News]

      {author} - {DATE__date(format=Y M D)} - {title}
      {IMG__
image(x=100)}
      {TXT__
text(bbcodes)}

[END__TEMPLATE__News]

</body>
</html>


<? include(“./sp/sp_end.php”); ?>


4) Create "image_cache" folder under your /public_html/   (www) directory and set CHMOD to 777 or try to use CHMOD 764 and ask your hosting company to CHOWN this directory to a web server group (usually it's "nobody")

5) That is all.


    Example:

Assume that we should output one author's articles in one format and the other's – in other format. To do it, use [CASE] structure following way:

 

[TEMPLATE__ $News ]

[CASE__author (VAR(author)=='Admin') ]

    {author}
    {DATE__
date(format=Y M D)}
    {title}
    {IMG__
image(x=100)}
    {TXT__
text(bbcodes)}

[ENDCASE__author]


[CASE__author (VAR(author)=='Mark') ]

    {author} -- {date} -- {title}
    {TXT__
text(Start=-100,symbol,bbcodes)}…

[__ELSE__author]

    News format for another authors

[ENDCASE__author]

[END__TEMPLATE__
News]


    Example:
You have two databases - "Categories" and "News" and would like to query + show results from both databases and group results by Category. To do it, create two SET__ (to define queries for "Categories" and "News" databases). Second database "News" will depends on first database by ID (see a query in "FindStaticNews" SET).

 

<? include(“./sp/sp_start.php”); ?>

[SET__
FindCurrentCategory
^MYSQL : SELECT ID,alias,title,type FROM categories
^WHERE : type = 'Category' AND status = 'Active' LIMIT 5
]
[SET__FindStaticNews
^MYSQL = SELECT *, UNIX_TIMESTAMP(LogTS) AS mytime FROM news
^WHERE type = 'Post' AND category = VAR(FindCurrentCategory.ID) ORDER By LogTS DESC LIMIT 20
^TABLE = news
^ID = ID
]

<html>
<body>

[TEMPLATE__$FindCurrentCategory]


     Category ID: {ID}, Category: {title}
     my text, html

[TEMPLATE__$FindStaticNews]

     Category ID: {FindCarrentCategory.ID}
     Article ID: {ID}
     Author: {author} - Date: {mydate} - Article title: {title} <br> {text} <br>

[END__TEMPLATE__FindStaticNews]

     my text, html

[END__TEMPLATE__FindCurrentCategory]

     my text, html

</body>
</html>


<? include(“./sp/sp_end.php”); ?>


    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”); ?>

 

 1997-2004 © Copyright "H-2.com"    Developed by H-2.com