Table of Contents |
Template Syntax Gossamer Links template engine is powered by our GT::Template module. For a complete list of all the functionality available by this module, be sure to read it's documentation. Gossamer Links provides a very straight forward way of templates. If you are familiar with ASP or PHP, then this should be no problem. Simply, each template has a set of tags on it that get replaced with HTML when the page is displayed. So for example, on the home page (home.html template), there is a <%category%> tag. This tag will be replaced with a full list of all the top level categories by Gossamer Links. Tags: 1: <%category%> 2: <% category %> 3: <% category %> will all do the same thing. Variables: Template Comments: When Variables are not
Enough: <%if category_results%> <table> <tr><td>Here are your category matches: <%category_results%></td></tr> </table> <%else%> Sorry, but no matching categories were found! <%endif%> Each if statement must end with a matching endif statement. Here's another example on the add form. If the user submitted the form and there was an error, we need to display that error to the user: <%if error%> <p><font color="red">Oops, there was a problem with your submission: <%error%> </font></p> <%endif%> That html between the if and endif tags will only get displayed if there was an error on the addition. Also available are <%ifnot ..%> and <%unless ..%>. Loops: <p>Here are your matching links:<br><br><%link_results%></p> You could do: <p>Here are your matching links:<br><br> <%loop link_results_loop%> <a href="<%URL%>"><%Title%></a>: <%Hits%> <%endloop%> So inside the <%loop%> and <%endloop%> tag you have a series of links, and you can use any link attribute you like. However, don't forget you can also use includes, so you could do: <p>Here are your matching links:<br><br> <%loop link_results_loop%> <tr><td><%include link.html%></td></tr> <%endloop%> Now link.html will be loaded and parsed! Much More: |
Table
of Contents
|