Forums / Setup & design / Add buttons for add/remove/edit nodes

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.

eZ debug

Timing: Jan 19 2025 04:27:46
Script start
Timing: Jan 19 2025 04:27:46
Module start 'content'
Timing: Jan 19 2025 04:27:48
Module end 'content'
Timing: Jan 19 2025 04:27:48
Script end

Main resources:

Total runtime1.7047 sec
Peak memory usage4,096.0000 KB
Database Queries210

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0061 590.2031180.8281
Module start 'content' 0.00611.4934 771.0313690.1250
Module end 'content' 1.49950.2051 1,461.1563341.0703
Script end 1.7046  1,802.2266 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00480.2789210.0002
Check MTime0.00160.0967210.0001
Mysql Total
Database connection0.00080.048010.0008
Mysqli_queries1.589193.21992100.0076
Looping result0.00250.14422080.0000
Template Total1.667597.820.8337
Template load0.00220.126920.0011
Template processing1.665397.688520.8326
Template load and register function0.00010.008310.0001
states
state_id_array0.00130.074010.0013
state_identifier_array0.00270.155920.0013
Override
Cache load0.00200.1197530.0000
Sytem overhead
Fetch class attribute can translate value0.00230.133650.0005
Fetch class attribute name0.00120.0713100.0001
XML
Image XML parsing0.00400.236350.0008
class_abstraction
Instantiating content class attribute0.00000.0015130.0000
General
dbfile0.01741.0225410.0004
String conversion0.00000.000330.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
6content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
7content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
14content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
6content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 38
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs