Needs review
Project:
CSS
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
15 Dec 2010 at 18:54 UTC
Updated:
15 Dec 2010 at 18:54 UTC
Thought this might be useful - apply CSS to anything in the context of an organic group if CSS is set on the group node.
Tested and working on my end, using hook_preprocess_page since a view, panel or some other non-node page might be in the context of a group.
/**
* Implementation of hook_preprocess_page().
*/
function css_og_preprocess_page() {
$group = og_get_group_context();
if (variable_get("css__{$group->type}", 0) && !empty($group->css_css)) {
$attributes = array(
'type' => 'text/css',
'rel' => 'stylesheet',
'media' => 'all',
'href' => url('css/get/' . $group->nid),
);
$link = '<link'. drupal_attributes($attributes) .' />';
$css = "\n//--><!]]>\n"."</script>\n".
$link . "\n".
'<script type="text/javascript">'."\n<!--//--><![CDATA[//><!--\n";
drupal_add_js($css, 'inline', 'header', FALSE, FALSE, FALSE);
}
}