2012-03-09 76 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