Hope this will help you,
In Drupal 7 you can use template_preprocess_page or template_preprocess_node function for your requirement in theme template.php file as Namari suggested andwith drupal_add_css to attach the CSS file.
You cant use theme.info file to particular pages. If you add the CSS in theme.info file then the CSS will included for each page. As you want to include the CSS file for particular pages so better to use template_preprocess_node OR template_preprocess_page.
drupal_add_css : Adds a cascading stylesheet to the stylesheet queue.
/**
* Implement template_preprocess_page()
*
*/
function yourThemeName_preprocess_page(&$variables) {
if (arg(0) == 'node' && is_numeric(arg(1)) && arg(1) == 123) {//check your condition here
//you can also use $node = $variables['node']; $node is the node object where $node->nid is the node id
drupal_add_css(drupal_get_path('theme', 'theme_name') . "/cssfilename.css");
}
}
- You can also use template_preprocess_node
/**
* Implement template_preprocess_node()
*
*/
function yourThemeName_preprocess_node(&$vars) {
$node = $vars['node'];
if($vars['type'] == 'my-node-type' && $node->nid == 123 ) {// check your condition
drupal_add_css(drupal_get_path('theme', 'theme_name') . "/cssfilename.css");
}
}
- If you are checking for a node then better to use template_preprocess_node than template_preprocess_page