I must attain the following during my Joomla template's primary menu:

    <ul class="topmenu">
         <li><a class="nav_link" id="active" href="#">Home</a></li><span class="separator"></span>
         <li><a class="nav_link" href="#">About Us</a></li><span class="separator"></span>
         <li><a class="nav_link" href="#">Services</a>
<div class="subnav_wrapper">
      <ul class="subnav">
       <li><a class="sub_nav_link" href="#">Custom Software</a></li>
       <li><a class="sub_nav_link" href="#">Software Solutions</a></li>
       <li><a class="sub_nav_link" href="#">Mobile SMS</a></li>
       <li><a class="sub_nav_link" href="#">Web Solutions</a></li>
       <li class="last"><a class="sub_nav_link" href="#">ICT Consultancy</a></li>
     </li><span class="separator"></span>

I have already overriden the default.php apply for the module (I have replicated "default.php" from "modulesmod_mainmenutmpl" into "templatesmytemplatehtmlmod_mainmenu". Things I do not get is when I'm able to differentiate between your top-level ul, li along with a elements and individuals within the subnav. For instance, to include the course "last" towards the last list item within the subnav, I have attempted the next:

if ($node->name() == 'ul') {
   foreach ($node->children() as $child)
    if ($child->attributes('access') > $user->get('aid', 0)) {
   $children_count = count($node->children());
   $children_index = 0;
   foreach ($node->children() as $child) {
   if ($children_index == $children_count - 1) {
    $child->addAttribute('class', 'last');


However the above adds the course also within the last item from the top-level ul.

Is a method to attain the preferred effect while using template override method?

Unsure concerning the template overriding of menus. You could think about http://extensions.joomla.org/extensions/structure-a-navigation/menu-systems/tree-menus/163 the industry great module for personalising menus.

Alternatively, if you wish to basically style recption menus products you can consider using ul li:last-child inside your CSS. Note this isn't fully supported across all browsers.