本文整理汇总了PHP中Navigation::node方法的典型用法代码示例。如果您正苦于以下问题:PHP Navigation::node方法的具体用法?PHP Navigation::node怎么用?PHP Navigation::node使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Navigation
的用法示例。
在下文中一共展示了Navigation::node方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Navigation
function test_adding_node()
{
$n = new Navigation();
$blog_node = (object) array('data' => 'Blog', 'attr' => (object) array('id' => 'blog', 'sort' => 0));
/**
* Add blog page.
*/
$n->add($blog_node, 'index');
/**
* Should have second id now:
*
* index
* - blog
*/
$this->assertEquals($n->get_all_ids(), array('index', 'blog'));
// Remove and re-add index
$n->remove('index');
$this->assertEquals($n->get_all_ids(), array());
$n->add('index');
$index_node = $n->node('index');
$expected_index = (object) array('data' => 'Home', 'attr' => (object) array('id' => 'index', 'sort' => 0));
/*
* Should have index node with title 'Home' from the database.
*/
$this->assertEquals($expected_index, $index_node);
}
示例2: Navigation
<?php
/**
* Displays a single section of the navigation as a
* bulleted list, with `class="current"` added to
* the current page's `<li>` element for custom styling.
*/
$n = new Navigation();
$section = $n->node($data['section']);
echo '<ul>';
foreach ($section->children as $item) {
if ($item->attr->id == $page->id) {
printf('<li class="current"><a href="/%s">%s</a></li>', $item->attr->id, $item->data);
} else {
printf('<li><a href="/%s">%s</a></li>', $item->attr->id, $item->data);
}
}
echo '</ul>';
示例3: die
<?php
/**
* Updates the name of a page in the navigation. Called via a hook from
* the page edit form.
*/
if (!$this->internal) {
die('Must be called by another handler');
}
$n = new Navigation();
$node = $n->node($this->data['page']);
if ($node) {
$node->data = !empty($this->data['menu_title']) ? $this->data['menu_title'] : $this->data['title'];
if ($this->data['page'] != $this->data['id']) {
// Update ID if renamed
$node->attr->id = $this->data['id'];
}
$n->save();
require_once 'apps/navigation/lib/Functions.php';
navigation_clear_cache();
}