Hello,

I'm working on a website and i want to have a certain set of icons (pictures, badges, missing the right term here) and then be able to attach some or all of them to my story/page/whatever nodes.

I found this module - Node badges ( http://drupal.org/project/node_badges ) - and it looks like what i want but i'm not sure because there isnt a version for Drupal 6, only 5.

I'm using Drupal 6.

If anyone have any ideas on how i can achieve this, please post them here.

Comments

doomed’s picture

Well, i just tried Node Badges on a test Drupal 5 site and it works the way i want.

So.. does anyone know if there's something like this on Drupal 6?

Obviously i'm looking on the modules list, but there's so much stuff there...

vm’s picture

check the issue queue of the module in question to see if a port of that module has started. If not file an issue to see when a port will be available. It's possible the developer hasn't done it yet because he/she doesn't think anyone is interested.

Outside of that you could try porting the module on your own if you have the skillset. There are modules that help you do so as well as a great deal of documentation on porting modules from 5.x to 6.x in the documentation area.

dnewkerk’s picture

For Drupal 6, I think you would be better off using Flag module instead. Flag is rapidly becoming a "standard" in Drupal, and looks to be around for a long time. Flag can do everything (as far as I can tell) that Node Badges do, and quite a bit more. The basic aspects are straight-forward (which content types are included, whether the flag is per user or global - global would probably be the choice in this case, which roles are allowed to use this flag, and where the flag link/option shows up (e.g. on the node creation/edit page, and/or as an instant toggle link on the node itself).

When I look at Node Badges they are essentially Flags on a node, with a specific behavior/theming attached to them (to display a specific image). Flag module has this helpful page which shows you how to 1) Check whether the current node, comment, or user is flagged, and 2) If flagged, do something (e.g. print out an image). http://drupal.org/node/305086

Untested example in node.tpl.php for a flag you make called "badge1":

<?php
  $flag = flag_get_flag('badge1');

  if ($flag && $flag->is_flagged($node->nid)) {
    print '<img src="/files/badge1.jpg" />';
  }
?>

You don't have to understand any of that code other than: 1) the name of the flag in the first line, 2) the image to use.

Best practice is to keep PHP like that stored neatly in template.php instead of you node.tpl.php... so if you want to do that, you could replace the above code with <?php print $flag_badge1; ?> and add the following to template.php (again, not tested):

function phptemplate_preprocess_node(&$variables) {
  $flag = flag_get_flag('badge1');

  if ($flag && $flag->is_flagged($node->nid)) {
    $variables['flag_badge1'] = '<img src="/files/badge1.jpg" />';
  }
}

Anyhow hope this helps :)

doomed’s picture

Well thank you very much.

I will check this module and if i end up using it, i'll make sure to post something here.

henrijs.seso’s picture

Thanks! works. helped me a lot.

in template.php code is little different, here is what worked for me...

<? php
  $flag = flag_get_flag('flagname');
  if ($flag && $flag->is_flagged($vars['node']->nid)) {
    $vars['something'] = t('You have already placed a flagname.');
    } else {
    $vars['something'] = flag_create_link('flagname', $vars['node']->nid);
  }
?>