Suppose I have a template with a channel entries tag on it. I need to execute an extension method during a hook that runs before the channel entries query takes place. It doesn't matter what parameters are passed to the hook, I just need to execute some logic any time entries are going to be queried.

  • I'd be interested in seeing how you did the core hack and created a new hook. Apr 4, 2014 at 9:34

2 Answers 2


It sounds like the channel_entries_row hook would do it? http://ellislab.com/expressionengine/user-guide/development/extension_hooks/module/channel/index.html#channel-entries-row

  • I believe that hook executes after the channel module runs the query and executes once per entry in the results. Jan 30, 2013 at 18:42
  • channel_entries_query_result gets called once per entries tag, and the tag contents are not parsed yet. edit: but you said BEFORE the query takes place, so disregard this comment. Jan 30, 2013 at 18:49
  • 1
    You might be able to use template_fetch_template and use $row['template_data'] which I think has the full unparsed template contents? You can't return a modified version of template_data though. Then you could use a regex to see if an entries tag exists: preg_match('/{exp:channel:entries(.*)?(?:}.*){\/exp:channel:entries}/s', $row['template_data'], $matches); Jan 30, 2013 at 18:54
  • 1
    It looks like I am just going to go with template_fetch_template because I don't think there are any channel module hooks that execute prior to the query. Jan 30, 2013 at 18:55

We should make a feature request. I need a hook that runs before the query is ran too. To my knowledge, such hook does not exist.

  • 1
    At first, we used the template_fetch_template hook but it wasn't a good kludge because then our hook logic would execute once for every embed which was overkill. In the end, we went with a core hack and created a new hook. Feb 22, 2013 at 21:12
  • Is there somewhere we can submit feature requests to EllisLab? Can't seem to find one.
    – notacouch
    Apr 5, 2013 at 18:57

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.