2012-03-09 75 views
1

我在我的主題的.info中定義我的腳本在2組;這些預加載的身體和那些裝載後的文件是這樣的:Drupal打印.info腳本組分別

; Scripts in head group to load pre-body 
scripts[head][] = js/cufon.js 
scripts[head][] = js/font.js 

; Scripts in end group to load after all other html 
scripts[end][] = js/scripts.js 

有沒有什麼辦法,我認爲單獨打印出來這些?我以爲我會abble做這樣的:

<?php print $scripts['head']; ?> 
<!-- html --> 
<?php print $scripts['end']; ?> 

感謝

+0

我檢查了所有瓦爾範圍,並不能找到任何暗示腳本通過傳遞到組視圖 – DonutReply 2012-03-09 12:06:46

回答

0

至於我可以告訴什麼,我試圖做是不可能的,但它可以做的另一種方式。

創建[主題]在你的template.php _preprocess_html功能和使用drupal_add_js添加腳本與範圍,然後使用drupal_get_js檢索所有的腳本添加到每個範圍和爲$瓦爾:

// Set Scripts 
$path = drupal_get_path('theme', 'themename'); 
// pre-body scripts 
$options = array('scope'=>'scripts_head','preprocess'=>true); 
drupal_add_js($path.'/js/cufon.js',$options); 
drupal_add_js($path.'/js/myfont.font.js',$options); 
// post-body scripts 
$options['scope'] = 'header'; 
drupal_add_js($path.'/js/scripts.js',$options); 
// pass to view 
$vars["scripts_head"] = drupal_get_js('scripts_head'); 
$vars["scripts_end"] = drupal_get_js('header'); 

文檔:
drupal_add_js
drupal_get_js