Closed (fixed)
Project:
Zen
Version:
6.x-1.x-dev
Component:
PHP Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
5 Feb 2009 at 21:50 UTC
Updated:
16 Dec 2010 at 22:39 UTC
How about adding this to phptemplate_preprocess_page() ?
It adds a link to a stylesheet on a per-page basis if the stylesheet exists.
// 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";
}
Now all a user would need to do to include a new stylesheet for a page would be to create a new stylesheet with the correct name and it gets automatically included on that page.
Comments
Comment #1
authentictech commentedThis looks like a good feature and certainly fits in with what I was looking for today. Has anyone had the chance to test it?
I'm not sure about having it included in the Zen theme by default as it could be beyond the remit of a starting theme, but mentioning it in the Zen manual as potential customisation would be a bonus (if it was tested and shown to work well).
Comment #2
authentictech commentedComment #3
akalata commentedClosing old/inactive requests.