I am trying to add a CSS and JS files when a certain content type is being viewed (Drupal 6). The problem is that the code is being added to every page.
I have tried this first, included in template.php:
function phptemplate_preprocess_node(&$vars, $hook) {
$node = $vars['node'];
if ($node->type == 'mytype') {
drupal_add_css(path_to_theme() . "/css/mytpess.css");
drupal_add_js(path_to_theme() . "/javascripts/jquery.masonry.min.js");
drupal_add_js("$(document).ready(function(){
$('.node').masonry({
itemSelector: '.field-type-flexifield'
});
});",'inline');
}
}
Then I moved it out of there and placed it in node-mytype.tpl.php:
drupal_add_css(path_to_theme() . "/css/mytpess.css");
drupal_add_js(path_to_theme() . "/javascripts/jquery.masonry.min.js");
drupal_add_js("$(document).ready(function(){
$('.node').masonry({
itemSelector: '.field-type-flexifield'
});
});",'inline');
But either way it gets added to every page. How can I resolve this?