J
J
jelezo2015-11-19 20:00:49
Drupal
jelezo, 2015-11-19 20:00:49

How to add a script to the head of a specific node type?

there is a script:
<script src="http://site.ru/script.js"></script>
How to add it to the head of a certain type of node?
Let's say that the script is connected only for nodes that are of type news.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Drupby, 2015-11-19
@jelezo

In the theme's template.php:

function YOURTHEME_preprocess_node(&$vars) {
  if ($vars['node']->type == 'news') {
    drupal_add_js(/* указать свой скрипт */);
  }
}

Learn more about using drupal_add_js

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question