Needs work
Project:
Code per Node
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
16 Feb 2012 at 00:34 UTC
Updated:
29 Mar 2013 at 20:21 UTC
Haven't used this module yet to solve the problem, but wanted to suggest my current solution as an addition.
function cpn_preprocess_node(&$vars) {
$identifier = $vars['node']->nid;
if (module_exists('i18n')) {
$identifier = $vars['node']->vid;
}
$file = path_to_theme() .'/css/nodes/'. $identifier .'.css';
if (file_exists($file)) {
$age = date("U", filemtime($file));
drupal_add_css($file.'?v='.$age , 'theme', 'all', FALSE);
}
}
Comments
Comment #1
doublejosh commentedI added the age addition when I posted this without testing, when in fact you can't include query strings in drupal_add_css, drupal_add_link, etc. Additionally, fixed the problem of multiple include attempts with a static flag.
Comment #2
doublejosh commentedHere's a content type one too. Though if you use Adv Agg the bundler will do this for you.
Comment #6
doublejosh commentedCorrected a problem with the translated identifier, added node specific JS, and cleaned up a bit.
Realize that one goal of this module is to remove the node specific CSS/JS away from the theme, but sometimes it's appropriate.
My use case is having to create various one-off pages for marketing purposes.
Comment #7
doublejosh commentedIn case anyone stumbles upon this, here's another solution: http://drupal.org/project/context_addassets
Comment #8
damienmckennaIf this is to be included then it needs to be handled differently:
Comment #8.0
damienmckennaremove debug line