Add buttons for add/remove/edit nodes

Author Message

Frode Slettum

Friday 14 July 2006 1:34:41 pm

Hi

I'm about to create an intranet site based on the standard templates bundled with eZ publish. I want to accomplish this:
- Add a toolbox to the right with buttons to create objects
- Add buttons / links to articles and files to delete/edit them
- This should only be able done by users with the rights

This is how I tried to accomplish it:

To make the toolbox:
- I made an override for the file templates/toolbar/full/node_list.tpl

I added another toolbox in the file:

{if $node.can_create} {*I have seen this from many other templates so I guess it does what it says*}
 <li><a href="#" onclick="ezpopmenu_submitForm( 'new-article' ); return false;">Add article</a></li>
 <form action={"/content/action"|ezurl} method="post" id="new-article">
  <input type="hidden" name="NodeID" value="{$node.node_id}" />
  <input type="hidden" name="ClassID" value="16" /> {*16 is the class-ID of Article*}
  <input type="hidden" name="NewButton" value="" />
 </form>
 
 <li><a href="#" onclick="ezpopmenu_submitForm( 'create-folder' ); return false;">Create folder</a></li>
 <form action={"/content/action"|ezurl} method="post" id="create-folder">
  <input type="hidden" name="NodeID" value="{$node.node_id}" />
  <input type="hidden" name="ClassID" value="1" />
  <input type="hidden" name="NewButton" value="" />
 </form>

 <li><a href="#" onclick="ezpopmenu_submitForm( 'del-folder' ); return false;">Delete folder</a></li>
 <form method="post" action={"content/action"|ezurl} id="del-folder">
 <input type="hidden" name="ContentNodeID" value="{$node.object.main_node_id}" />
  <input type="hidden" name="ContentObjectID" value="{$node.object.id}" />
  <input type="hidden" name="ActionRemove" value"" />
 </form>
{/if}

I don't even know if this is the right way, and the right place to do it but it works on another side I made based on the

"Intranet Solution" contribution at ez.no.

As you can see, my idea was to make the code to all pages. However I could make an override for each section that should have this "feature" enabled. But this should really be possible from everywhere on the site.

To edit articles and files, this is how I was planned to do it:
- make an override for line/article and line/file and add the following:

<a href={concat("content/edit/",$node.object.id)|ezurl}><img src={"edit.png"|ezimage} /></a>

Am I on to something? And why don't the first code works for me? Looks like it doesn't understand onclick=etc etc ..

regards
Frode Slettum

Kristof Coomans

Tuesday 18 July 2006 2:01:23 am

Hi Frode

Is the JavaScript function ezpopmenu_submitForm loaded? Check any JavaScript errors in your browser.

Just out of curiosity, why do you want to use anchors instead of buttons? The code you're using disallows clients to use the form when JavaScript is disabled.

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Frode Slettum

Tuesday 18 July 2006 4:22:54 am

Hi, thank you for your reply. I was almost getting worried .. :)

ezpopmenu_submitForm loaded? I guess not :) I don't know anything about javascript so I guess I'll take a look at this. Nice that you sent me on the right track anyway ..

The reason I did it like this is that is more pretty with a text-link rather than a button.

If someone could comment the other challenges I'm experiencing as well I would be really grateful.

Ɓukasz Serwatka

Tuesday 18 July 2006 4:52:00 am

Hi,

This documentation page describes how to create/edit/remove content from the user side:
http://ez.no/products/ez_publish/documentation/customization/tips_tricks/editing_creating_and_removing_content_from_the_user_page

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Frode Slettum

Tuesday 18 July 2006 5:03:58 am

Thank you. Hope someone will update this kind of documentation to the new template language soon.

The last thing I haven't quite got figured out is where I should but these buttons. Is it normal to add the code to the override templates for the classes and control the access via the permission settings (roles, users etc), or play with override for certain sections.

Coulibaly Ibrahim

Wednesday 19 July 2006 1:39:14 am

First, you must put it in your templates.
second, this code doesn't allow your users to create objects if they don't have appropriate rights.
for exemple , you can have 2 users (with differents rights) using the same page and having different buttons.
it look up throught the permission to deplay or not the button.
don't forget that:

{section show=$node.object.can_create}{*or can_create*}
{*the form to create*}
{/section}

Frode Slettum

Wednesday 19 July 2006 1:49:43 am

Thank you all for good help.

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.