Posted by djdevin on December 15, 2010 at 6:54pm
1 follower
| Project: | CSS |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Issue Summary
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.
<?php
/**
* 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);
}
}
?>