0

I'm using a MODULE_preprocess_node function to modify the node template and I'm experiencing strange things.

Basically my idea was to prevent anonymous users from commenting more than once. In the preprocess function, I check if the current hostname (if anonymous) has a previously submitted comment for the current NID and if it does, I empty the comment form array.

But the problem is that, even when caching is disabled, I'm experiencing strange behavior. I'm not quite sure whether it's because of caching. I checked my db_select call and it works.

Do you have any recommendation for me to prevent this from being happening ? May be I should ask if the output of *_preprocess_* functions are cached at first place.

I do not have (core) caching enabled and I'm planning to do so. No other modules installed yet.

Thanks in advance.

1

Do not confuse the cache with the "theme registry".

If you're updating theme functions, flush the cache (which will also update the theme registry).

if you post code there could be other reasons it isn't working. if you're dealing with comments I would look at using comment specific hooks rather than node submission hooks.

| improve this answer | |
  • Actually it was about the $comment_form in the node.tpl.php so that's why I used node proprocess functions. Your answer saves a lot of my frustration with this. Thanks! – AyeshK Dec 17 '12 at 19:32
  • "Thanks" is not enough: Thanks a lot! – AyeshK Dec 17 '12 at 19:32
  • ... and after further checking I realized that the preprocess functions' results are not cached (it was just my bad assumptions) – AyeshK Dec 17 '12 at 20:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.