Reputation: 3551
i would like to have other template for only page (in my case node/348), so i write that i must create other
page--node--348.tpl.php
but now how can add other external css and js file ? where ?
Maybe in template.php ?
Thanks a lot and sorry for my english :)
Upvotes: 0
Views: 605
Reputation: 64
You can simply add a condition in "template_preprocess_html()" function in your "template.php" as below:
<?php
function THEME_NAME_preprocess_html(&$variables) {
$arg = arg();
$nid = 348;
if ($arg[1] == $nid) {
drupal_add_css(path_to_theme() . '/css/my_style.css');
drupal_add_js(path_to_theme() . '/js/my_script.js');
}
}
?>
Upvotes: 1
Reputation: 641
Make a hook_node_view in one of your custom module, then check the node id is 348 and inject your css and js like this :
function nameOfYourModule_node_view($node, $view_mode, $langcode) {
if ($node->nid == 348) {
$node->content['#attached']['js'][] = array
(
'type' => 'file',
'data' => path_to_theme() . '/js/my_script.js',
'group' => JS_THEME,
'preprocess' => TRUE,
'scope' => 'footer',
'weight' => '999',
);
}
}
Upvotes: 1
Reputation: 1353
You can use module CSS injector and JS to custom ONLY the node that you want:
https://www.drupal.org/project/css_injector
https://www.drupal.org/project/js_injector
about js, you can create a new js and custom with "id" and "class" of your node. With css injector you can anable the changes only for the node that you want.
Upvotes: 0