Skip to content

Instantly share code, notes, and snippets.

@airways
Created February 17, 2013 21:01
Show Gist options
  • Save airways/4973441 to your computer and use it in GitHub Desktop.
Save airways/4973441 to your computer and use it in GitHub Desktop.
Calling {exp:structure:entries} with a parent_id parameter that does not have any children results in all entries from the site tree being returned, instead of nothing, which is what I would expect. This patch fixes this by setting the entry_id parameter to an impossible value.
function entries() {
$parent_id = $this->EE->TMPL->fetch_param('parent_id', false);
if ($parent_id) {
$child_ids = $this->sql->get_child_entries($parent_id);
$fixed_order = $child_ids !== FALSE && count($child_ids > 0) ? implode('|', $child_ids) : false;
if ($fixed_order) {
$this->EE->TMPL->tagparams['fixed_order'] = $fixed_order;
} else {
$this->EE->TMPL->tagparams['entry_id'] = '-99999';
}
}
return parent::entries();
}
@jackmcdade
Copy link

Nice catch man!

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