Smarty templates Home

Introduction
Welcome
System requirements
Licensing details
What is the registration
Using ASPRunner
Working with projects
Templates
What are templates
Cars
Classified ads
Events
Jobs
Knowledge base
News
Paypal
Real estate
Sporting
Vacation houses
Connecting to the database
Datasource tables
Master-details
SQL query page
About SQL query designer
Query Designer
SQL
Results
Charts
Creating chart and setting parameters
Chart appearance
Using SQL to shape chart data
Reports
Creating report and setting parameters
Report totals and layout
Choose pages
Login page
User login settings
Advanced security settings
User group permissions
Dynamic permissions
Fields order and totals
Miscellaneous settings
Choose theme
Visual Editor
About
Toolbars
Page Elements
"View as" settings
"Edit as" settings
Validation types
Lookup wizard
Events
Output directory settings
After you are done
FTP upload
FrontPage Publishing
Advanced topics
Connecting to database
Connecting to MS Access database
Connecting to MS SQL Server database
Connecting to FoxPro database
Connecting to MySQL database
Connecting to Oracle database
Connecting to MS Excel database
Connecting to CSV or Text file
Events
Data Access Layer
More about events
Global events
Table events
Page life cycle overview
Predefined actions
Send simple email
Send email with new data
Save new data in another table
Insert a record into another table
Check if specific record exists
Display a message on the Web page
Redirect to another page
Custom code
Sample code
Show list of customer orders
Check if start date is ealier than end date
Before deleting a record check if related records exist
Speed up data entry using events
Publishing ASP application to the remote Web server
Using third party FTP client to publish ASP pages to the remote Web server
Using FrontPage to publish ASP pages to the remote Web server
Demo account
What is the Demo Account?
Terms and Conditions
Enterprise Edition
Online report/chart builder
Master-details relationships
Using JOIN SQL queries
AJAX-based Functionality
ASPRunner session variables
Debugging tips
Template files processing rules (Files.txt)
Multilanguage support
Useful functions and links
ASPRunner templates
Stylesheets
Template language
Rich Text Editor plugins
How to control Inline Add/Edit functionality from script
Troubleshooting "Operation must use an updateable query" errors
ODBC
Upgrade Guide from ASPRunnerPro 4.0 and older
Frequently Asked Questions
Error: Operation must use an updateable query.
Error: Syntax error in UPDATE statement.
Error: Syntax error in INSERT INTO statement
Error: Login failed for user 'MACHINE_NAME\IUSR_MACHINE_NAME'
Error: Data type mismatch in criteria expression
Error: The Microsoft Jet database engine cannot open the file (unknown).
Error: Unable to open registry key 'Temporary (volatile) Jet DSN for process ...
Error: Data provider could not be initialized
Error: Invalid use of Null: 'Replace'
Error: Specified driver could not be loaded due to system error 5 (Oracle in OraHome92)
How can I add new ODBC Datasource
Error: Too many fields defined
Error: I enter correct login and password but receive Invalid Login error. I use SQL Server.
I cannot find ODBC Administrator applet on Windows 2000 machine
I cannot connect to my Excel (Access) database
Where can I download latest ODBC drivers
How to work with Access database stored on the remote computer?
Reserved Access, T-SQL, ODBC keywords.
Order ASPRunner online

 
  ASPRunner manual


ASPRunner templates

 

ASPRunner uses built-in template language. ASPRunner templates cleanly separates your presentation layer (HTML, CSS, etc.) from your application code.

New template language was introduced in ASPRunner 6.0. The main idea is to simply visual templates moving all logic and javascript to ASP files. This makes Visual Editor stable and eliminates the need to reset pages,

ASPRunner 5.2 and older use Smarty as a template language. If you open a project created by previous version, all unmodified visual templats will be converted to new format automatically. Modified files won't be changed and still be using Smarty-based template language. To convert modified visual template to the new format use "Reset" and re-apply changes manually.

Template language reference

 - all templates tags are enclosed within delimiters { and }. All content outside delimiters is displayed as statis HTML.

 - template variables start with dollar ($) sign. They may contain numbers, letters and underscores.

Example: {$variable_name}

{BEGIN block_name} {END block_name} is used to define block section (loops, condition statements).

Functions

  • assign name, val is used to assign value val to the variable name.

  • assign_section name,begin,end is used to define block section.

  • display(templatefile) renders and displays the template file.

How templates work

Template files (*.htm) can be found in templates directory under output directory.

Here is the basic example of how templates work:

list.asp

 
<!--#include file="libs/xtempl.asp"-->

' create object
set xt = new XTempl

' assign some content. This would typically come from
' a database or other source, but we'll use static
' values for the purpose of this example.
xt.assign "name", "george smith"
xt.assign "address", "45th & Harris"

' display it
xt.display('list.htm')

The template file then contains the output interspersed with tags that ASPRunner replaces with assigned content.

list.htm

output

 
<html>
<head>
<title>User Info</title>
</head>
<body>

User Information:<p>

Name: {$name}<br>
Address: {$address}<br>

</body>
</html>

 

 
<html>
<head>
<title>User Info</title>
</head>
<body>

User Information:<p>

Name: george smith<br>
Address: 45th & Harris<br>

</body>
</html>

 

{BEGIN} ... {END} blocks

Template file contains a set of code sections wrapped by {BEGIN ...} and {END ...}.

view.htm

{BEGIN Model_fieldblock}

  <tr><td class=shade width=150>Model</td><td width=250>

  {$Model_value}&nbsp;

  </td></tr>

{END Model_fieldblock}

In view.asp file use the following:

xt.assign("Model_fieldblock",true); - code snippet between {BEGIN ...} and {END ...} appears in the output.

xt.assign("Model_fieldblock",false); - code snippet goes away.

How to deal with Javascript

Earlier we mentioned that javascript and some HTML tags like <form> and <input type=hidden ...> need to be moved to ASP code in order to keep templates clean.

On the server side javascript code needs to be assigned to body or end variables in block array.

list.asp

' create body object

set body = CreateObject("Scripting.Dictionary")

' code assigned to "begin" variable replaces {BEGIN body} tag

body("begin")="<form name='frmSearch' method='GET' action='carsadmin_cars_list.asp'>" & _

"<input type='Hidden' name='a' value='search'>" & _

"<input type='Hidden' name='value' value='1'>" & _

"</form>"

' code assigned to "end" variable replaces {END body} tag

body("end")="<script>if(document.getElementById('SearchFor'))" & _

"document.getElementById('ctlSearchFor').focus();</script>"

xt.assign "body",body

Template file and generated output

list.htm

output

{BEGIN body}

...
{END body}

 

<form name="frmSearch" method="GET" action="carsadmin_cars_list.asp">

<input type="Hidden" name="a" value="search">

<input type="Hidden" name="value" value="1">

</form>

...

<script>if(document.getElementById('SearchFor'))

document.getElementById('ctlSearchFor').focus();</script>

 

 

 

The CHM file was converted to HTML by chm2web software.