pyrocms/pyrocms — Issue #854: new tag: page:has
Author: gospellabs
Created: 2011-10-27 16:49:40+00:00
State: open

Hi,
I wanted the ability to use an if tag to determine if a page had children. Much like the "is" function but opposite.

I am just starting to learn GIT so I probably couldn't figure out how to submit this properly, so here goes.

/system/cms/modules/pages/plugin.php
```
/**
* Page has function
*
* Check if the page has children
*
* Usage:
* {pyro:pages:has parent_id="4"} // return (TRUE)
* {pyro:pages:has parent_id="8"} // return (FALSE)
*
* Use Id or Slug as param, following usage data reference
* Id: 4 = Slug: books
* Id: 6 = Slug: cookbook
* Id: 7 = Slug: recipes
* Id: 8 = Slug: ingredients
* Id: 9 = Slug: literature
*
* @param	int Parent ID
* @return	Bool	true or false
*/
public function has()
{
$parent_id	= $this->attribute('parent_id');
if (!$parent_id)
{
return;
}
return $this->page_m->has_children($parent_id);
}
```