Paths
Paths are the really interesting part of XTE, and they are where it
gets its real power from. Paths are the way you refer to objects,
arrays, object properties and methods, and array values in XTE. So
translating the path in the first example into PHP code, we were
actually saying:
$site->url
Where $site is a global object, and url is a property of that
object. It must be understood by XT developers that the global-ness of
the object only means that it's origin was as a global object, because
any object used by XTE that was global is first copied to the XTE
register and used from there, so as not to affect in any way the values
and settings of global objects, and also so as to provide a level of
isolation between invocations of the XT engine. So basically, $site was
a global object when site/url was called, but before it is acted on it
is first moved to the register.
There are also a few predefined path starting points defined by XTE
globally as well as during the execution of certain tags, such as the
<xt:loop> tag, which allow you to refer to objects defined at
that time for that specific purpose. These are as follows:
| object | Refers to the object or associative array passed to the
current invocation of the XT engine. |
| nothing | Returns a false value. |
| attrs | Contains a list of all of the attributes of the current
XML tag. |
| paths | Contains a list of all of the possible XPath paths that
point to the current XML tag. These paths are used for
tag and tag attribute binding with the bind() and
bindAttr() methods. Only available for ordinary tags,
not XT tags. |
| cgi | Refers to the global $cgi object, which contains all of
the HTTP request values. |
| session | Refers to the global $session object, which contains all
of the user info, such as username and email, if the user
is logged in. User status can be determined with the
paths session/valid and session/admin. |
| site | Refers to the global $site object, which contains all of
the directory and url info. To reference a relative URL,
for example, so that your template can be called from
the document root or within a subfolder of a site, you
could use the site/prefix path. |
| loop | Contains an array of loop objects, the names of which are
defined in each loop's expression. Each loop object
has the following properties: index (loop iteration number,
counting from 0), number (loop iteration number, counting
from 1), even and odd (boolean values depending on whether
the loop iteration index is an even or odd number),
value if the iteration value was a string or integer,
start (true for the starting repetition -- index 0),
end (true for the final repetition), and length (the
total number of repetitions). |
| result | Contains the current result object from a database query
made by an <xt:sql> command. The properties of this object
correspond to the column names returned from the query. |
| block | Contains a list of parameters passed to the current call
to <xt:show> for that <xt:block>. Used inside the
<xt:block> command to allow parameter passing, making
blocks similar to PHP functions or macros. |
| xml | Contains the current item in an XML include call. Nodes
below the item are accessible via xml/nodename, and
attributes are accessible via xml/attrs/attrname. |
Strings
Strings are the simplest part of XTE, because aside from inline
${path} expressions, they are taken as-is and no processing is done on
them.
Page 1: The real power behind the XT tem...
Page 2: Paths
Page 3: PHP
Page 4: Assignments
All Tutorials