I am writing a module.
I wrote in my hook_block something like this:

if ($op == 'view' && $delta == 0) {
(.....)
$counttest = variable_get('counttest', 0);
variable_set('counttest', $counttest+1);
$counttest2 = variable_get('counttest', 0);
print $counttest2;
(.....)
}

And when I refresh my page in browser I suppose to see $counttest + 1, but there is sometimes $counttest +1, sometimes $counttest +2, sometimes $counttest +3. I don't know why. Anyone can help me?

Peter.

Comments

armanschwarz’s picture

are you reseting the counttest variable? if not, everytime you run ariable_set('counttest', $counttest+1) it will increase by 1. Sorry that's probably not much help but I'm having trouble understanding what it is that you're trying to do. Can you be more specific?

piotrsmykaj’s picture

I don't writing english very well :)

I have a problem because when I write something to "view" in hook_block, then this is invoke by drupal one, two or three times when I reload my page. I don't know why, I think this should invoke only one time - not two or three.