$category_tree, * 'open_path' => [1 ,2] * ]); * * ----------------------------------------------------------------------------- */ /** tree_ul * creates (recursively) a nested ul-li tree of categories * --- -- -- - - - * @param $tree (array) : categories array formated as tree * @param $open_nodes (array) : array of categor ids that shall be marked open/selected * @return $html (string) */ function tree_li($tree, $open_nodes = [], $l = 0) { $html = ""; foreach($tree as $node) { // if has childs ... // write li ; traverse children recursively if ((isset($node['childs'])) && ( $node['childs']!= [])) { if (in_array(intval($node['rec']['id']), $open_nodes)) { $inner_class = "inner show"; $sign = "–"; $a_class = "has-childs selected"; } else { $inner_class = "inner"; $sign = "+"; $a_class = "has-childs"; } $html .= "
  • {$node['rec']['label']} {$sign}
  • "; } else { // else just write the li if (in_array(intval($node['rec']['id']), $open_nodes)) { $u_in = ""; $u_out = ""; $a_class = "selected"; } else { $u_in = ""; $u_out = ""; $a_class = ""; } $html .= "
  • {$node['rec']['label']}
  • "; } } return $html; } // draw the menu (hidden on XS screens) // ----------------------------------------------------------------------------- echo "

    Διαθέσιμη ύλη

    "; echo ""; // TODO: // draw menu for XS screens (for example, just the 1st-level categories) // (maybe in an accordion so it won;t take too much area on small screens)