本文整理汇总了PHP中MenuItem::setWeight方法的典型用法代码示例。如果您正苦于以下问题:PHP MenuItem::setWeight方法的具体用法?PHP MenuItem::setWeight怎么用?PHP MenuItem::setWeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MenuItem
的用法示例。
在下文中一共展示了MenuItem::setWeight方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
示例2: Message
if (empty($name)) {
Message::register(new Message(Message::DANGER, i18n(array("en" => "name is required.", "zh" => "请填写name"))));
$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();