本文整理汇总了PHP中MenuItem::setName方法的典型用法代码示例。如果您正苦于以下问题:PHP MenuItem::setName方法的具体用法?PHP MenuItem::setName怎么用?PHP MenuItem::setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MenuItem
的用法示例。
在下文中一共展示了MenuItem::setName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: MenuItem
/**
* Creates new menuitem and adds it to items list
*
* @param string $name
* Internal name of item
* @param string $text
* Text to show
* @param string $url
* Optional url for linking
*
* @return MenuItem Reference to the created child item.
*/
public function &createItem($name, $text, $url = '')
{
$menu_item = new MenuItem();
$menu_item->setName($name);
$menu_item->setText($text);
if ($url) {
$menu_item->setUrl($url);
}
$this->items[$name] = $menu_item;
return $this->items[$name];
}
示例2: MenuItem
$menu_item->setUri('');
$menu_item->save();
$menu_item = new MenuItem();
$menu_item->setWeight($weight++);
$menu_item->setMenuId($menu->getId());
$menu_item->setName('NEWS');
$menu_item->setParentId($root_id);
$menu_item->setUri('news');
$menu_item->save();
$menu_item = new MenuItem();
$menu_item->setWeight($weight++);
$menu_item->setMenuId($menu->getId());
$menu_item->setName('OUR SERVICES');
$menu_item->setParentId($root_id);
$menu_item->setUri('services');
$menu_item->save();
$menu_item = new MenuItem();
$menu_item->setWeight($weight++);
$menu_item->setMenuId($menu->getId());
$menu_item->setName('ABOUT US');
$menu_item->setParentId($root_id);
$menu_item->setUri('about');
$menu_item->save();
$menu_item = new MenuItem();
$menu_item->setWeight($weight++);
$menu_item->setMenuId($menu->getId());
$menu_item->setName('CONTACT');
$menu_item->setParentId($root_id);
$menu_item->setUri('contact');
$menu_item->save();
}
示例3: isset
$error_flag = true;
}
// validation for country_id
$country_id = isset($_POST['country_id']) ? strip_tags($_POST['country_id']) : null;
/// proceed submission
// proceed for $name
$object->setName($name);
// proceed for $country_id
$object->setCountryId($country_id);
if ($error_flag == false) {
if ($object->save()) {
// create root menu_it
$menu_item = new MenuItem();
$menu_item->setWeight(0);
$menu_item->setMenuId($object->getId());
$menu_item->setName('root');
$menu_item->setParentId(null);
$menu_item->setUri('');
$menu_item->save();
$object->setRootMenuItemId($menu_item->getId());
$object->save();
Message::register(new Message(Message::SUCCESS, i18n(array("en" => "Record saved", "zh" => "记录保存成功"))));
HTML::forwardBackToReferer();
} else {
Message::register(new Message(Message::DANGER, i18n(array("en" => "Record failed to save", "zh" => "记录保存失败"))));
}
}
}
$html = new HTML();
$html->renderOut('core/backend/html_header', array('title' => i18n(array('en' => 'Create Menu', 'zh' => 'Create 菜单'))));
$html->output('<div id="wrapper">');
示例4: isset
}
// validation for $menu_id
$menu_id = isset($_POST["menu_id"]) ? strip_tags($_POST["menu_id"]) : null;
if (empty($menu_id)) {
Message::register(new Message(Message::DANGER, i18n(array("en" => "menu_id is required.", "zh" => "请填写menu_id"))));
$error_flag = true;
}
// validation for $parent_id
$parent_id = isset($_POST["parent_id"]) ? strip_tags($_POST["parent_id"]) : null;
if (empty($parent_id)) {
Message::register(new Message(Message::DANGER, i18n(array("en" => "parent_id is required.", "zh" => "请填写parent_id"))));
$error_flag = true;
}
/// proceed submission
// proceed for $name
$object->setName($name);
// proceed for $uri
$object->setUri($uri);
// proceed for $menu_id
if (!empty($menu_id)) {
$object->setMenuId($menu_id);
}
// proceed for $parent_id
if (!empty($parent_id)) {
$object->setParentId($parent_id);
}
if ($error_flag == false) {
if ($object->save()) {
Message::register(new Message(Message::SUCCESS, i18n(array("en" => "Record saved", "zh" => "记录保存成功"))));
HTML::forwardBackToReferer();
} else {