0

I want to create a flag which can be used to bookmark multiple content. In my site i am allowing user to publish their own articles. Each article has a genre type taxonomy. I want to make a flag which will be displayed below the article content page, and on clicking on the flag the user will be able to subscribe to both the article and its genre (taxonomy). I tried using flags for taxonomy but that flag does not appear on the bottom of every content page. Instead it appears on the view when we seea ll the content related to a genre. I am using drupal 7. Thanks for your help.

1

This is possible but you need to use the Flag API hooks and the Flag Actions module. Enable the Flag Actions module that comes with the Flag module if you haven't already. You will now have an option under the flag tab on the triggers page to fire off an action based on whenever anyone flags something with your flag.

/admin/structure/trigger/node

None of the actions available will match what you are trying to do but you can create one. In your site module (or create one), you need to just define two functions: the action definition hook, and the function that fires.

For the action definition, you're using hook_action_info() to declare a function

/**
 * Implements hook_action_info().
 */

function YOURMODULE_action_info() {
  return array(
    'MYFLAG_action' => array(
      'label' => t('Action to take after MYFLAG is flagged'),
      'type' => 'node',
      'configurable' => FALSE,
      'triggers' => array('any'),
    ),
  );
}

and then you want to create the function to trigger your taxonomy flag

/**
 * Action function for report action
 *
 * @see action_example_action_info()
 */
function MYFLAG_action(&$entity, $context = array()) {

   // Use the name of the taxonomy flag here
   $MYFLAG = flag_get_flag("name of taxonomy flag");

   // add logic to find your taxonomy_id, probably from the node object available through the $entity variable

   $taxonomy_id = ( SOME OPERATION )

   //execute the flag operation
   $flag->flag('flag', $taxonomy_id);  


}

Finally, flush cache and go back to your triggers page to associate the trigger of flagging a node with your new custom action.

0

if you can write code in a custom module or in a template, you could use flag_create_link($flag_name, $content_id) to make it appears where you whant.

for taxonomy, here the how to.

  • the problem is I dont knw how to do theming and moduling in drupal as yet. I am only a beginner. Is there no module already present for it which can be directly enabled. Thanks. appreciate your help. – Akshay Kumar May 1 '13 at 19:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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