作爲更具體採取對這個問題:Drupal的模塊,檢查是否節點類型
drupal jQuery 1.4 on specific pages
如何檢查,一個模塊內,一個節點是否是某種類型才能夠對節點做某些事情。
感謝
上下文:
我想,這樣,而不是「my_page」工作它的工作節點類型,以適應這個代碼。
function MYMODULE_preprocess_page(&$variables, $arg = 'my_page', $delta=0) {
// I needed a one hit wonder. Can be altered to use function arguments
// to increase it's flexibility.
if(arg($delta) == $arg) {
$scripts = drupal_add_js();
$css = drupal_add_css();
// Only do this for pages that have JavaScript on them.
if (!empty($variables['scripts'])) {
$path = drupal_get_path('module', 'admin_menu');
unset($scripts['module'][$path . '/admin_menu.js']);
$variables['scripts'] = drupal_get_js('header', $scripts);
}
// Similar process for CSS but there are 2 Css realted variables.
// $variables['css'] and $variables['styles'] are both used.
if (!empty($variables['css'])) {
$path = drupal_get_path('module', 'admin_menu');
unset($css['all']['module'][$path . '/admin_menu.css']);
unset($css['all']['module'][$path . '/admin_menu.color.css']);
$variables['styles'] = drupal_get_css($css);
}
}
}
謝謝。
謝謝我用上下文更新了我的問題。 – Mark 2010-06-07 15:19:31
然後我的第一個代碼示例應該讓你朝着正確的方向 – Kevin 2010-06-07 16:26:05