What I'm trying to do is parse the custom field data sent to the entry_submission_end hook.

Here's what I was able to dissect out of the channel entries module, but what I'm confused is how to instantiate an instance of Channel for use by the template parser library.

public function entry_submission_end_hook($entry_id, $entry_metadata, $entry_data) 
    $tag_to_parse = "{page_uri}";
    $channel = new Channel; // do I include mod.channel.php and instantiate this, if so how?

    $parser = $this->EE->channel_entries_parser->create($tag_to_parse);
    return $parser->parse($channel, $entry_data);

Ideally this should return the URI of the page for the entry saved via entry_submission_end.

Alternatively if there is another way to run logic on parsed tag data from a given entry upon saving or creating said entry I'm all ears.

  • Why the costly parse? If it's a specific fieldtype or logic part, can't you just lookup what the method does and replicate? e.g. if it's a specific solution and not a generic add-on, that is. e.g. 2. If you just want the page_uri, then lookup how it is constructed, instead of shooting the template parse howitzer.
    – GDmac
    Commented Mar 21, 2014 at 7:54

1 Answer 1


Here's what I was able to come up with. I did tap into the channel entries module. This seems excessive since in my scenario it's just taking a single field of text and parsing it but at least it fully implements whatever classes EE has.

I hope this helps someone.

public function parse_tagdata($entry_id, $tagdata)
    require_once PATH_MOD.'channel/mod.channel.php';

    ee()->TMPL->tagdata = $tagdata;
    ee()->TMPL->tagparams['dynamic'] = "no";
    ee()->TMPL->tagparams['entry_id'] = $entry_id;
    ee()->TMPL->site_ids = array($this->config->item('site_id'));

    $vars = ee()->functions->assign_variables($tagdata);
    ee()->TMPL->var_single  = $vars['var_single'];
    ee()->TMPL->var_pair        = $vars['var_pair'];

    $channel = new Channel;
    $channel->query = ee()->db->query($channel->sql);               

    return $channel->return_data;

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.