本文整理汇总了PHP中ProductCategory::getSinglePath方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductCategory::getSinglePath方法的具体用法?PHP ProductCategory::getSinglePath怎么用?PHP ProductCategory::getSinglePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProductCategory
的用法示例。
在下文中一共展示了ProductCategory::getSinglePath方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: intval
$show_sub = '';
// neu la sub cat
if ($cat_slug != '') {
$select_node = ProductCategory::bll()->getOneBySlug($cat_slug);
if ($select_node) {
$in_sub = true;
$selected_node_id = $select_node['id'];
if ($select_node['level'] == 1) {
//get childs next to current
$selected_parent_slug = $select_node['slug'];
//$childs = $select_node->getNode()->getChildren();
$childs = ProductCategory::getNodeChildrens($selected_node_id);
} else {
//get from bottom to top
//$parents = $select_node->getNode()->getAncestors();
$parents = ProductCategory::getSinglePath($selected_node_id);
//print_r($parents->toArray());
if (count($parents) >= 2) {
$p = $parents[1];
} else {
$p = $parents[0];
}
$selected_parent_slug = $p['slug'];
$hops = intval($select_node['level']) - intval($p['level']);
//echo "level 2:".count($parents).":".$hops;
//print_r($p->toArray());
//$childs = $p->getNode()->getDescendants($hops);
$childs = ProductCategory::getNodeChildrens($p['id'], $hops, $select_node['id']);
}
//build sub into html
$show_sub = ProductCategory::buildTree($childs);