Posted by ChrisDill on February 12, 2013 at 6:57pm
I am wondering if there is a better way to do this that will improve performance, versus having some of these scripts listed twice for different pages. Also, should I be applying these to nodes, or would it be better on preprocess_page?
function the_dill_design_preprocess_node(&$variables) {
$node = $variables['node'];
if (!empty($node) && $node->nid == '2') {
// drupal_add_js(drupal_get_path('theme', 'the_dill_design') .'/js/jquery.easing-1.3.js');
drupal_add_js(drupal_get_path('theme', 'the_dill_design') .'/js/jquery.royalslider.min.js');
drupal_add_css(drupal_get_path('theme', 'the_dill_design') .'/css/slider.css');
drupal_add_css(drupal_get_path('theme', 'the_dill_design') .'/css/royalslider.css');
drupal_add_css(drupal_get_path('theme', 'the_dill_design') .'/css/rs-default.css');
drupal_add_js(drupal_get_path('theme', 'the_dill_design') .'/js/slider.js');}
if (!empty($node) && $node->nid == '3') {
// drupal_add_js(drupal_get_path('theme', 'the_dill_design') .'/js/jquery.easing-1.3.js');
drupal_add_js(drupal_get_path('theme', 'the_dill_design') .'/js/jquery.royalslider.min.js');
drupal_add_css(drupal_get_path('theme', 'the_dill_design') .'/css/royalslider.css');
drupal_add_css(drupal_get_path('theme', 'the_dill_design') .'/css/rs-minimal-white.css');}
if (!empty($node) && $node->nid == '5') {
// drupal_add_js(drupal_get_path('theme', 'the_dill_design') .'/js/jquery.easing-1.3.js');
drupal_add_js(drupal_get_path('theme', 'the_dill_design') .'/js/jquery.royalslider.min.js');
drupal_add_css(drupal_get_path('theme', 'the_dill_design') .'/css/animated-slider.css');
drupal_add_css(drupal_get_path('theme', 'the_dill_design') .'/css/royalslider.css');
drupal_add_css(drupal_get_path('theme', 'the_dill_design') .'/css/rs-minimal-white.css');
drupal_add_js(drupal_get_path('theme', 'the_dill_design') .'/js/animated-slider.js');
}
}
Comments
What you are doing might be
What you are doing might be made easier with the ThemeKey module. I haven't used it, myself, but it looks like you can set content-specific themes via the UI, which is much more flexible than hard coding conditions into your templates.