Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
page list select indent
$children = $pages->get("/shop/")->children();
$list = new PageArray();
function mylist($children, $ind='', $arr){
$ind .= "– ";
foreach($children as $cat) {
$countproducts = wire("pages")->find("template=product,categories=$cat")->count();
$cat->title = $ind . $cat->title . " ($countproducts)";
if($cat->numChildren) {
mylist($cat->children,$ind, $arr);
return $arr;
$result = mylist($children, $ind='',$list);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.