Forums / Developer / Modify contents of an attribute when a button is pressed

Modify contents of an attribute when a button is pressed

Author Message

David Santiso

Sunday 01 May 2011 6:07:54 am

Hi,

In the template shows an object with different attributes I want to add a button that when pressed changes the content of a single attribute (integer).

I am not interested to display the attribute formats using the function edit

{attribute_edit_gui attribute=...}

Just to modify the field value.

Thanks in advance,

David

Marko Žmak

Sunday 01 May 2011 2:49:17 pm

In the default eZP installation you don't have the possibility to edit only one attribute. The alternatives are:

  • create an extension with a custom module that does this (or try to find if such an extension already exists)
  • use a form that has hidden fields for all attributes except the one you want to change

The same issue was also discused here:

  • http://share.ez.no/forums/setup-design/object-relations-attribute

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

David Santiso

Monday 02 May 2011 1:07:48 am

Ok, thanks.

I had tried to create a form with hidden fields to the attribute I want to modify, but it was redirected to the edit template of the object

I didn't know that I have to do it for all attributes of the object.

David Santiso

Monday 02 May 2011 11:16:33 am

My code is this, but it doesn't work. When I click on the submit button it redirect to the edit template of the object without displaying the changes.

<form name="editform" id="editform" enctype="multipart/form-data" method="post" action={concat( '/content/edit/', $node.contentobject_id, '/', $edit_version, '/', $edit_language|not|choose( concat( $edit_language, '/' ), '/' ), $is_translating_content|not|choose( concat( $from_language, '/' ), '' ) )|ezurl}>
  
  <input class="button" type="submit" name="PublishButton" value="{'Submit'}" />
  <input type="hidden" name="DiscardConfirm" value="0" />

  <input type="hidden" name="ContentObjectAttribute_id[]" value="{$node.data_map.attribute1.id}" />
  {attribute_edit_gui attribute=$node.data_map.attribute1 view_parameters=$view_parameters}

  <input type="hidden" name="ContentObjectAttribute_id[]" value="{$node.data_map.attribute2.id}" />
  {attribute_edit_gui attribute=$node.data_map.attribute2 view_parameters=$view_parameters}
  
  ...

  <input type="hidden" name="ContentObjectAttribute_id[]" value="{$node.data_map.attribute_to_edit.id}" />
  <input type="text" name="ContentObjectAttribute_data_integer_{$node.data_map.attribute_to_edit.id}" value="23" />
            
</form>

Marko Žmak

Monday 02 May 2011 12:17:18 pm

For the attributes you want hidden you don't use attribute_edit_gui but a pair of hidden inputs. And don't forget to do this for all the attributes of the object.

And for the attribute you want to be displayed and edited you do use attribute_edit_gui.

See the other post I mentioned for details.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

David Santiso

Monday 02 May 2011 12:45:56 pm

Yes I've read it. I've also tried this, but still not working.

<form name="editform" id="editform" enctype="multipart/form-data" method="post" action={concat( '/content/edit/', $node.contentobject_id, '/', $edit_version, '/', $edit_language|not|choose( concat( $edit_language, '/' ), '/' ), $is_translating_content|not|choose( concat( $from_language, '/' ), '' ) )|ezurl}>
            
  {include uri='design:content/edit_validation.tpl'}
            
  <input class="button_green" type="submit" name="PublishButton" value="{'Submit'}" />
  <input type="hidden" name="DiscardConfirm" value="0" />
            
  <input type="hidden" name="ContentObjectAttribute_id[]" value="{$node.data_map.attribute1.id}" />

  <input type="hidden" name="ContentObjectAttribute_id[]" value="{$node.data_map.attribute2.id}" />
  
  ...
        
  <input type="hidden" name="ContentObjectAttribute_id[]" value="{$node.data_map.attribute_to_edit.id}" />
  {attribute_edit_gui attribute=$node.data_map.attribute_to_edit view_parameters=$view_parameters}
            
</form>

Marko Žmak

Monday 02 May 2011 1:00:37 pm

When you use attribute_edit_gui you musn't use the ContentObjectAttribute_id[] input.

Also for every hidden attribute you have to have two input fields as I described in the other post.

Read my answers to the other post more carefully.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

eZ debug

Timing: Jan 18 2025 03:05:23
Script start
Timing: Jan 18 2025 03:05:23
Module start 'content'
Timing: Jan 18 2025 03:05:24
Module end 'content'
Timing: Jan 18 2025 03:05:24
Script end

Main resources:

Total runtime0.9695 sec
Peak memory usage4,096.0000 KB
Database Queries206

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0061 589.0859180.8047
Module start 'content' 0.00620.8498 769.8906601.1172
Module end 'content' 0.85590.1135 1,371.0078341.0234
Script end 0.9695  1,712.0313 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00380.3873210.0002
Check MTime0.00140.1405210.0001
Mysql Total
Database connection0.00100.103110.0010
Mysqli_queries0.884291.19732060.0043
Looping result0.00190.20062040.0000
Template Total0.939596.920.4698
Template load0.00220.222320.0011
Template processing0.937396.681720.4687
Template load and register function0.00020.020410.0002
states
state_id_array0.00060.067010.0006
state_identifier_array0.00110.115920.0006
Override
Cache load0.00160.1641430.0000
Sytem overhead
Fetch class attribute can translate value0.00150.157230.0005
Fetch class attribute name0.00150.159280.0002
XML
Image XML parsing0.00120.128330.0004
class_abstraction
Instantiating content class attribute0.00000.0023100.0000
General
dbfile0.00820.8423290.0003
String conversion0.00000.000530.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
7content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
11content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltags/li.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/li.tplEdit templateOverride template
2content/datatype/view/ezxmltags/ul.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/ul.tplEdit templateOverride template
4content/datatype/view/ezxmltags/strong.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/strong.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 34
 Number of unique templates used: 9

Time used to render debug report: 0.0001 secs