1

I'm creating a view that shows all the nodes of a specific type. I'm looking to also show which of those nodes the current user is subscribed to and provide a link to subscribe or unsubscribe. Is there any way to achieve this using arguments, custom PHP field, etc?

I created an argument that filters the nodes the current user is subscribed to, but it hides all the nodes their not subscribed to, even if "Display All Values" is selected.

I'm using the Notifications module and Views 2.16 on D6.

0

For a single View of non-subscribed nodes:

  1. Using a contextual filter for NIDs, select provide default value by using PHP code.

  2. Then in the PHP code use an EntityFieldQuery to get a listing of all nodes that are subscribable. Save this array of IDs to a variable.

  3. Then use a 2nd EntityFieldQuery to get an array of all subscribed nodes for the active user.

  4. Then subtract the 2 arrays, these are all nodes able to be subscribed to by the user.

  5. use return $subscribable_nodes; to return the nodes as an array to the View.

Your view would contain a node title, and you could rewrite the node title as a link to the subscription url if you want.

  • Adding the link isn't the problem, it's more a problem of how to see if they're subscribed or not, and providing the unsubscribe link (which includes an SID - Subscription ID). I thought about having 2 different views like you mentioned, however I'm not sure how to make a view that only shows the nodes they're not subscribed to? – EJK Jun 5 '14 at 18:11
  • @EJK see my edit. – tenken Jun 5 '14 at 20:08

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.