Screen shot 2011-01-06 at 2.32.34 PM.png

Code per Node makes it possible to add custom CSS and Javascript per node, per content type, per block, and globally. The code is stored in the database, but served from the file system. It also supports syntax highlighting with CodeMirror.

CPN was covered by a recent webinar by Mediacurrent: http://www.mediacurrent.com/blog/webinar-code-node (this is also mentioned in DrupalEasy podcast 120)

Installation

After the usual module installation, you should:

  1. Install CodeMirror (tested with v3.20) to sites/all/libraries/codemirror.
  2. Turn on syntax highlighting at admin/config/content/cpn (D7) or admin/settings/cpn (D6).
  3. Configure the global settings at admin/config/content/cpn (D7) or admin/settings/cpn (D6).
  4. Set appropriate permissions at admin/people/permissions (D7) or admin/user/permissions (D6).
  5. Enable per-content type settings at admin/structure/types/manage/[node-type] (D7) or admin/content/node-type/[node-type] (D6).

Additional Notes

Related Modules

This module provides functionality similar to other modules. I'll outline the differences, as I best understand them:

  • CSS Injector: doesn't support Javascript (though JS Injector does); doesn't provide fields for CSS per-node, though it may be possible in the admin settings via configurable rules (and may get implemented in #437006: Added CSS fieldset for node/edit); doesn't support CSS per-block.
  • CSS: doesn't serve the CSS from the file system; doesn't support Javascript; doesn't support CSS per-block.
  • Context Add Assets: doesn't support editing CSS or Javascript through the website; association of external assets happens in the backend Context module; doesn't support per-block assets.
  • Inline CSS Checker: use this to find any content that has inline CSS in text fields.

Credits

Originally build by joelstein, Rob Loach contributed on the D7 port. Currently maintained by Damien McKenna.

Continued development is sponsored by Mediacurrent.

Project Information

Downloads