Case scenario: The node author can set a global flag, like "Help wanted", to signal others that he welcomes input on the node content. The flag itself is shown only to the node author. And if the node has been flagged, it's supposed to output something like "The author welcomes your help." -- if it's unflagged, nothing is shown.

I did dig through the available documentation but was unable to find any hint on how to accomplish this. So I was wondering, if there's a way to use the Flag module for this purpose.

Kind regards,

-- jan

Comments

mooffie’s picture

Status: Active » Fixed

The flag itself is shown only to the node author

Until #285237: Ability to disallow a flag/unflag operation is settled, you have two options:

1. Tick only "show checkbox on node form" (in the flag settings page). Only the author will see it because only he can edit the node. Don't tick "show link on page" or "show link on teaser".

2. You can place the link on the page yourself. Wrap the call to flag_create_link() in a PHP condition that checks whether the current user is the author of the node.

And if the node has been flagged, it's supposed to output something like "The author welcomes your help."

Do the following in 'node.tpl.php':

$flag = flag_get_flag('help_wanted') or die('no "help_wanted" flag defined');

if ($flag->is_flagged($node->nid)) {
  print "The author welcomes your help.";
}

This is explained in a new handbook page:

The Flag API

neurer’s picture

Works like a charm, cheers!

PS. Wasn't aware that the handbook had undergone such huge changes since I last checked a week ago or so -- thanks for the hint.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.