I propose to add per-page CSS stylesheet support in Drupal. It should work like this: Every node editing form will have an "add stylesheet" option where the user can add some custom CSS. This CSS will be added as an additional stylesheet in the head section inside style tags, in addition to the Drupal theme. It should be able to override the theme. This will be just for one page, not for the site. Obviously it should be for the node page, not for the frontpage listing.

Comments

Anonymous’s picture

Priority: Critical » Normal
coreb’s picture

Version: x.y.z » 6.x-dev
Component: base system » node system

Moving out of the x.y.z queue into 6.x-dev. I would mark this "won't fix", but I'll let someone who dips their hands in the code make that decision.

Crell’s picture

Status: Active » Closed (won't fix)

I agree this could be a nice feature, but it's quite possible to add this as a contrib module. No need to put it in core.

petrocket’s picture

you can add something like this to your phptemplate_preprocess_page() function:

  // Add page stylesheets.
  if($vars['is_front']) {
    // special style sheet for home page
    $cssFilename = drupal_get_path('theme', $GLOBALS['theme']) . '/css/home-page.css';
  }
  else {
    // all other pages get a style that looks like page-node-1.css or page-node-add.css etc.
    $path = drupal_get_path_alias($_GET['q']);
    $cssFilename = drupal_get_path('theme', $GLOBALS['theme']) . '/css/'.phptemplate_id_safe('page-'. $path) . '.css';
  }
  
  if(file_exists(getcwd() . '/' . $cssFilename)) {
    $vars['styles'] .= '<link type="text/css" rel="stylesheet" media="all" href="'.$cssFilename.'?L" />' . "\n";
  }