Drupal - if content type in views block tpl or node #drupal
<?php //set var to identify content type
$node_type = $row->_field_data['nid']['entity']->type;
?>
<?php //check for content types
if ($node_type == 'CT_NAME' || $node_type == 'CT_NAME_OTHER'):
?>
Do something...
<?php endif; ?>
<?php //check for node id
if ($node->nid == 39):
?>
Do something...
<?php endif; ?>
/*
* http://drupal.stackexchange.com/questions/12725/attach-a-script-to-a-particular-node-id-or-view
*/
<?php
// Node ID:
function THEMENAME_preprocess_node(&$variables) {
if ($variables['nid'] == 'INSERT_NODE_ID') {
// include javascript
drupal_add_js(path_to_theme() . 'INSERT_SCRIPT');
}
}
// View:
function THEMENAME_preprocess_views_view(&$variables){
if ($variables['name'] == 'INSERT_VIEW_MACHINE_NAME') {
// include javascript
drupal_add_js(path_to_theme() . 'INSERT_SCRIPT');
}
}
?>