Last active
January 3, 2016 05:49
-
-
Save somatonic/8418364 to your computer and use it in GitHub Desktop.
page list select indent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$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)"; | |
$arr->add($cat); | |
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