By daemon on
I would like to pass a custom variable declared and set from node.tpl.php to be used in page.tpl.php, how can this be done? I have been searching all the documentation and forum posts already.
I would like to pass a custom variable declared and set from node.tpl.php to be used in page.tpl.php, how can this be done? I have been searching all the documentation and forum posts already.
Comments
I think that depends on the
I think that depends on the variable, where it comes from, how it was calculated or generated... Can you be more specific?
I am working on a theme hack
I am working on a theme hack to allow comments and the comment form to placed anywhere in page.tpl.php, however, in order for things to function without break all the JavaScript I have to call a drupal_get_form function inside node.tpl.php or under template_preprocess_node.
Here is a snippet of the code in question and the variable I need to have passed to page.tpl.php.
Why can't you call that in
Why can't you call that in page.tpl.php?
Still figuring out how it
Still figuring out how it works to be honest, it does not have the intended effect when I call it from page.tpl.php.
What if you try adding it in
What if you try adding it in hook_preprocess_page()?
It doesn't trigger what I
It doesn't trigger what I need.
To explain, I'm turning disabling the comments in my node through the following (or the equivalent in the preprocess):
Then I have to re-create the form on page.tpl.php (in the preprocess in this case)
However, in doing so, all the JavaScript related to the form (Live Module JS, Comment-Notify Module JS, Textarea Resize JS, etc...) no longer appears. Through trial and error I noticed that if I run the following in node.tpl.php:
However, the side effect is that the form are
By the time page.tpl.php is
By the time page.tpl.php is processed, the header section variables (e.g., $scripts) are already set.
I think you need to act before the theme layer is invoked at all; hence a custom module.
Implement hook_nodeapi('view') and the render the comment form as a property of the $node object. ($node->comment_form) Then the form will be available to you in page.tpl.php as $vars['node']->comment_form .
Or else, you may be able to force $scripts to be re-populated in theme_preprocess_page after you've rendered the comment form there, e.g.,
But this is probably less efficient, since the scripts will be collected twice.
BTW, I just figured out that
BTW, I just figured out that Drupal 7 will fix this issue by adding $scripts , etc, later in the theme life-cycle.