Path

ez.no / ezpublish / documentation / customization / tips & tricks / editing, creating and removing content from the user page


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

You should remove the table in the edit.tpl, otherwise there can be a problem with the Online Editor.

missing close tag </select> in example about creating list of objects

it should be:



<select name="ClassID">


   {section var=class loop=$node.object.can_create_class_list}


    <option value="{$class.id}">{$class.name|wash}</option>


   {/section}


</select>


Contents

Customization

Access control
eZ publish API Documentation
Content structure
Custom design
Components
Tips & Tricks
    Debugging templates
    Javascript in templates
    Fetching current user
    Showing related objects
    Show which templates are used
    Fetching the ID of the parent
    One Article Folder
    Creating tree menus
    How can I use my own php script insid...
    Hiding attribute content
    Splitting an article over several pages
    Accessing section id in pagelayout
    List articles in folder
    Creating nice URLs
    Alt tag on images
    Improve the pagelayout.tpl
    Clean HTML tags
    Insert javascript call inside ezpub d...
    3rd party applications
    Fetch Function examples
    Display more than 15 items on your co...
    Including PHP files in templates
    Redirecting after content publishing
    HowTo see if article has an image
    Date and Time Formats
    Forms processing example: store user...
    Adjust Timezone
    Adding a Remove Button/Image
    Find the age in years for an object
    Editing, creating and removing conten...
    Indexing binary files with IFilters o...
Troubleshooting


Created

30/01/2005
10:25:50 pm
by Kristian Hole

Last updated

07/02/2005
11:13:18 am
by Kristian Hole

Authors

Kristian Hole



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.