The input template

These documentation pages are no longer maintained. Please visit the new documentation site.

Go ahead and surf the "Guestbook" page again. Attempt to press the "Sign the guestbook" button (which at this point should work). Instead of the "Object unavailable" message, you should be presented with a page that resembles the following screenshot:

If it worked, it means that eZ publish allowed the anonymous user to create a new guestbook entry object. What you're looking at is the default edit template, which resides in the "design/standard/templates/content/edit.tpl" file. This template contains a lot of functionality that we don't need (version control, set.). What we need is a template that shows two fields (the name and the entry field) and two buttons (Submit and Cancel). The following text explains how to create a template override and a custom template for guestbook entries.

Until now, we've been doing template overrides by using the web based administration interface. The administration interface can only be used to create basic template override rules. Complex/advanced rules must be input manually to the override file of the target siteaccess. What the administration interface does is that it simply manipulates this file when you create/edit/delete template overrides. Let's create the guestbook-entry template override manually. The following list of steps should guide you through it.

  1. Acquire and make a note of the identification number of the "Guestbook entry" content class. (Hint: Admin->Setup->Classes->Content)
  2. Acquire and make a note of the identification number of the guestbook section. (Hint: Admin->Setup->Sections)
  3. Edit the "settings/siteaccess/tscm/override.ini.append" file.
    Notice that the file contains the overrides that we've added so far.
  4. Scroll down to the end of the file and add the following lines to it:
[edit_guestbook_entry]

Source=content/edit.tpl

MatchFile=edit_guestbook_entry.tpl

Subdir=templates

Match[class]=__REPLACE_WITH_CLASS_ID__

Match[section]=__REPLACE_WITH_SECTION_ID__

Make sure that you replace the "__REPLACE_WITH_CLASS_ID__" with the identification number of the "Guestbook entry" content class. You'll also need to replace the "__REPLACE_WITH_SECTION_ID__" with the identification number of the guestbook section. When finished, save the file, clear all caches, surf the guestbook and press the "Sign the guestbook" button again. At this point, the system should not display anything. That is because the "edit_guestbook_entry.tpl" file doesn't exist. Let's fix this problem. Create the new template file ("design/tscm/override/templates/edit_guestbook_entry.tpl") and put the following lines of code into it:

<div class="pagetitle">

   Add a guestbook entry

</div>

 

<form enctype="multipart/form-data"

     method="post"

     action={concat("/content/edit/",

                    $object.id,

                    "/",

                    $edit_version)|ezurl}>

 

<table class="layout">

   <tr><td>

 

       {include uri="design:content/edit_validation.tpl"}

       {include uri="design:content/edit_attribute.tpl"}

 

       <div class="buttonblock">

           <input class="defaultbutton"

                  type="submit"

                  name="PublishButton"

                  value="Submit" />

 

           <input class="button"

                  type="submit" 

                  name="DiscardButton" 

                  value="Cancel" />

 

           <input type="hidden" 

                  name="MainNodeID" 

                  value="{$main_node_id}" />

       </div>

   </td></tr>

</table>

</form>

The action URL is constructed by concatenating several strings. The final string is translated using the "ezurl" operator. The URL reveals the module that we wish to access (content), the function that should be executed (edit), the identification of the object ($object.id) and the version ($edit_version) that should be edited. Since this interface is only meant to be used to create new nodes (and not edit existing nodes), the version number will always be one.

The "edit_validation.tpl" takes care of validating the input once it is submitted. Omitting this line will still not allow the submission of partially or completely empty entries. The system will simply not display the warning. Since we've set both the entries to be required (when we created the "Guestbook entry" class), eZ publish will not allow empty entries.

The "edit_attribute.tpl" takes care of displaying the actual input fields and their names.

The "PublishButton" string (name of the "Submit" button) instructs the system to publish the object that is being edited.

The "DiscardButton" string (name of the "Cancel" button) instructs the system to discard the object that is being edited.

The hidden "MainNodeID" field reveals the identification number of the node that will be the parent of the node that is being published. This is the main location of the node that is being published. Without this field, eZ publish will not be able to publish the object.

Comments

"Match[section]" is not available for "content/edit.tpl"

According to the 3.6 docs, only "object", "class", "class_identifier" and "class_group" (but not "section") can be used in override conditions for "content/edit.tpl".
See http://ez.no/doc/ez_publish/techn...ference/template_override_conditions

Possible to create template for /content/edit with admin interface

Just filter the templatelist with content/edit and then make new override for the guestbook_entry class.

css

remember to add the "layout" class in the stylesheet. otherwise it looks fugly....

showing default template

Erik

"I added the lines, I created the template ( however, it does not specify where, so I added it to the node/view/full ) hoping this would be the correct location."

I'm sure you spotted this but, it does specify where to put the template:
design/tscm/override/templates/edit_guestbook_entry.tpl

David

showing default template

I tried to do as per instructions, however, it seems like it is not reading the correct template or is missing the template somehow. I followed the steps:
1. Acquire and make a note of the identification number of the "Guestbook entry" content class. (Hint: Admin->Setup->Classes->Content)
2. Acquire and make a note of the identification number of the guestbook section. (Hint: Admin->Setup->Sections)
3. Edit the "settings/siteaccess/tscm/override.ini.append" file.
Notice that the file contains the overrides that we've added so far.
4. Scroll down to the end of the file and add the following lines to it:

I added the lines, I created the template ( however, it does not specify where, so I added it to the node/view/full ) hoping this would be the correct location. Changed priorites and cleared cache. Nothing happens.
If anyone could please suggest something or contact me I would appreciate it.
Thank you.
Erik Thorsen

A Change That Made a Difference...

I was having a great deal of trouble getting the input template to work. I followed the instructions carefully, copying and pasting all the code precisely. However I noticed that there was a difference between the code on this page that I was putting into the "settings/siteaccess/tscm/override.ini.append" file and the code that was put there automatically for the other override templates I had created earlier. When I changed the line that read:

Match[class]=__REPLACE_WITH_CLASS_ID__

to:

Match[class_identifier]=__REPLACE_WITH_CLASS_Identifier__

then it worked. I'm not sure why this worked but it did.

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
2:00:54 pm
by Balazs Halasy

Last updated

23/11/2004
2:21:07 pm
by Raymond Bosman

Authors

Balazs Halasy
Raymond Bosman



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.