In our current development, running with Drupal 7, we need to let the end-user bookmark some products within a "catalog". We will use the flag module for this.

However, we would like the flag to remember not only the products, but its variants. Not only the node/entity itself, but also the "attributes" selected by the user.
i.e. : bookmark a T-shirt in such size / such color.

Is there a "drupal way" to do this ? Do I need to use an extra or different module ?

Thank you.

  • 1
    How are the attributes stored?
    – mpdonadio
    Apr 11, 2012 at 11:18

1 Answer 1


You could try some Rules trickery and save the attributes data to the users profile upon the flag action. However, I really think you will be best going down the custom module route because it is rather specific.

A very basic outline of the module would be something like the below:

  1. Create your .info file to provide Drupal the details of your custom module
  2. Create a .install file to create a db schema to contain the additional data, ensure you include a fcid row (to reference to the flag "flag_content" table).
  3. Create your .module file with function which hooks into the flag actions with appropriate if statements to refine the scope to these products. In this function you will want to save the additional "attributes" data to your new db table with a reference to the fcid to tie them up.
  4. While in your .module file, if flag exists you will also want to perform a hook_form_alter on the products to change the default values to that which has been stored in the database.

I know my answer is very brief with regards to build the module but that is a bit beyond the scope of an answer here and I think that highlights the Drupal Way for what you will need.

  • Hello WestieUK, Your answer is not so brief : It gives me some hints about what I should/could do. I will investigate in that direction, though it is still quite hazy to me.
    – Cypher
    Apr 11, 2012 at 10:01
  • Cool thanks, basically it comes down the "Drupal way" is never hack but instead extend the Flag module with another custom module. Google module creation tutorials and look at the drupal api
    – WestieUK
    Apr 11, 2012 at 10:24

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.