public function split_list()
{
/* Sample use
---------------------------------------------------------
{exp:stash:split_list
name="my_list_fragment"
list="list_1"
match="#^blue$#"
against="colour"
}
--------------------------------------------------------- */
// the original list
$old_list = $this->EE->TMPL->fetch_param('list', FALSE);
// the new list
$new_list = $this->EE->TMPL->fetch_param('name', FALSE);
// limit the number of rows to copy?
$limit = $this->EE->TMPL->fetch_param('limit', FALSE);
if ($old_list && $new_list) {
$this->EE->TMPL->tagparams['name'] = $old_list;
// apply filters to the original list and generate an array
$list = $this->rebuild_list();
// apply limit
if ($limit !== FALSE) {
$list = array_slice($list, 0, $limit);
}
// flatten the list array into a string, ready for setting as a variable
$this->EE->TMPL->tagdata = $this->flatten_list($list);
// reset the name parameter
$this->EE->TMPL->tagparams['name'] = $new_list;
// unset params used for filtering
unset($this->EE->TMPL->tagparams['match']);
unset($this->EE->TMPL->tagparams['against']);
// set as a new variable
return $this->set();
}
}