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


PHP Navigation::getNavigationHtml方法代碼示例

本文整理匯總了PHP中Frontend\Core\Engine\Navigation::getNavigationHtml方法的典型用法代碼示例。如果您正苦於以下問題:PHP Navigation::getNavigationHtml方法的具體用法?PHP Navigation::getNavigationHtml怎麽用?PHP Navigation::getNavigationHtml使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Frontend\Core\Engine\Navigation的用法示例。


在下文中一共展示了Navigation::getNavigationHtml方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getSubNavigation

 /**
  * Get the subnavigation html
  *   syntax: {$var|getsubnavigation[:type[:parentId[:startdepth[:enddepth[:excludeIds-splitted-by-dash[:tpl]]]]]}
  *
  *   NOTE: When supplying more than 1 ID to exclude, the single quotes around the dash-separated list are mandatory.
  *
  * @param string $var        The variable.
  * @param string $type       The type of navigation, possible values are: page, footer.
  * @param int    $pageId     The parent wherefore the navigation should be build.
  * @param int    $startDepth The depth to start from.
  * @param int    $endDepth   The maximum depth that has to be build.
  * @param string $excludeIds Which pageIds should be excluded (split them by -).
  * @param string $tpl        The template that will be used.
  * @return string
  */
 public static function getSubNavigation($var = null, $type = 'page', $pageId = 0, $startDepth = 1, $endDepth = null, $excludeIds = null, $tpl = '/Core/Layout/Templates/Navigation.tpl')
 {
     // build excludeIds
     if ($excludeIds !== null) {
         $excludeIds = (array) explode('-', $excludeIds);
     }
     // get info about the given page
     $pageInfo = Navigation::getPageInfo($pageId);
     // validate page info
     if ($pageInfo === false) {
         return '';
     }
     // split URL into chunks
     $chunks = (array) explode('/', $pageInfo['full_url']);
     // remove language chunk
     $hasMultiLanguages = FrontendModel::getContainer()->getParameter('site.multilanguage');
     $chunks = $hasMultiLanguages ? (array) array_slice($chunks, 2) : (array) array_slice($chunks, 1);
     if (count($chunks) == 0) {
         $chunks[0] = '';
     }
     // init var
     $parentURL = '';
     // build url
     for ($i = 0; $i < $startDepth - 1; $i++) {
         $parentURL .= $chunks[$i] . '/';
     }
     // get parent ID
     $parentID = Navigation::getPageId($parentURL);
     try {
         // get HTML
         $return = (string) Navigation::getNavigationHtml($type, $parentID, $endDepth, $excludeIds, (string) $tpl);
     } catch (Exception $e) {
         return '';
     }
     // return the var
     if ($return != '') {
         return $return;
     }
     // fallback
     return $var;
 }
開發者ID:bwgraves,項目名稱:forkcms,代碼行數:56,代碼來源:TemplateModifiers.php


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