Call theme closure function in process_page, not preprocess_page
kkaefer - July 4, 2009 - 14:54
| Project: | Drupal |
| Version: | 7.x-dev |
| Component: | theme system |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
This patch moves the call to theme('closure') into process_page so that it runs later in the theming flow. This is necessary because other functions might add JavaScript to the footer scope which is not output correctly when closure is called that early.
| Attachment | Size | Status | Test result | Operations |
|---|---|---|---|---|
| closure.patch | 751 bytes | Idle | Passed: 11863 passes, 0 fails, 0 exceptions | View details |

#1
To make things a little bit clearer. In HEAD's current state you can't add javascript to $closure (footer scope) using #attached_js.
Like this for example (change in toolbar.module):
$build = array('#theme' => 'toolbar',
'#attached_js' => array(
array('data' => $module_path . '/toolbar.js', 'scope' => 'footer', 'weight' => JS_LIBRARY + 2),
array('data' => 'misc/jquery.cookie.js', 'scope' => 'footer', 'weight' => JS_LIBRARY + 2),
),
'#attached_css' => array(
$module_path . '/toolbar.css',
),
);
This patch fixes the problem as advertised.
I feel bold so I will RTBC after bot gives it a run.
#2
Mind giving a look at #469242: Move <head> outside page.tpl.php ? Seems really related.
#3
I have checked the code syntax and all looks good. The bot is happy.
Does anyone think this needs a test to ensure that closure is called at the right time?
#4
It may touch the problem in the process, but I can't test if it will fix this problem because it needs a re-roll first.
#5
Crossposted.
I don't have an answer for the question.
#6
#469242: Move <head> outside page.tpl.php hit a dead end it seams so this should go in.
drupal_render has no test for #attached_css or #attached_js so if a test is needed it should be a new issue and not hold this one.
#7
I opened #522782: Test #attached for tests.
#8
No more dead end for #469242: Move <head> outside page.tpl.php. I suggest waiting on this a bit.
#9
#519782: Change $closure to become a hidden region like page_top got committed. This is no longer an issue.