Skip to content

Instantly share code, notes, and snippets.

@airways
Created October 28, 2011 15:52
Show Gist options
  • Save airways/1322600 to your computer and use it in GitHub Desktop.
Save airways/1322600 to your computer and use it in GitHub Desktop.
ExpressionEngine: Extending a core or third party module or plugin
<?php
class ExtendedChannel {
public __construct()
{
$this->EE = &get_instance();
}
public function extended_entries()
{
// Get params
$some_param = $this->EE->TMPL->fetch_param('some_param');
// Do something to get some custom data, in this case $entry_ids was an array of entry IDs
// ...
// Modify the template params
$entry_ids = implode('|', $entry_ids);
$this->EE->TMPL->tagparams['fixed_order'] = $entry_ids;
// Include the class if it isn't included
if(!class_exists('Channel'))
{
// First party modules or plugins
require_once(APPPATH.'modules/channel/mod.channel.php');
// Third party would be
// require_once(PATH_THIRD.'package/mod.package.php');
}
// Create instance of Package class and call the tag you want to extend
// It will use the parameters passed from the template, as well as
// anything you have modified in tagparams
$C = new Channel();
$this->return_data = $C->entries();
return $this->return_data;
}
}
@stevegrossi
Copy link

This is really helpful, thanks for posting! However, I notice that when modifying TMPL->tagparams array, EE seems to ignore search params. For example,

$this->EE->TMPL->tagparams['search:title'] = "foo";

Still returns entries without "foo" in the title. I know it's been a while since you posted this, but if in your experience you've ever come across this issue, I'd love to know how you got around it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment