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

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

eZ debug

Timing: Jan 30 2025 21:16:10
Script start
Timing: Jan 30 2025 21:16:10
Module start 'layout'
Timing: Jan 30 2025 21:16:10
Module start 'content'
Timing: Jan 30 2025 21:16:10
Module end 'content'
Timing: Jan 30 2025 21:16:10
Script end

Main resources:

Total runtime0.0238 sec
Peak memory usage6,144.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0050 588.3906151.2422
Module start 'layout' 0.00500.0035 739.6328220.7578
Module start 'content' 0.00850.0139 960.39061,006.5078
Module end 'content' 0.02240.0013 1,966.898437.9766
Script end 0.0237  2,004.8750 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002510.6777140.0002
Check MTime0.00104.2546140.0001
Mysql Total
Database connection0.00062.674910.0006
Mysqli_queries0.00249.886430.0008
Looping result0.00000.051210.0000
Template Total0.00093.910.0009
Template load0.00073.021010.0007
Template processing0.00020.829510.0002
Override
Cache load0.00041.826410.0004
General
dbfile0.002811.601580.0003
String conversion0.00000.033140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs