Là một mất cụ thể hơn về vấn đề này:mô-đun drupal, kiểm tra xem loại nút
drupal jQuery 1.4 on specific pages
Làm thế nào để kiểm tra, bên trong một module, có hay không một nút là một loại nhất định để có thể làm một số thứ nhất định cho nút.
Cảm ơn
Bối cảnh:
Tôi đang cố gắng để thích ứng với mã này để thay vì làm việc trên 'my_page' nó hoạt động trên một loại nút.
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);
}
}
}
Cảm ơn.
Cảm ơn tôi đã cập nhật câu hỏi của mình với ngữ cảnh. – Mark
Sau đó, ví dụ mã đầu tiên của tôi sẽ giúp bạn đi đúng hướng – Kevin