本文整理汇总了PHP中Varien_Data_Tree_Node::setLevel方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Data_Tree_Node::setLevel方法的具体用法?PHP Varien_Data_Tree_Node::setLevel怎么用?PHP Varien_Data_Tree_Node::setLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Data_Tree_Node
的用法示例。
在下文中一共展示了Varien_Data_Tree_Node::setLevel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _addChildNodes
protected function _addChildNodes($children, $path, $parentNode, $withChildren = false, $level = 0)
{
if (isset($children[$path])) {
foreach ($children[$path] as $child) {
$nodeId = isset($child[$this->_idField]) ? $child[$this->_idField] : false;
if ($parentNode && $nodeId && ($node = $parentNode->getChildren()->searchById($nodeId))) {
$node->addData($child);
} else {
$node = new Varien_Data_Tree_Node($child, $this->_idField, $this, $parentNode);
$node->setLevel($node->getData($this->_levelField));
$node->setPathId($node->getData($this->_pathField));
$this->addNode($node, $parentNode);
}
if ($withChildren) {
$this->_loaded = false;
$node->loadChildren(1);
$this->_loaded = false;
}
if ($path) {
$childrenPath = explode('/', $path);
} else {
$childrenPath = array();
}
$childrenPath[] = $node->getId();
$childrenPath = implode('/', $childrenPath);
$this->_addChildNodes($children, $childrenPath, $node, $withChildren, $level + 1);
}
}
}
示例2: addChildNodes
public function addChildNodes($children, $path, $parentNode, $level = 0)
{
if (isset($children[$path])) {
foreach ($children[$path] as $child) {
$node = new Varien_Data_Tree_Node($child, $this->_idField, $this, $parentNode);
$node->setLevel(count(explode('/', $node->getData($this->_pathField))));
$node->setPathId($node->getData($this->_pathField));
$this->addNode($node, $parentNode);
if ($path) {
$childrenPath = explode('/', $path);
} else {
$childrenPath = array();
}
$childrenPath[] = $node->getId();
$childrenPath = implode('/', $childrenPath);
$this->addChildNodes($children, $childrenPath, $node, $level + 1);
}
}
}