Forums / Setup & design / Changing the value of an attribute help please

Changing the value of an attribute help please

Author Message

Hugo Siles

Wednesday 14 April 2004 3:26:52 pm

Hi all...

I really need some help whit a problem that I have. I want to know if it is posible to change the value of an attribute without calling content/edit/$object_id..etc.

For example, I have extended the class article, now it has an attribute called volumen..
what I want is that every time this article is visited the volumen get incresed by one.

is there some way to do this??? please help me with this problem..

Cheers:

Hugo

Gunnstein Lye

Monday 19 April 2004 7:57:31 am

It is not possible do this in a "nice" way. You could solve it with a hack: in kernel/content/view.php, add some code that increases the (current version of the) attribute by one if the object is of the right class. If you do it as a pure SQL call, the performance impact would be low.

Hugo Siles

Tuesday 20 April 2004 4:16:40 am

Thanks for your reply Gunnstein...

but i have this problem, one of the requirement of the project I'm developing is that I can't modify the kernel of ezpublish, so please, if there is another way or some idea to achive this funcionality I would really apreciate your help...

Cheers

Hugo Siles Del Castillo

Gunnstein Lye

Tuesday 20 April 2004 4:46:48 am

Well, there is one other way: You could create a custom operator that does the same as my kernel hack. Place it somewhere in the view template. This way you don't have to modify the kernel.

But there is a problem with this too: When the page is cached, the operator will not be executed. So you have to disable view cache, and find some other cache solution.

A workaround is to place the operator somewhere in the pagelayout (not in a cache block) and send $module_result.node_id as a parameter to it. In the code for the operator, check the node id (not all pages have a node id), if it exists, do the sql that updates the attribute. This should work. Make sure to make the code as efficient as possible, or it will slow down your pages.

Hugo Siles

Tuesday 20 April 2004 5:27:49 am

Thanks a lot Gunnstein, I would try to create a new operator, I have read the documentation about this: http://ez.no/ez_publish/documentation/development/kernel/custom_template_operators
Now I know that i have to modify or override the template.ini, that's fine, but where should I put the php file or code of the function that I will define???

Another thing, when you are talking about the page being cached, are you refering to a cache-block or to the settings in the site.ini file???

Thanks for all your time and help, I really apreciate it..

Cheers

Hugo

Gunnstein Lye

Tuesday 20 April 2004 6:15:33 am

That doc page is only about using built-in PHP functions as template operators. What you need is a doc about making a custom operator for your own PHP functions. This should be here
http://ez.no/ez_publish/documentation/development/extensions/template_operator
but is obviously not written yet. I'll see if I can put something together, but it may not happen today.

Never mind the caching stuff, it was just me thinking aloud. Use the suggestion in the last paragraph, in other words {increase_view_count( $module_result.node_id )} somewhere in pagelayout, but not in a cache block.

Hugo Siles

Tuesday 20 April 2004 6:32:21 am

thanks Gunnstein

I really apreciate all your time, I will be waiting for an update to the page that you mentioned, also I'll be searching around the forum in order to see if someone is with the same kind of problem.. thanks

Cheers:

Hugo

Gunnstein Lye

Tuesday 20 April 2004 10:40:05 am

I have added the doc now:
http://ez.no/ez_publish/documentation/development/extensions/template_operator

eZ debug

Timing: Jan 18 2025 16:10:42
Script start
Timing: Jan 18 2025 16:10:42
Module start 'content'
Timing: Jan 18 2025 16:10:43
Module end 'content'
Timing: Jan 18 2025 16:10:43
Script end

Main resources:

Total runtime1.5624 sec
Peak memory usage4,096.0000 KB
Database Queries209

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0144 588.9766180.8125
Module start 'content' 0.01451.3500 769.7891568.9922
Module end 'content' 1.36450.1978 1,338.7813341.0547
Script end 1.5623  1,679.8359 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00410.2625210.0002
Check MTime0.00150.0960210.0001
Mysql Total
Database connection0.00230.145910.0023
Mysqli_queries1.477694.57422090.0071
Looping result0.00230.14802070.0000
Template Total1.505596.420.7528
Template load0.00230.146620.0011
Template processing1.503296.212720.7516
Template load and register function0.00010.008110.0001
states
state_id_array0.00180.115610.0018
state_identifier_array0.00200.125620.0010
Override
Cache load0.00200.1267460.0000
Sytem overhead
Fetch class attribute can translate value0.00120.077030.0004
Fetch class attribute name0.00100.065690.0001
XML
Image XML parsing0.00100.065530.0003
class_abstraction
Instantiating content class attribute0.00000.0013120.0000
General
dbfile0.00410.2632270.0002
String conversion0.00000.001030.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
8content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
10content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
5content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
4content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 29
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs