当前位置: 首页>>代码示例>>PHP>>正文


PHP CMSCategory::getLink方法代码示例

本文整理汇总了PHP中CMSCategory::getLink方法的典型用法代码示例。如果您正苦于以下问题:PHP CMSCategory::getLink方法的具体用法?PHP CMSCategory::getLink怎么用?PHP CMSCategory::getLink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CMSCategory的用法示例。


在下文中一共展示了CMSCategory::getLink方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getCMSMenuItems

 protected function getCMSMenuItems($parent, $depth = 1, $id_lang = false)
 {
     $id_lang = $id_lang ? (int) $id_lang : (int) Context::getContext()->language->id;
     if ($depth > 3) {
         return;
     }
     $categories = $this->getCMSCategories(false, (int) $parent, (int) $id_lang);
     $pages = $this->getCMSPages((int) $parent);
     if (count($categories) || count($pages)) {
         $this->_menu .= '<ul>';
         foreach ($categories as $category) {
             $cat = new CMSCategory((int) $category['id_cms_category'], (int) $id_lang);
             $this->_menu .= '<li>';
             $this->_menu .= '<a href="' . Tools::HtmlEntitiesUTF8($cat->getLink()) . '">' . $category['name'] . '</a>';
             $this->getCMSMenuItems($category['id_cms_category'], (int) $depth + 1);
             $this->_menu .= '</li>';
         }
         foreach ($pages as $page) {
             $cms = new CMS($page['id_cms'], (int) $id_lang);
             $links = $cms->getLinks((int) $id_lang, array((int) $cms->id));
             $selected = $this->page_name == 'cms' && (int) Tools::getValue('id_cms') == $page['id_cms'] ? ' class="sfHoverForce"' : '';
             $this->_menu .= '<li ' . $selected . '>';
             $this->_menu .= '<a href="' . $links[0]['link'] . '">' . $cms->meta_title . '</a>';
             $this->_menu .= '</li>';
         }
         $this->_menu .= '</ul>';
     }
 }
开发者ID:prestashop,项目名称:blocktopmenu,代码行数:28,代码来源:blocktopmenu.php

示例2: getCMSMenuItems

 private function getCMSMenuItems(&$menu, $parent, $depth = 1, $id_lang = false)
 {
     $category_id = (int) Tools::getValue('id_cms_category', false);
     $page_id = (int) Tools::getValue('id_cms', false);
     $is_category = $this->page_name == 'cms' && $category_id;
     $is_page = $this->page_name == 'cms' && $page_id;
     $id_lang = $id_lang ? (int) $id_lang : (int) Context::getContext()->language->id;
     $activeCategories = array();
     if ($is_page) {
         $parent_category = $this->getCmsParentCategory($page_id);
         $activeCategories = $this->getActiveCMSMenuItemPath($parent_category, $id_lang);
     } else {
         if ($is_category) {
             $activeCategories = $this->getActiveCMSMenuItemPath($category_id, $id_lang);
         }
     }
     $categories = $this->getCMSCategories(false, (int) $parent, (int) $id_lang);
     $pages = $this->getCMSPages((int) $parent);
     if ((count($categories) || count($pages)) && ($this->_showAll !== 'one level' || $this->_showAllResponsive !== 'one level')) {
         $pageMenu = '';
         foreach ($pages as $page) {
             $cms = new CMS($page['id_cms'], (int) $id_lang);
             $links = $cms->getLinks((int) $id_lang, array((int) $cms->id));
             $selected = $this->page_name == 'cms' && (int) Tools::getValue('id_cms') == $page['id_cms'] ? ' class="active"' : '';
             $pageMenu .= $this->_subItemHead . '<li class="' . $this->_subItemClass . '">';
             $pageMenu .= '<a href="' . $links[0]['link'] . '"' . $selected . '><span>' . $cms->meta_title . '</span></a>';
             $pageMenu .= '</li>' . $this->_subItemTail;
         }
         $catMenu = '';
         foreach ($categories as $category) {
             $currentId = (int) $category['id_cms_category'];
             $catSelect = '';
             foreach ($activeCategories as $activeCategory) {
                 if ($currentId === (int) $activeCategory['id_cms_category']) {
                     $catSelect = ' class="active"';
                 }
             }
             $cat = new CMSCategory((int) $category['id_cms_category'], (int) $id_lang);
             $catMenu .= $this->_subItemHead . '<li class="' . $this->_subItemClass . '">';
             $catMenu .= '<a href="' . Tools::HtmlEntitiesUTF8($cat->getLink()) . '"' . $catSelect . '><span>' . $category['name'] . '</span></a>';
             $this->getCMSMenuItems($catMenu, $category['id_cms_category'], (int) $depth + 1, $id_lang);
             $catMenu .= '</li>' . $this->_subItemTail;
         }
         $menu .= $this->_subMenuHead . '<ul class="' . $this->_subMenuClass . (empty($catMenu) ? '' : ' active') . '">';
         $menu .= $catMenu;
         $menu .= $pageMenu;
         $menu .= '</ul>' . $this->_subMenuTail;
     }
 }
开发者ID:tmdhosting,项目名称:TMDHosting-PrestaShop-Technology-Theme,代码行数:49,代码来源:blocktopmenu_mod.php

示例3: generateCMSCategoriesMenu

 protected function generateCMSCategoriesMenu($id_cms_category, $id_lang)
 {
     $category = new CMSCategory($id_cms_category, $id_lang);
     $rawSubCategories = $this->getCMSCategories(false, $id_cms_category, $id_lang);
     $rawSubPages = $this->getCMSPages($id_cms_category);
     $subCategories = array_map(function ($category) use($id_lang) {
         return $this->generateCMSCategoriesMenu($category['id_cms_category'], $id_lang);
     }, $rawSubCategories);
     $subPages = array_map(function ($page) use($id_lang) {
         return $this->makeNode(['type' => 'cms-page', 'page_identifier' => 'cms-page-' . $page['id_cms'], 'label' => $page['meta_title'], 'url' => $this->context->link->getCMSLink(new CMS($page['id_cms'], $id_lang), null, null, $id_lang)]);
     }, $rawSubPages);
     $node = $this->makeNode(['type' => 'cms-category', 'page_identifier' => 'cms-category-' . $id_cms_category, 'label' => $category->name, 'url' => $category->getLink(), 'children' => array_merge($subCategories, $subPages)]);
     return $node;
 }
开发者ID:prestashop,项目名称:ps_mainmenu,代码行数:14,代码来源:ps_mainmenu.php

示例4: extractElementInfo

 public function extractElementInfo()
 {
     switch ($this->type) {
         case 'external':
             $this->link = $this->external;
             break;
     }
     if ($this->element) {
         switch ($this->type) {
             case 'cms_category':
                 $title = $this->element->name;
                 $this->link = $this->element->getLink();
                 if ($this->display_cms_cat_childs && !self::isAdmin()) {
                     foreach (CmsCategory::getChildren($this->element->id, self::getIdLang()) as $children) {
                         $obj = new CmsCategory($children['id_cms_category'], self::getIdLang());
                         $child = new self(array('type' => 'cms_category', 'id_cms_category' => $obj->id, 'element' => $obj, 'display_cms_cat_childs' => $this->display_cms_cat_childs));
                         $this->childrens[] = $child;
                     }
                     foreach ($this->getCMSPages($this->element->id) as $page) {
                         $obj = new CMS($page['id_cms'], self::getIdLang());
                         $child = new self(array('type' => 'cms', 'id_cms' => $obj->id, 'element' => $obj, 'display_cms_cat_childs' => $this->display_cms_cat_childs));
                         $this->childrens[] = $child;
                     }
                 }
                 break;
             case 'product_category':
                 $title = $this->element->name;
                 $link = $this->element->getLink();
                 if ($this->display_prod_cat_childs && !self::isAdmin()) {
                     /** @var $this->element CategoryCore */
                     foreach (Category::getChildren($this->element->id, self::getIdLang()) as $children) {
                         $obj = new Category($children['id_category'], self::getIdLang());
                         $child = new self(array('type' => 'product_category', 'id_category' => $obj->id, 'title' => $obj->name, 'link' => $obj->getLink(), 'display_prod_cat_childs' => $this->display_prod_cat_childs));
                         $this->childrens[] = $child;
                     }
                 }
                 break;
             case 'product':
                 $link = $this->element->getLink();
                 $title = $this->element->name;
                 break;
             case 'internal':
                 $link = self::getClassLink()->getPageLink($this->element->page);
                 $title = $this->element->title;
                 break;
             case 'cms':
                 $link = self::getClassLink()->getCMSLink($this->element, null);
                 $title = $this->element->meta_title;
                 break;
             case 'manufacturer':
                 $link = $this->element->getLink();
                 $title = $this->element->name;
                 break;
             case 'supplier':
                 $link = $this->element->getLink();
                 $title = $this->element->name;
                 break;
             case 'attachment':
                 $link = self::getClassLink()->getPageLink('attachment', NULL, "id_attachment=" . $this->id_attachment);
                 $title = $this->element->name;
                 break;
         }
     }
     //        if(self::isSSL())
     //            $this->link = str_replace('http://','https://',$this->link);
     if (empty($this->link)) {
         $this->link = @$link;
     }
     if (empty($this->title)) {
         $this->title = @$title;
     }
     if (is_array($this->title)) {
         $this->title = $this->title[self::getIdLang()];
     }
     if ($this->has_anchor) {
         $this->link .= '#' . $this->anchor;
     }
 }
开发者ID:simonbonjean,项目名称:PrestaSuperTool-Api,代码行数:78,代码来源:Item.php


注:本文中的CMSCategory::getLink方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。