本文整理汇总了PHP中MenuItem::setParentId方法的典型用法代码示例。如果您正苦于以下问题:PHP MenuItem::setParentId方法的具体用法?PHP MenuItem::setParentId怎么用?PHP MenuItem::setParentId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MenuItem
的用法示例。
在下文中一共展示了MenuItem::setParentId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isset
}
// 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">');
$html->renderOut('core/backend/header');
示例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: Message
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 {
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 item', 'zh' => 'Create 菜单项目'))));
$html->output('<div id="wrapper">');
$html->renderOut('core/backend/header');
$html->renderOut('menu/backend/menu_item_create', array('object' => $object));