Closed (outdated)
Project:
Drupal core
Version:
7.x-dev
Component:
base system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
28 May 2010 at 22:59 UTC
Updated:
5 Apr 2013 at 02:30 UTC
Jump to comment: Most recent
Comments
Comment #1
hass commentedComment #2
damien tournoud commentedThis is actually a documentation issue. This parameter is not (and has never been) linked with theme 'regions'.
The text should read:
Comment #3
hass commentedHow to make "page_top" a scope for adding JS code to this scope?
Comment #4
hass commentedhttp://drupal.org/node/171205 have nothing about scopes...
Comment #5
hass commentedAlso the same in here where scope is also named a region...
Comment #6
damien tournoud commentedA theme that would want to define a new 'scope' (but I guess this is totally useless), simply has to call drupal_add_js($scope) at the correct place.
We should simply fix the documentation and only mention 'header' and 'footer', because those are the only two actually useful.
Comment #7
hass commentedIt would be much more better if it would work as it's currently documented. I really need to be able to add js code to regions.
Comment #8
damien tournoud commentedYou can still hook_page_alter() your way in, but I doubt it is really desirable for your module to add js code to regions.
Comment #9
hass commentedSeems also not working, see #812606: Cannot add inline JS code to regions via hook_page_alter()
Comment #10
marcingy commentedComment #11
socialnicheguru commentedSorry to re-open but it is not clear if this has actually been resolved.
#2 states:
scope: The location in which you want to place the script. Possible values are 'header' or 'footer'. If your theme implements different scopes, you can also use these. Defaults to 'header'.
scope options like header and footer in hook_js_alter do not coincide with the theme.
good explanation is given here: http://drupal.org/node/330985#comment-1095483:
The scope "header" does not add to the "header" region, it actually adds to "html_head"; proper region name would probably be "head".
The scope "footer" does not add to the "footer" region, it actually adds to "closure"; proper region name would probably be "closure".
Closure has been removed in Drupal 7 in favor of hidden regions page_top, page_bottom. http://drupal.org/update/modules/6/7#hook_footer explains the use of hidden regions.
So js added to footer used to goto closure and somehow ends up at the bottom of the html page.
Does anyone know how and which variable exactly?
Scope options in hook_js_alter do not coincide with hidden regions. $page['page_top'] or $page['page_bottom'] as described in http://drupal.org/update/modules/6/7#hook_footer, are not accessible by hook_js_alter.
So how can I define a scope of page_bottom for js? $page is not a variable for hook_js_alter.
How does this relate to adding inline js using hook_page_alter?
I have a related issue:http://drupal.org/node/1945222
Comment #12
petergus commentedIm also wondering this... For some reason
scrope => footerworks butscope => headerdoes not! strange..maybe because header means where it is defined in
print $scripts?can we define our own scopes somewhere?
Comment #13
mikeytown2 commentedFYI:
AdvAgg 6.x can do this and I believe AdvAgg 7.x can do this.