ez.no / ezpublish / documentation / customization / tips & tricks / editing, creating and removing content from the user page
These documentation pages are no longer maintained. Please visit the new documentation site.
In some cases it is useful to give the user the access to creation, modification and removal of content without using the administration interface. This is described below.
The code checks if the user has the correct roles and access to create content, and then displays the correct buttons/links:
The following code shows how to display a dropdownlist with the classes the user has access to create and then a button to create it:
{section show=count($node.object.can_create_class_list)} <form method="post" action={"/content/action"|ezurl}> <input type="hidden" name="NodeID" value="{$node.node_id}" /> <select name="ClassID"> {section var=class loop=$node.object.can_create_class_list} <option value="{$class.id}">{$class.name|wash}</option> {/section} <input type="submit" name="NewButton" value="{'Create here'|i18n('design/standard/node/view')}" /> </form> {/section}
The following code displays a edit link if the user has access to edit the node:
{section show=$node.object.can_edit} <a href={concat("/content/edit/", $node.object.id)|ezurl}>Edit</a> {/section}
Try the edit link. The default edit template usually shows too much information for normal users (like placement and version information). Lets edit it to get rid of the fuzz. Copy the template from /design/standard/templates/content/edit.tpl to /design/yourdesign/templates/content/edit.tpl (where yourdesign is usually corporate, plain etc). Edit the /design/yourdesign/templates/content/edit.tpl and remove the line:
{include uri="design:content/edit_placement.tpl"}
and the lines
<td width="120" align="right" valign="top" style="padding-left: 16px;"> <!-- Right part start--> {include uri="design:content/edit_right_menu.tpl"} <!-- Right part end -->
Clear the cache, and try to edit again. Much nicer :)
The following code displays a remove-button if the user has access to delete the object:
{section show=$node.object.can_remove} <form method="post" action={"/content/action"|ezurl}> <input type="hidden" name="ContentNodeID" value="{$node.object.main_node_id}" /> <input type="hidden" name="ContentObjectID" value="{$node.object.id}" /> <input type="submit" name="ActionRemove" value="{'Remove'|i18n('design/standard/node/view')}" /> </form> {/section}
The code is based on having the $node variable accessable, which means you have to put it in your full view template.
Example is based on eZ publish 3.5
This code was inspired by code in the "Learning eZ publish 3" book.
Comments
Remove table
Kristian Hole
Tuesday 29 November 2005 11:35:15 am
missing close tag </select> in example about creating list of objects
esu vytis
Tuesday 24 May 2005 8:59:21 pm