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:

  • The guestbook folder's description
  • A list of all the guestbook entries

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

Here:

"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

It's because of using name spaces. Here is the link to explanation:
http://ez.no/ez_publish/documenta...raries/ez_template/basics/namespaces

Explain the colon after the dollar sign

This is the first time in the tutorial that a colon appears after the dollar sign when referencing variables. What does it do differently? Why do we need it?

Contents

Building an eZ publish site

Prerequisits
Situation
Creating the TSCM site
Testing the interfaces
Setting up the main layout
Creating sections
The welcome page
The news page
The members page
The guestbook
    Creating the content class
    Adding content
    Creating the template
    Adding an action button
    Making the button work
    The input template
    Testing the guestbook
    Implementing an approval mechanism
    Modifying the entry page
    Creating a workflow
    Connecting the workflow to a trigger...
    Approving entries
    The "runcronjob" script
The links page


Created

19/11/2003
1:09:55 pm
by Balazs Halasy

Last updated

20/11/2003
9:48:44 am
by Balazs Halasy

Authors

Balazs Halasy



This page is part of the eZ Publish documentation. The documentation is available under the GNU Free Documentation License. All contributions will be released under the terms of this license.