Hi,

I want one flag to disappear if the same node is flagged with another flag. Means: I have flag A and flag B for the same content type and want Flag A to disappear if the node is already flagged with flag B and the other way around - flab B should disappear if it is flagged with flag A. IMPORTANT: I placed the links to the flags in the way like it is mentioned here http://drupal.org/node/295383 so I just need a PHP snippet to check if a node is flagged.

How would be the PHP code to check this in a node-contenttype.tpl.php file??? I need something like

<?php
global $user;

if(
$user->uid == $node->uid)
    print flag_create_link('flag_name', $node->nid); 
?>

where I check if a user wrote this node as I want this flagging just be possible for users who wrote the node. I am not that fit with PHP and would be very grateful if someone could help me...

Greez,
Tobias

Comments

quicksketch’s picture

See #474410: Display image on node teaser/body if certain flag is checked, which is basically the same request and includes some sample code that does what you're wanting.

tobiberlin’s picture

Thank you very much, that helped me... I used a if-else:


<?php
$flag = flag_get_flag('flag_A');
if ($flag->is_flagged($node->nid))
 
{ echo "&nbsp;"; }

else {

global $user;

if($user->uid == $node->uid)
    {print flag_create_link('flag_B', $node->nid);}
     }
?>

Now the link for flag B just appears if flag A is unflagged

quicksketch’s picture

Status: Active » Fixed

Great, that's the intended behavior right? If so, then this issue is fixed.

Status: Fixed » Closed (fixed)

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