0

I'm trying to make a twitter-like "following" system for a content-type I have.

Users have an entity reference to the content-type.

What I want is a user to go onto the content and click the "follow" button. The user's entity ref field would then be populated with this content and the follow button would turn to followed.

Users can follow multiple content.

Can anybody point me in the right direction for accomplishing this please?

Update

I've now got Button and Rules and am trying to set this up, however, I've immediately hit a sticking point: I can't find my content-type in Rules. Shouldn't it be entity:MyContentType?

Update 2

See my answer.

1

It turns out I was going about this the wrong way.

To create a Twitter-like follow button the best thing to use is the module Flag.

Create a Flag called "Follow Me" (follow_me)

Create a Content-pane View which has:

  • Sort Criteria: Content: Type (=MyContent)
  • Context Filters: Content: Nid
  • Relationships: Flags: follow_chapter (by current user)

This content pane then can be used with Panels.

You can then create another view with the relationship with Flags: follow_me to get a list of content followed by the user.

0

I think that you should try something like this:

You create, with hook_menu, a custom callback that responds on a path like add-follow/%content_type.

In the callback you get the %content_type variable, so you can load the user with user_load and add the reference to the content type, and then save the user.

3
  • Hi, thanks for the response. I'm very new to Drupal so forgive my ignorance. Are you suggesting that I edit the pages' php? – dav_i Sep 16 '12 at 20:57
  • in the tpl you should have something like this: if ($field_booelan['und'][0]['value'] == 1) { print $field_image;}. But it depends on field name, if you have i18n and other things. However the node.tpl.php is well commented :) – arrubiu Sep 17 '12 at 6:07
  • Thanks! Okay, I'll look into this. Is there a way to do this by existing modules (i.e. UI based) though? – dav_i Sep 17 '12 at 8:23

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.