Skip to content

Instantly share code, notes, and snippets.

@dmlogic
Created July 4, 2014 08:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmlogic/12261e9b1aba873d2366 to your computer and use it in GitHub Desktop.
Save dmlogic/12261e9b1aba873d2366 to your computer and use it in GitHub Desktop.
Run any string as ExpresisonEngine channel::entries. Also supports search field
<?php
/**
* Allows an arbirary string to be parsed as Channel Entries markup
*/
use Channel;
class PsuedoChannelEntries {
public function entries($tagparams,$tagdata,$search_fields = [])
{
$this->setup($tagparams,$tagdata,$search_fields);
$CH = new Channel();
$CH->enable['custom_fields'] = 1;
return $CH->entries();
}
//--------------------------------------------------------------------------
private function setup($tagparams,$tagdata,$search_fields)
{
ee()->TMPL->tagparams = $tagparams;
ee()->TMPL->tagdata = $tagdata;
ee()->TMPL->search_fields = $search_fields;
$vars = ee()->functions->assign_variables($tagdata, '/');
ee()->TMPL->var_single = $vars['var_single'];
ee()->TMPL->var_pair = $vars['var_pair'];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment