exponential.earth / exponential / documentation / building an ez publish site / the guestbook / creating the template
These documentation pages are no longer maintained. Please visit the new documentation site.
Use the administration interface to create a template override for the guestbook folder. Hints: Remember to assign the guestbook folder to the guestbook section. Override the "/node/view/full.tpl" template for the folder class within section "Guestbook". Name the new template "full_view_guestbook_folder". Base the template on an empty file. In addition, you should also make sure that the "guestbook" link in the main menu actually points to the guestbook. When you're finished with all this, attempt to write your own template code that takes care of displaying the following elements:
Put your code into the newly generated/empty "design/tscm/override/templates/full.tpl" file. If you're unsure about the template code (or if you're simply just lazy), feel free to peek at (or copy) the template code that is provided below.
<div class="pagetitle"> {$node.name} </div> <table class="guestbook"> <tr><td> {$node.object.data_map.description.content.output.output_text} </td><td> <img src={"guestbook.png"|ezimage}> </td></tr> <tr><td> <!-- The button will be here! --> </td><td> </td></tr> </table> {* Grab all the guestbook entries. *} {let name=test counter=0 children=fetch( content, list, hash( parent_node_id, $node.node_id, sort_by, $node.sort_array ) ) } <table class="news_archive"> {* Loop through all the entries. *} {section loop=$:children} {* Increment the counter by one. *} {set counter=$:counter|inc} <tr><td> <hr /> Submitted by <b>{$:item.object.data_map.name.content|wash}</b> on {$:item.object.published|l10n(shortdate)}: <br /> <br /> <i>{$:item.object.data_map.entry.content|wash}</i> </td></tr> {* End of loop. *} {/section} <tr><td><hr /></td></tr> </table> <div class="center"> Number of entries in the guestbook: {$:counter} </div> {* Release the counter and the children variable. *} {/let}
Notice the use of the "wash" operator. It takes care of translating bogus strings into friendly ones. The wash operator will make sure that HTML tags found inside guestbook entries don't mess up the output. In other words, people who submit text with HTML tags will not be able to destroy the original page layout. Tags will be displayed as normal text (they will not be interpreted by the browser).
The template code above makes use of an image called "guestbook.png". Feel free to use the following icon/image: guestbook.png. This image is non-content specific (it belongs to layout/design), so therefore, we'll place it inside the TSCM design directory. Download and place the image into the "design/tscm/images/" directory.
Some of the HTML code that was presented above also makes use of some additional CSS. Make sure you put the following lines into the TSCM CSS file (things might look a bit ugly without).
.guestbook { margin-left: auto; margin-right: auto; width: 95%; }
If you've used the example data and the example code, you should be looking at something that resembles the following screenshot (when accessing the guestbook page from the main menu).
Comments
Mistake
Marat M.
Friday 06 May 2005 11:29:17 pm
"Put your code into the newly generated/empty "design/tscm/override/templates/full.tpl" file."
While actually the template name is:
"design/tscm/override/templates/full_view_guestbook_folder.tpl"
and is created through the overriding, then editing on the server.
Namespaces
Kirill Subbotin
Wednesday 30 March 2005 4:44:18 pm
http://ez.no/ez_publish/documenta...raries/ez_template/basics/namespaces
Explain the colon after the dollar sign
Dave Myron
Friday 10 December 2004 12:30:58 pm