About Sitellite       Screenshots       Downloads       Forge      Documentation       Community       Support

You are here: Home / Documentation / XT Tips & Caveats

XT Tips & Caveats

Outputting PHP

This won't be the most frequently used feature, but in some cases it can be quite handy. I'll start out with an example, then I'll explain my way through it:

<xt:code><![CDATA[

echo 'hello<br />';

]]></xt:code>

The <xt:code> tag tells XT to wrap the enclosed content in the language identifiers of your choice (the default is PHP). The CDATA tags are in case you have any "illegal entities" in your source code (namely, < and &), as does the above example since it prints a <br /> tag.

The output of this code would simply be:

<?php

echo 'hello<br />';

?>

Pretty straight-forward. The previewability of this solution is also intact, since the CDATA block doesn't display in the browser, so your code remains invisible when previewing the template.

The nice thing about this feature is that, coupled with my article on publishing a static web site from Sitellite, you can use this to publish semi-dynamic web sites that are completely devorced from Sitellite itself (leaving the Sitellite-powered site as a staging area), as well. Couple this with some simple rsync-based mirroring and perhaps a little cron, and you've got a full-fledged language-agnostic content publishing solution.

Of course, you'll want to make sure your staging area is blocked off from public access, or people will be able to see your source code by viewing the source of your templates. You could do this either by firewalling it off entirely, or using SSL and HTTP basic authentication to access the staging site.

Here's a quick overview of the different languages supported:

<xt:code language="php"></xt:code> <?php ?>
<xt:code language="asp"></xt:code> <% %>
<xt:code language="jsp"></xt:code> <% %>
<xt:code language="eruby"></xt:code> <% %>
<xt:code language="python"></xt:code> <% %>
<xt:code language="eperl"></xt:code> <: :>
<xt:code language="asp_include"></xt:code> <%@ %>
<xt:code language="jsp_include"></xt:code> <%@ %>
<xt:code language="runat_server"></xt:code> <script runat="server"></script>
<xt:code language="javascript"></xt:code> <script language="javascript type="text/javascript"></script>

Most other languages I've seen use the asp/jsp tag style as well, so I'm sure there are more that are supported than just the ones mentioned here.

In conclusion, I hope this helps make you a more empowered XT template designer, or at least helps clear up some of the less apparent aspects of the language.

For more info about XT, including a decent tag reference and explanation of the XT expression syntax, see:

http://www.sitellite.org/docs/XML/_XML_XT_php.html



Page 1: The Basics: HTML Versus XML
Page 2: Comments
Page 3: Javascript
Page 4: Doctype
Page 5: Outputting PHP

All Tutorials

Members

Note: You can use your SitelliteForge.com account here and vice versa.

Username

Password

Forgot your password?

Not a member? Click here to register

Sitellite 5 Beta


Copyright © 2008, SIMIAN systems Inc.
All rights reserved. Privacy policy
Some of the icons on this site were created by the Gnome Project.