3

Is there any way to parse tags exp:channel in a third party module. In my custom module I need to call exp:channel, but need to get entry ids before final rendering of the module. Can anyone know how to parse exp calls before rendering the module?

Thanks

6

While you can't actually parse the tag using your custom module, you can pass parameters to the channel module and run it. Here's a code sample:

function your_module_method()
{
    // Set the parameters for the channel:entries tag
    $this->EE->TMPL->tagparams['entry_id'] = $entry_ids;
    $this->EE->TMPL->tagparams['dynamic'] = 'no';

    require_once(PATH_MOD.'channel/mod.channel.php');

    // Instantiate channel module
    $ch = new Channel(); 

    // return the entries
    return $ch->entries();
}

The result is that your module method will function exactly like a exp:channel:entries tag with the parameters set as you configure them.

  • Thanks. Can u please help how to call this channel module in a custom module? – Dhanu Nov 6 '13 at 7:38
  • 1
    I got the answer. We can just include the file require_once(APPPATH.'modules/channel/mod.channel.php'); But I am getting nothing when calling $ch->entries(); Any idea? – Dhanu Nov 6 '13 at 7:58
  • Sorry, I omitted that. You can use the PATH_MOD constant instead, as I've put in my edit above. Returning $ch->entries() itself won't output anything, it simply replicates the {exp:channel:entries} tag with your own allowing you to override and set the parameters. So you need to place any necessary variables within your tag pair in the template to get data out. Feel free to update the question with your updated code and corresponding template and I'll take a look. – Jeremy Gimbel Nov 6 '13 at 13:20

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.