本文整理匯總了PHP中navigation_node::set_parent方法的典型用法代碼示例。如果您正苦於以下問題:PHP navigation_node::set_parent方法的具體用法?PHP navigation_node::set_parent怎麽用?PHP navigation_node::set_parent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類navigation_node
的用法示例。
在下文中一共展示了navigation_node::set_parent方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: add_node
/**
* Adds a navigation node as a child of this one, given a $node object
* created using the create function.
* @param navigation_node $childnode Node to add
* @param string $beforekey
* @return navigation_node The added node
*/
public function add_node(navigation_node $childnode, $beforekey = null)
{
// First convert the nodetype for this node to a branch as it will now have children
if ($this->nodetype !== self::NODETYPE_BRANCH) {
$this->nodetype = self::NODETYPE_BRANCH;
}
// Set the parent to this node
$childnode->set_parent($this);
// Default the key to the number of children if not provided
if ($childnode->key === null) {
$childnode->key = $this->children->count();
}
// Add the child using the navigation_node_collections add method
$node = $this->children->add($childnode, $beforekey);
// If added node is a category node or the user is logged in and it's a course
// then mark added node as a branch (makes it expandable by AJAX)
$type = $childnode->type;
if ($type == self::TYPE_CATEGORY || isloggedin() && $type == self::TYPE_COURSE) {
$node->nodetype = self::NODETYPE_BRANCH;
}
// If this node is hidden mark it's children as hidden also
if ($this->hidden) {
$node->hidden = true;
}
// Return added node (reference returned by $this->children->add()
return $node;
}