Hey Zicky,
I got this sorted last night and here is how I achieved it ... first by using two of the advanced options to insert classes into the nested <ul> tags and into the <li> tags which have submenu items.
// load records from 'navigation_menu'
list($navigation_menuRecords, $selectedNavigation_menu) = getCategories(array(
'tableName' => 'navigation_menu', //
'categoryFormat' => 'showall', // showall, onelevel, twolevel, breadcrumb
'defaultCategory' => 'first', // Enter 'first', a category number, or leave blank '' for none
// advanced options (you can safely ignore these)
'ulAttributes' => 'class="submenu"', // add html attributes to <ul> tags, eg: 'class="menuUL"' would output <ul class="menuUL">
'liAttributesCallback' => 'customMenuLIAttr', // ADVANCED: custom function to return li attributes, eg: 'myLiAttr' and function myLiAttr($category) { return "id='li_uniqueId_{$category['num']}'"; }
));
function customMenuLIAttr($category) {
global $GLOBALS;
return ($category['_hasChild'])? " class=\"active sub-menu\"" : "" ;
}
This is how the code looked when the classes were inserted into the <ul> and <li> tags. The remaining thing to achieve is the placement of the <span></span> tags.
<ul class="nav sf-menu clearfix"> // this is hardcoded in
<li class="active sub-menu"><a href="#">Home</a><span></span> // class inserted by the CMSB getCategories function:: 'liAttributesCallback' => 'customMenuLIAttr',
<ul class="submenu"> // class inserted by the CMSB getCategories function:: 'ulAttributes'=>'class="submenu"',
<li><a href="#">Lorem ipsum dolor sit<span></span></a>
<ul class="submenu"> // class inserted by the CMSB getCategories function:: 'ulAttributes'=>'class="submenu"',
<li><a href="#">Lorem ipsum dolor sit</a></li>
<li><a href="#">Conse ctetur adipisicing</a></li>
<li><a href="#">Elit sed do eiusmod tempor</a></li>
<li><a href="#">Incididunt ut labore</a></li>
<li><a href="#">Et dolore magna aliqua</a></li>
</ul>
</li>
<li><a href="#">Conse ctetur adipisicing</a></li>
<li><a href="#">Elit sed do eiusmod tempor</a></li>
<li><a href="#">Incididunt ut labore</a></li>
<li><a href="#">Et dolore magna aliqua</a></li>
</ul>
</li>
<li><a href="#">About</a></li>
<li><a href="#">Blog</a></li>
<li><a href="#">Gallery</a></li>
<li><a href="#">Contacts</a></li>
</ul>
The <span></span> tags is then controlled by CSS to insert a triangle pointing down or to the right to indicate that the menu was either a dropdown or expandable horizontally. For the dropdown menu it is to be inserted after the anchor tag is closed i.e. <a href="#">XX</a><span></span>. While for the horizontal expansion it must occur before the anchor tag closes i.e. <a href="#">YY<span></span></a>. To achieve this, I used conditional statements to determine the category depth and specify where to place the span tags.
<ul class="nav sf-menu clearfix">
<?php foreach ($navigation_menuRecords as $categoryRecord): ?>
<?php echo $categoryRecord['_listItemStart'] ?>
<?php if($categoryRecord['_hasChild'] && $categoryRecord['depth'] == '0'): ?>
<b><a href="<?php echo $categoryRecord['url'] ?>"><?php echo $categoryRecord['name'] ?></a></b><span></span>
<?php elseif($categoryRecord['_hasChild'] && $categoryRecord['depth'] > '0'): ?>
<b><a href="<?php echo $categoryRecord['url'] ?>"><?php echo $categoryRecord['name'] ?><span></span></a></b>
<?php else: ?>
<b><a href="<?php echo $categoryRecord['url'] ?>"><?php echo $categoryRecord['name'] ?></a></b>
<?php endif ?>
<?php echo $categoryRecord['_listItemEnd'] ?>
<?php endforeach; ?>
</ul>
This has taken me six days to figure out costing me a delay I could not afford.
Me thinks that had I gotten expert help from the authors of CMSB, this would have been solved a long time ago. Perhaps there is a new support policy that I have not read?
Terry