Modify bootstrap dropdown menu so child items appear as list page
2 posts by 2 authors in: Forums > CMS Builder
Last Post: January 12, 2016 (RSS)
By JeffC - January 12, 2016
Hi
I am using the standard bootstrap nav css to display a category menu structure created in cmsb.
<span class="navbar-brand"><?php echo htmlspecialchars($website_config['website_name']) ?>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<?php foreach($categories as $category): ?>
<?php echo $category['_listItemStart']; ?>
<a href="<?php echo $category['_link']; ?> " <?php if($category['_hasChild'] && $category['depth'] == '0'): ?>class="dropdown-toggle" data-toggle="dropdown"<?php endif; ?> >
<?php echo $category['name']; ?> <?php if($category['_hasChild'] && $category['depth'] == '0'): ?><span class="caret"></span><?php endif; ?></a>
<?php echo $category['_listItemEnd']; ?>
<?php endforeach; ?>
This standard code shows parent items with child items as a drop down.
Please could some one assist me to rewrite the above so that the nav menu shows the parent only, with the parent linking to a separate list page containing the child links.
I understand how list and detail pages work, but I am confused by category menus!
By Toledoh - January 12, 2016
You need to remove the "if child"
<ul class="nav navbar-nav">
<?php if (!$categoryRecord['hide_from_navigation']): ?>
<?php echo $categoryRecord['_listItemStart'] ?>
<a href="
<?php if ($categoryRecord['redirect']): ?><?php echo PREFIX_URL ?><?php echo $categoryRecord['redirect'] ?>
<?php else: ?><?php echo $categoryRecord['_link'] ?>
<?php endif ?>
"
><?php echo $categoryRecord['name'] ?>
</a>
<?php echo $categoryRecord['_listItemEnd'] ?>
<?php endforeach; ?>
</ul>
and in the viewer code, need to add the 'onelevel'
// load pages
list($categories, $selectedCategory) = getCategories(array(
'tableName' => 'pages',
'categoryFormat' => 'onelevel', //TO REMOVE DROP DOWN NAVIGATION
'ulAttributesCallback' => 'customMenuUlAttr', // ADVANCED: custom function to return ul attributes, eg: myUlAttr($category);
'liAttributesCallback' => 'customMenuLiAttr', // ADVANCED: custom function to return li attributes, eg: myLiAttr($category);
));
Hope that helps
Tim (toledoh.com.au)