I want a hook that will let me conditionally add js/css to the page depending on the type of entity.
Since I am putting this in a module I cannot use a theme hook (because if the theme already defines the hook then Drupal will crash).
Ultimately, I want to do something like:
// SWTICH BY ENTITY TYPE
switch($entity_type){
case 'eform': // entity forms
drupal_add_js( $theme_path . '/scripts/ajax_forms.js');
break;
case 'view': // view pages (making this one up)
drupal_add_js( $theme_path . '/scripts/fancybox.js');
break;
}
// SWTICH BY CONTENT TYPE
switch($content_type){
case 'services':
drupal_add_js( $theme_path . '/scripts/fancybox.js');
break;
}
// SWITCH BY NID
switch($nid){
case '293': // Homepage
drupal_add_js( $theme_path . '/js/global.js');
break;
}
Right now I'm using hook_node_view
to check content type & nid. Works great for nodes, but doesn't help me with non-nodes.