I'm in the process of building my 1st extension (oi!) and I need to find a hook that allows me to fire off a routine when a member visits a single entry page.

I have listing pages and single view pages - I only need the routine to fire when viewing single entry pages NOT listing pages.

The list of hooks is extensive but I cannot seem to find one that fits.

The broad picture is:

I have an extension that relies on hooks to update the DB when ever a member adds a reply or adds a new entry. It gets a list of active users in the last 2 weeks, adds their member_id to Solspace 'Favorites' table in the DB in a separate collection.

This is working as expected as I can call the 'fav' module to mark entries on a list view page as 'unread'.

What I now need to do is when a user visits an entry, remove their member_id from the 'fav' table/collection. Someone adds a new comment/entry, it re-adds their member_id and marks the entry as 'unread' once again.

I believe the best approach is to make a module that I can call in the template code within the entry template to remove the user from the 'fav' DB table.

  • Why not a plugin? You can fire it on template level.
    – Sobral
    Commented Feb 3, 2015 at 0:16
  • General consensus is to use a module as I'll be interacting with the DB. So many ways to skin a cat. Commented Feb 3, 2015 at 0:23
  • 1
    Can you update your question to include the broad element you're trying to accomplish? I could answer your current question directly, but have no way of knowing whether or not I'm giving you and answer you really need. Commented Feb 3, 2015 at 0:58
  • Question updated thx. Commented Feb 3, 2015 at 3:01

1 Answer 1


Crelate a plugin containing single function, say, function_name. The plugin will accept member_id of logged in visitor


and ID of entry being viewed, passed as parameter


In this function, if member_id is not 0 (i.e. member is logged in), perform a check against your database table and if necessary, perform an update.

(Since there is DB interaction, someone might say you should create module, but since this is your first EE add-on and it has no settings, keep the things simple).

Then, in your single entry template, inside channel entries tag, call the plugin like this:

{exp:plugin_name:function_name entry_id="{entry_id}"}
  • Thx Yuri, I've marked this as correct – it's the simplest way to achieve it, I just chose another route :) Commented Feb 4, 2015 at 10:16

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.