Question

I want to add a logo (CCK image field) to the group nodes and show it when users visit that group.
Is there any module for that?

Was it helpful?

Solution

I write this module to render custom logo for each Organic Group:

function og_logo_block($op = 'list', $delta = 0, $edit = array()) {
    if ($op == "list") {
        $block = array();
        $block[0]["info"] = t('OG Logo Block');
        return $block;
    } else if ($op == 'view') {
        global $theme;
        global $node;
        $block['subject'] = '';
        $settings = theme_get_settings($theme);
        if (($node = og_get_group_context()) && node_access('view', $node)) {
            $block['content'] = l('<img alt="' . $node->title . '" title="' . $node->title . '" src="' . base_path() . $node->field_logo[0]['filepath'] . '" />', "node/$node->nid", array('html'=>true));
        } else if ($settings['default_logo']) {
            $block['content'] = '<img src="' . base_path() . 'sites/all/themes/' . $theme . '/logo.png" alt="this is logo" />';
        } else {
            $block['content'] = '<img src="' . base_path() . $settings['logo_path'] . '" alt="this is logo" />';
        }
    }
    return $block;
}

OTHER TIPS

Spaces module could do this.

There is no such module as such, but I did it earlier some time back. You will have to attach the logo to the node on node load.

I generally did it from the theme level, following these steps:

  • check if page is a group page
  • if it is a group page, then replace the default logo with group logo contained in the node as $node->group_logo

I don't use OG so I can't explain in detail however the strategy would be to create a template.php file in the theme folder. In that file create a template preproses function that adds a class to the OG node title with some markup. The class should be prefaced with logo- and then some PHP code to add a unique identifier for the node. Because there are certain rules for characters to use in a class name, it's important to pass the string through some code that will clean it up. Then in the CSS file use the class to add a background image to the element. Since we are on the subject of OpenAtrium, this is how they add all the icons to menu items.

It's entirely possible that using the Zen theme or using something like the Context module that the particular OG as a unique body class. For example, on groups.drupal.org the Location and Mapping group has og-context-303 added to every node within that group. Then the solution is to add a CSS selector like body.og-context-303 h1.title {[image type stuff here], background:url(images/map-icon.png)}. If there are only ten groups then there are only ten lines of CSS to add.

Just add a regular image field using CCK or, under Drupal 7 and higher, the image field implemented by the Fields module that comes with the Drupal core modules.

Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange
scroll top