0

I'm using Solspace favorites module and am looking to automatically add new entries+comments to the DB in a separate Favorites Collection to mark entries as either read or unread (fav or not fav).

Basic thinking: A “new entry” gets added by user (channel form) and after it’s all submitted, write to the Favorties table in the DB :

  • Get all members active in the last X weeks (don’t want all or guests)
  • Grab the submitted entry_id
  • Grab the Favorites collection_id (read_unread)
  • Recursively write to the favourites table in the DB (member_id, collection_y, entry_id, time_z)

Now on the front (using Favorites tag) when returning a list of entries – I can check for the existence of the entry_id and member_id - if there is a match I can visually mark that entry for that user as UNREAD (fav) or READ (not fav).

Continuing on, someone adds a comment to an entry. Need to mark it as UNREAD (new) so delete all instances and replace:

  • Delete all DB entries where the collection = Y and the entry_id = X
  • Get all members active in the last X weeks (don’t want all or guests)
  • Grab the submitted entry_id
  • Grab the Favorites collection_id (read_unread)
  • Recursively write to the favourites table in the DB (member_id, collection_y, entry_id, time_z)

A member is deleted:

  • Delete all favourites where member_id = member being deleted and collection = Y.

Members visit an entry:

  • Grab the entry_id
  • If entry_id, member_id + collection_y exists then delete it effectively marking it as READ.

This is all invisible to the user, I don’t need anything returned simply fired after add/deleting/viewing – hence I’m informed I need to build a module/Extension combo.


Am I correct in my assumptions below that these are the primary Hooks needed to get this functioning?

ADD COMMENT: comment_form_end($res)

DELETE COMMENT: delete_comment_additional($comment_ids)

ADD ENTRY: channel_form_submit_entry_end()

DELETE MEMBER: member_delete($member_ids)

VIEW ENTRY: template_post_parse($final_template, $is_partial, $site_id)

2 Answers 2

0

It looks like your on the right lines here. A single extension should be sufficient. The other option is to trigger standard Solspace Fav tags using AJAX requests but your proposed approach would be much more robust. :)

0

Ended up using the following hooks in a custom module/extension that requires Solspace Favorites:

Custom Module: markasread

{exp:readunread:markasread entryID="{entry_id}"}

Deletes the entry from Solspace Favorites table where entry_id, member_id and Collection = true.

channel_form_submit_entry_end()

Gathers active members in the last X days array, grabs entry_id + writes to Solspace Favorites module/DB for active members array.

insert_comment_end()

Same as above but DELETES all related entries in the Favourites table prior to inserting.

When members are deleted or entries deleted, Solspace Favorites takes over with its in-built routines.

Your Answer

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

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