Howto: Override $node_url in theme
My module implements template_preprocess_hook, but when it fires, the $variables['node_url'] is not set yet. I have gone through the themong guide and tried just about every preprocess hook there is and none of them has that variable set when I get control. It is set in theme.inc in template_preprocess_node, without regard as to whether or not it is already set. I even tried mymodule_preprocess_node, and it is still not set there. The problem may be because my module's weight is -2 due to a timing problem with the user module. So I am probably getting called before node.module too. So how can I change that value? -- Nancy E. Wichmann, PMP Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
The weight of modules can be found in the system table From: development-bounces@drupal.org [mailto:development-bounces@drupal.org] On Behalf Of nan_wich@bellsouth.net Sent: vrijdag 24 juli 2009 18:40 To: development Subject: SPAM --- [development] Howto: Override $node_url in theme My module implements template_preprocess_hook, but when it fires, the $variables['node_url'] is not set yet. I have gone through the themong guide and tried just about every preprocess hook there is and none of them has that variable set when I get control. It is set in theme.inc in template_preprocess_node, without regard as to whether or not it is already set. I even tried mymodule_preprocess_node, and it is still not set there. The problem may be because my module's weight is -2 due to a timing problem with the user module. So I am probably getting called before node.module too. So how can I change that value? -- Nancy E. Wichmann, PMP Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
http://drupal.org/project/util On Fri, Jul 24, 2009 at 2:22 PM, Peter Droogmans <Peter@attiks.com> wrote:
The weight of modules can be found in the system table
*From:* development-bounces@drupal.org [mailto: development-bounces@drupal.org] *On Behalf Of *nan_wich@bellsouth.net *Sent:* vrijdag 24 juli 2009 18:40 *To:* development *Subject:* SPAM --- [development] Howto: Override $node_url in theme
My module implements template_preprocess_hook, but when it fires, the $variables['node_url'] is not set yet. I have gone through the themong guide and tried just about every preprocess hook there is and none of them has that variable set when I get control.
It is set in theme.inc in template_preprocess_node, without regard as to whether or not it is already set. I even tried mymodule_preprocess_node, and it is still not set there.
The problem may be because my module's weight is -2 due to a timing problem with the user module. So I am probably getting called before node.module too.
So how can I change that value?
-- Nancy E. Wichmann, PMP
Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
-- Jim Taylor Rooty Hollow LLC, Owner jim@rootyhollow.com www.rootyhollow.com (614) 432-8609 Twitter: jalama Linkedin: http://www.linkedin.com/in/rootyhollow
Everybody has given excellent suggestions regarding how to change a module's weight, but please do note the original question, as well as Nancy's follow up. She is not asking about how to set a module's weight, and obviously knows how to do this as she altered her module's weight intentionally and for (presumably) good reason. The question is about setting one of the $variable array elements within a theme_preprocess hook. Sorry Nancy, I don't have an answer for you. It sounds as though your suspicion is correct that because your code is being called before the node module's code, it is getting overwritten at that level. Maybe you could break out your preprocess function into a separate module space so that you can keep your -2 weighting for your base module but the section that needs to run after node.module is done its business could be at an unaltered weight. Not the cleanest solution, certainly .. and it may not work in your context depending on what you are doing. Best, William On Fri, Jul 24, 2009 at 2:31 PM, Jim Taylor <jim@rootyhollow.com> wrote:
http://drupal.org/project/util
On Fri, Jul 24, 2009 at 2:22 PM, Peter Droogmans <Peter@attiks.com> wrote:
The weight of modules can be found in the system table
*From:* development-bounces@drupal.org [mailto: development-bounces@drupal.org] *On Behalf Of *nan_wich@bellsouth.net *Sent:* vrijdag 24 juli 2009 18:40 *To:* development *Subject:* SPAM --- [development] Howto: Override $node_url in theme
My module implements template_preprocess_hook, but when it fires, the $variables['node_url'] is not set yet. I have gone through the themong guide and tried just about every preprocess hook there is and none of them has that variable set when I get control.
It is set in theme.inc in template_preprocess_node, without regard as to whether or not it is already set. I even tried mymodule_preprocess_node, and it is still not set there.
The problem may be because my module's weight is -2 due to a timing problem with the user module. So I am probably getting called before node.module too.
So how can I change that value?
-- Nancy E. Wichmann, PMP
Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
-- Jim Taylor Rooty Hollow LLC, Owner jim@rootyhollow.com www.rootyhollow.com (614) 432-8609
Twitter: jalama Linkedin: http://www.linkedin.com/in/rootyhollow
William Smith wrote:
altered her module's weight intentionally and for (presumably) good reason. It's not terribly material, but the reason is because we wanted to "rescue" nodes from a user that gets deleted. The user.module does bad things before calling our module. There is an open issue about that.
It sounds as though your suspicion is correct that because your code is being called before the node module's code, Actually, I don't believe that node.module is involved at all. This is done in theme.inc.
Further, it dawned on me that the user timing issue is now actually in a separate add-on module, so I set the main module's weight to 1, so that it would run later and it made no difference. My suspicion now is that the theme.inc code runs after all the preprocess functions and there's not a lot I can do, except open an issue against D7 to have it check to see if that variable is already set before it changes it. That won't help my D6 code though. -- Nancy E. Wichmann, PMP Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
Peter Droogmans wrote:
The weight of modules can be found in the system table
I am quite aware of how to change module weight. That is not the problem. The problem is how to set my own $variables['node_url'] in a theme preprocess function. -- Nancy E. Wichmann, PMP Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
Try this: http://drupal.org/project/moduleweight Paolo Mainardi CTO Twinbit http://www.paolomainardi.com Il giorno 24/lug/2009, alle ore 20.22, Peter Droogmans <Peter@attiks.com> ha scritto:
The weight of modules can be found in the system table
From: development-bounces@drupal.org [mailto:development- bounces@drupal.org] On Behalf Of nan_wich@bellsouth.net Sent: vrijdag 24 juli 2009 18:40 To: development Subject: SPAM --- [development] Howto: Override $node_url in theme
My module implements template_preprocess_hook, but when it fires, the $variables['node_url'] is not set yet. I have gone through the themong guide and tried just about every preprocess hook there is and none of them has that variable set when I get control.
It is set in theme.inc in template_preprocess_node, without regard as to whether or not it is already set. I even tried mymodule_preprocess_node, and it is still not set there.
The problem may be because my module's weight is -2 due to a timing problem with the user module. So I am probably getting called before node.module too.
So how can I change that value?
-- Nancy E. Wichmann, PMP
Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
participants (5)
-
Jim Taylor -
nan_wich@bellsouth.net -
Paolo Mainardi -
Peter Droogmans -
William Smith