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
|