As I understand it from the theme documentation, there is a function called
themename_preprocess($vars,$hook)
when I load a particular page, this function is hit a number of times depending on the hooks which are being called. According to the documentation there is also a function called
themename_preprocess_hook($vars)
and my understanding is that if themename_preprocess() is called with $hook = 'page' once, therefore themename_preprocess_page() should be called once as well.
In my situation I have copied Garland and am using it as a base to test out certain templating functions I will need for development with a designer. I have implemented themename_preprocess() successfully, which checks the hook via the switch structure, and then adds template suggestions according to context (as from the context module), panel, path, etc. These have all been successful: but it is important for you to know what I am doing.
Having done this, I noticed that themename_preprocess() is called maybe 16 or so times on a given page, way overkill when I am only intending to hit $hook=page, or maybe $hook=node. Logically, my solution would be to drop the case='page' block of code into the themename_preprocess_page() function to save a bunch of function calls.
However, it seems that themename_preprocess_page() is not being called when a panel I have created (let us call it node 2) is being viewed. It is fully possible that a panel does not trigger the preprocess_page() function, even though it does come through preprocess() with $hook='page'.
If I am overlooking something important do not hesitate to let me know. My process for testing the occurrence of the callback is simple: I define the function themename_preprocess_page($vars) and do a single operation: echo a unique string. I then view the source of a given page (node/2 in this case) and search for that unique string. In the case that I do this with themename_preprocess() I get a result for $hook='page', but not for themename_preprocess_page().
If this is intended functionality I'd appreciate knowing - the theme API docs imply that it is not. For instance, the $hook variable in themename_preprocess() may not be coeval to the hook variable in themename_preprocess_[hook]() - but they have the same name so it's highly confusing.
Note that 'themename' is in every case replaced with my theme's machine-readable name as defined by the .info's file name (themename.info) in the theme's directory.
*ADDENDUM*
I installed the Devel module and it is now being called. I am confused about this behavior. Will I need the Devel module installed on the live site so that themename_preprocess_page() can be called? This doesn't seem right.
Comments
Comment #1
pfrenssen