exponential.earth / exponential / documentation / building an ez publish site / the guestbook / 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.
[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"
Svitlana Shatokhina
Monday 02 April 2007 4:13:27 pm
See http://ez.no/doc/ez_publish/techn...ference/template_override_conditions
Possible to create template for /content/edit with admin interface
Gerhard Sletten
Thursday 24 August 2006 10:27:31 pm
css
Torbjørn Laukvik
Tuesday 26 April 2005 2:51:31 pm
showing default template
David Goddard
Wednesday 06 April 2005 12:02:49 pm
"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
Erik Thorsen
Monday 10 January 2005 3:19:21 pm
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...
Tom Walker
Thursday 30 December 2004 11:55:38 pm
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.