當前位置: 首頁>>代碼示例>>PHP>>正文


PHP MenuItem::setName方法代碼示例

本文整理匯總了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];
 }
開發者ID:tekkla,項目名稱:core-framework,代碼行數:23,代碼來源:MenuItemAbstract.php

示例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();
}
開發者ID:jeffreycai,項目名稱:ct21,代碼行數:31,代碼來源:fixture.php

示例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">');
開發者ID:jeffreycai,項目名稱:ct21,代碼行數:31,代碼來源:menu_create.php

示例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 {
開發者ID:jeffreycai,項目名稱:ct21,代碼行數:31,代碼來源:menu_item_create.php


注:本文中的MenuItem::setName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。