本文整理匯總了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);