<?php
foreach ($navItems as $ni) {
?>
<li class="<?php echo $ni->classes ?><?php echo($ni->hasSubmenu)?" dropdown":""; ?>">
<?php
if ($ni->hasSubmenu) {
?>
<a href="<?php echo $ni->url; ?>" target="<?php echo $ni->target; ?>" class="dropdown-toggle <?php echo $ni->classes; ?>" data-toggle="mydropdown" role="button" aria-haspopup="true" aria-expanded="false"><?php echo (isset($translate) && $translate == true) ? t($ni->date) : $ni->name; ?> <span class="caret"></span></a>
<?php
} else{
?>
<a href="<?php echo $ni->url; ?>" target="<?php echo $ni->target; ?>" class="<?php echo $ni->classes; ?>"><?php echo (isset($translate) && $translate == true) ? t($ni->name) : $ni->name; ?></a>
<?php
}
?>
<?php
if ($ni->hasSubmenu) {
echo '<ul class="dropdown-menu">'; //opens a dropdown sub-menu
} else {
echo '</li>'; //closes a nav item
echo str_repeat('</ul></li>', $ni->subDepth); //closes dropdown sub-menu(s) and their top-level nav item(s)
}
?>
</li>
<?php
}
我想在顶部添加“Szelídbeszéd”,这是最新添加到页面中。
答案 0 :(得分:0)
由于Concrete5返回单个对象数组而不是嵌套数组,因此在循环播放之前,您无法告诉孩子什么是什么以及什么不是。
因此,我建议您重建导航项数组,当您到达这些项目时,请附加它们的页面列表然后继续。
这可能不起作用,因为你会失去对这些页面的引用,因为这些页面会包含以下内容:#subSubmenu&#39;或者&#39; subDepth&#39;但试一试。
<?php
$navItemsNew = array();
$addedOrderedList = false;
$parentID = 4; //replace 4 with the ID of the parent page
foreach ($navItems as $ni) {
if($ni->cObj->getCollectionParentId() == $parentID){
if($addedOrderedList){
continue;
}else{
$pl = new PageList();
$pl->filterByParentID($parentID); //Get all posts beneath that parent
$pl->sortByPublicDate(); // Sort by public date, newest first
$pl->setItemsPerPage(0); //return all items in 1 page
$posts = $pl->getPage(1);
$addedOrderedList = true;
array_merge($navItemsNew, $posts);
continue;
}
}
$navItemsNew[] = $ni;
}
foreach ($navItemsNew as $ni) {
?>
<li class="<?php echo $ni->classes ?><?php echo($ni->hasSubmenu)?" dropdown":""; ?>">
<?php
if ($ni->hasSubmenu) {
?>
<a href="<?php echo $ni->url; ?>" target="<?php echo $ni->target; ?>" class="dropdown-toggle <?php echo $ni->classes; ?>" data-toggle="mydropdown" role="button" aria-haspopup="true" aria-expanded="false"><?php echo (isset($translate) && $translate == true) ? t($ni->date) : $ni->name; ?> <span class="caret"></span></a>
<?php
} else{
?>
<a href="<?php echo $ni->url; ?>" target="<?php echo $ni->target; ?>" class="<?php echo $ni->classes; ?>"><?php echo (isset($translate) && $translate == true) ? t($ni->name) : $ni->name; ?></a>
<?php
}
?>
<?php
if ($ni->hasSubmenu) {
echo '<ul class="dropdown-menu">'; //opens a dropdown sub-menu
} else {
echo '</li>'; //closes a nav item
echo str_repeat('</ul></li>', $ni->subDepth); //closes dropdown sub-menu(s) and their top-level nav item(s)
}
?>
</li>
<?php
}
答案 1 :(得分:-1)
子菜单中的页面来自xml,来自另一个网站,tomorow将添加1个新页面..并将在autonav最后一个孩子显示我们...但我们需要先!