2

I have created two flags using the Flag module and they are placed on my custom content type, 'Challenge'. Both the flags can only be flagged but not unflagged. The first flag is "Accept". The second flag is "Complete". These two flags i have created normally through the UI. However to display them in panels, i have used the following code in a custom text area in panel as flags are not displayed automatically there.

<div id="accept-flag">
<?php 
   print flag_create_link('flag1', %node:nid); 
?>
</div>
<div id ="complete-flag">
<?php
  print flag_create_link('flag2',%node:nid);
   ?>
</div>

This displays both the flag on my Panel Page. However, my use case is something different. At first only, the "Accept" flag should be visible. Then, when the user clicks on "Accept", then only the other flag, "Complete" should appear. Any hints on how to achieve this. I have also tried using Rules, giving the event: A node has been flagged and then the action for a new flag. It does not work. Then i tried using flag actions as well, i.e., on flagging of first flag, display another flag.It does not work. Any ideas, suggestions are appreciated.

Thanks

Edit

i thought of a way to do this using JavaScript and css. When the first flag is visible, the second wont show. The code i am using is :

if($("#accept-flag").is(":visible")){
    $("#complete-flag").css('display','none');

This i have placed inside js/script.js in my theme folder.

(function ($, Drupal, window, document, undefined) {

if($("#accept-flag").is(":visible")){
    $("#complete-flag").css('display','none');
}

})(jQuery, Drupal, this, this.document);

When i view the page source, the script is loading however both the flags are still showing.

Please advice

Thanks again

1 Answer 1

1

Since you are using Panels, you could create two variants. One of them would have a selection rule that says only select this variant if "accept" is flagged, and in it your display only the complete flag. The other variant wouldn't need selection rules (but would need to be placed under the first one in the variants order) and it would display only the complete flag.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.