6

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. – Charlie Gorichanaz Apr 4 '14 at 9:34
1

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. – Benjamin Kohl Jan 30 '13 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. – Brian Litzinger Jan 30 '13 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); – Brian Litzinger Jan 30 '13 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. – Benjamin Kohl Jan 30 '13 at 18:55
1

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. – Benjamin Kohl Feb 22 '13 at 21:12
  • Is there somewhere we can submit feature requests to EllisLab? Can't seem to find one. – notacouch Apr 5 '13 at 18:57

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.