本文整理汇总了PHP中FrontendNavigation::getNavigationHtml方法的典型用法代码示例。如果您正苦于以下问题:PHP FrontendNavigation::getNavigationHtml方法的具体用法?PHP FrontendNavigation::getNavigationHtml怎么用?PHP FrontendNavigation::getNavigationHtml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FrontendNavigation
的用法示例。
在下文中一共展示了FrontendNavigation::getNavigationHtml方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSubNavigation
/**
* Get the subnavigation html
* syntax: {$var|getsubnavigation[:type[:parentId[:startdepth[:enddepth[:'excludeIds-splitted-by-dash']]]]]}
*
* NOTE: When supplying more than 1 ID to exclude, the single quotes around the dash-separated list are mandatory.
*
* @param string[optional] $var The variable.
* @param string[optional] $type The type of navigation, possible values are: page, footer.
* @param int[optional] $pageId The parent wherefore the navigation should be build.
* @param int[optional] $startDepth The depth to strat from.
* @param int[optional] $endDepth The maximum depth that has to be build.
* @param string[optional] $excludeIds Which pageIds should be excluded (split them by -).
* @return string
*/
public static function getSubNavigation($var = null, $type = 'page', $pageId = 0, $startDepth = 1, $endDepth = null, $excludeIds = null)
{
// build excludeIds
if ($excludeIds !== null) {
$excludeIds = (array) explode('-', $excludeIds);
}
// get info about the given page
$pageInfo = FrontendNavigation::getPageInfo($pageId);
// validate page info
if ($pageInfo === false) {
return '';
}
// split URL into chunks
$chunks = (array) explode('/', $pageInfo['full_url']);
// init var
$parentURL = '';
// build url
for ($i = 0; $i < $startDepth - 1; $i++) {
$parentURL .= $chunks[$i] . '/';
}
// get parent ID
$parentID = FrontendNavigation::getPageId($parentURL);
try {
// get HTML
$return = (string) FrontendNavigation::getNavigationHtml($type, $parentID, $endDepth, $excludeIds);
} catch (Exception $e) {
return '';
}
// return the var
if ($return != '') {
return $return;
}
// fallback
return $var;
}