Is there a way to have a flag work trough two seperate links. A 'Yes' link to flag and a 'No' link to unflag instead of one link (as it is now) to flag and unflag.

Comments

mooffie’s picture

Status: Active » Fixed

Yes, it's possible: theme the "link" Flag shows.

In the theme folder there's "flag.tpl.php". Change it to your liking (after copying it to your theme folder). See the README.txt there. When I say "link" it's in a loose sense: the .tpl can contain anything: button(s), image(s), span(s), link(s), whatever. In your case you probably want to have one <span> (for the disabled choice at that moment) and one <a> (for the enabled one). But keep everything inside the "wrapper" you'll see there.

(I don't see this as a valid feature request because different people may have different ideas as to how they want the link to show, and since we can't satisfy everybody we provide a generic solution, which is ultimately flexible.)

Michsk’s picture

Great support. Thanks.

    <?php print $flag->title; ?>:
    <?php if($last_action == 'flagged'): ?>
      <a href="#" class="availible ava-yes ava-active round"><?php print t('Yes'); ?></a>
      <a href="<?php print $link_href; ?>" title="<?php print $link_title; ?>" class="availible ava-no <?php print $flag_classes ?>" rel="nofollow"><?php print t('No'); ?></a>
    <?php else: ?>
      <a href="<?php print $link_href; ?>" title="<?php print $link_title; ?>" class="availible ava-no <?php print $flag_classes ?>" rel="nofollow"><?php print t('Yes'); ?></a>
      <a href="#" class="availible ava-yes ava-active round"><?php print t('No'); ?></a>
    <?php endif; ?>

Status: Fixed » Closed (fixed)

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

scott weston’s picture

Thanks, Iasac... Very, very helpful!

Using Iasac's code as a starting point, I made a few tweaks which others might find helpful:

  • I'm using a javascript toggle for the flag, so I included the flag-wrapper class.
  • It also includes the $after_flagging check so the after flagging/unflagging message appears
  • I made the selected option only text (not a link pointing to #), so that users wouldn't feel compelled to click the already-selected option
<span class="flag-wrapper flag-<?php echo $flag_name_css; ?>">
<?php print $flag->title; ?>:
 
    <?php if($last_action == 'flagged'): ?>
      <span class="availible ava-yes ava-active round"><?php print t('Yes'); ?></span> | 
      <a href="<?php print $link_href; ?>" title="<?php print $link_title; ?>" class="availible ava-no <?php print $flag_classes ?>" rel="nofollow"><?php print t('No'); ?></a>
    <?php else: ?>
      <a href="<?php print $link_href; ?>" title="<?php print $link_title; ?>" class="availible ava-no <?php print $flag_classes ?>" rel="nofollow"><?php print t('Yes'); ?></a> | 
      <span class="availible ava-yes ava-active round"><?php print t('No'); ?></span>
    <?php endif; ?>
  <?php if ($after_flagging): ?>
    <span class="flag-message flag-<?php echo $last_action; ?>-message">
      <?php echo $message_text; ?>
    </span>
  <?php endif; ?>
</span>