Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By Eng_A_Moktar on
I'm trying to write a module that update a cck field value, on nodeapi in $op(view)
the update goes fine, but it being cached or something, it is fine in database,
when I do Empty cache "with devel module", the changes happen to the node .
it is something like this :
function hook_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL){
switch($op){
case 'view':
$result = db_query("UPDATE `content_type_page` SET `field_viscount_value` = (`field_viscount_value`+1) WHERE `content_type_page`.`nid` = %d;", $node->nid);
break;
}
}
Thanks.
Comments
add
add drupal_flush_all_caches(), if it not works, put your table to hook_flush_caches()
Do I have to flush all cache
Do I have to flush all cache ?
There is nothing in that
There is nothing in that snippet to suggest it would ever be reflected in the node, the code only updates a database table. Our you trying to track how many times the node has been viewed using one of it's own fields?
I'm trying to track node
I'm trying to track node views times, I've to use a cck field to store data there, so I can use it later with views, Please, don't suggest me another model, it has to be this way .
thanks
not solved yet
not solved yet
Add one of these lines at the end of your updates
OR
Peter Aziz
As nevets said: There is
As nevets said:
Two things: Is there a
Two things:
--
Read more at iRolo.net