Creating a dynamic drop down menu

13 posts by 2 authors in: Forums > CMS Builder
Last Post: January 24, 2014   (RSS)

By drewh01 - January 23, 2014

I have created this before, with the help of the forum of course...but I cannot get it to work again. At this point, I am not sure what I am doing wrong so going to start over from the beginning.

Attached is my nav file with working <LI> and <UL> structure.

I have created this same category menu type structure in my admin (tablename=pages1).

Oh, I also need to keep a line of code that lets me override a menu URL and follow a manual link. <?php if ($listRecord['url']) { $listRecord['_link'] = $listRecord['url']; } ?>

Below is what I tried to use, and failed miserably.

TRY #1:

<ul class="sf-menu" id="example">

<?php foreach ($pages1Records as $listRecord): ?>
<?php if ($listRecord['url']) { $listRecord['_link'] = $listRecord['url']; } ?>
<?php $isSelected = ($listRecord['num'] == $detailRecord['num']); ?>
<?php if ($isSelected) { print "<b>"; } ?>
<li><a href="<?php echo htmlencode($listRecord['_link']) ?>"><?php echo htmlencode($listRecord['name']) ?></a></li>

<?php if ($isSelected) { print "</b>"; } ?>
<?php endforeach ?>

<?php if (!$pages1Records): ?>
No records were found!<br/><br/>
<?php endif ?>

</ul>

 TRY #2:

---------

list($allPages, $selectedPage) = getCategories(array(
'tableName' => 'page1',
'categoryFormat' => 'twolevel', // showall, onelevel, twolevel, breadcrumb
));

----------

<ul>
<?php foreach ($allPages as $page): ?>

<?php $link = $page['url'] ? $page['url'] : $page['_link']; ?>

<?php echo $page['_listItemStart'] ?>

<?php if ($page['_isSelected']): ?>

<a href="<?php echo $link; ?>"><?php echo $page['name'] ?></a>

<?php else: ?>

<li>
<a href="<?php echo $link; ?>">
<?php echo $page['name'] ?>
</a>

<?php endif; ?>
<?php echo $page['_listItemEnd'] ?>

<?php endforeach; ?>
</ul>

This is beyond my knowledge and would appreciate some help.

Attachments:

nav_003.php 2K

By Mikey - January 23, 2014 - edited: January 23, 2014

Hey Drew...

Honestly, I'm feeling too lazy to actually look at the code you have listed in much detail - it's been a long day, but I think I understand what you're looking for.

I've got a solution that I've been using for about a year now that I'm fairly certain you're going to like much better than what you're asking help with and best of all, I've prepared all the files for you and included everything that you'll need to get this navigation up and rolling. See the attached zip file to get all the files you'll need and see my notes within the code of the php file "SuperMenu.php".

I've got quite a few hours of development time in this navigation, so all I ask is that if you develop something that all of us may find useful - please share and collectively we'll all develop better websites.

So let's mix this cocktail and get you loaded.

Grab a cocktail mixer:

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
  /* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */
  
  // load viewer library
  $libraryPath = 'cmsbuilder/lib/viewer_functions.php';
  $dirsToCheck = array('/var/www/host/blablabla/httpdocs/blabla/','','../','../../','../../../');
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
  if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }
  
    // load record from 'yourpage1'
  list($yourpage1Records, $yourpage1MetaData) = getRecords(array(
    'tableName'   => 'yourpage1',
    //'where'       => '', // load first record
    'where'       => whereRecordNumberInUrl(0),
    'loadUploads' => true,
    'allowSearch' => false,
    'limit'       => '1',
  ));
  $yourpage1Record = @$yourpage1Records[0]; // get first record
  if (!$yourpage1Record) { dieWith404("Record not found!"); } // show error message if no record found
?>
<?php /*?>// You'll find it easier to manage all your navigation categories using the php require_once as seen below. So create your includes directory and place your php file navRecords.php within the includes directory, then place every instance of your navigation records within this file. Or just use the files I created for you and modify as needed.<?php */?>
<?php require_once("includes/navRecords.php"); ?>

Pour in a little navRecords.php ingredients into an includes directory:

<?php
    // load records yourpage1
    list($yourpage1NavRecords, $selectedCategory) = getCategories(array(
    'tableName'   => 'yourpage1',
    'categoryFormat' => 'showall'
    //'categoryFormat' => 'onelevel' // showall, onelevel, twolevel
  ));

    // load records yourpage2
    list($yourpage2NavRecords, $selectedCategory) = getCategories(array(
    'tableName'   => 'yourpage2',
    'categoryFormat' => 'showall'
    //'categoryFormat' => 'onelevel' // showall, onelevel, twolevel
  ));

    // load records yourpage3
    list($yourpage3NavRecords, $selectedCategory) = getCategories(array(
    'tableName'   => 'yourpage3',
    'categoryFormat' => 'showall'
    //'categoryFormat' => 'onelevel' // showall, onelevel, twolevel
  ));
?>

Pour in your CSS:

<style type="text/css">
/* Nav CSS */
#navigation {
    margin:0 auto;
    position:relative;
    width:980px;
    height:42px;
}
.sf-menu-clear {
    clear:both;
}
.sf-menu, .sf-menu * {
    color:#364049;
    margin:            0;
    padding:        0;
    list-style:        none;
}
.sf-menu {
    color:#FFF;
    line-height:    1.0;
}
.sf-menu ul {
    position:        absolute;
    top:            -999em;
    width:            10em; /* left offset of submenus need to match (see below) */
}
.sf-menu ul li {
    width:inherit;
    min-width:308px;
    /*min-width:225px;*/
}
.sf-menu li a {
    font-size:18px;
}
.sf-menu li:hover {
    visibility:        inherit; /* fixes IE7 'sticky bug' */
    color:#FFF;
    background-color:#9FB63B;
    text-decoration:none;
}
.sf-menu li:hover a {
    visibility:        inherit; /* fixes IE7 'sticky bug' */
    color:#FFF;
    background-color:#9FB63B;
    text-decoration:none;
}
.sf-menu li ul li a {
    font-size:16px;
}
.sf-menu li ul li:hover {
    visibility:        inherit; /* fixes IE7 'sticky bug' */
    color:#FFF;
    background-color:#364049;
    text-decoration:none;
}
.sf-menu li ul li:hover a {
    visibility:        inherit; /* fixes IE7 'sticky bug' */
    color:#FFF;
    background-color:#364049;
    text-decoration:none;
}


.sf-menu ul li ul li {
    width:inherit;
    margin-left:60px;
    /*left:0px;*/
    min-width:225px;
}
.sf-menu ul li ul li {
    visibility:        inherit; /* fixes IE7 'sticky bug' */
    color:#FFF;
    background-color:#9FB63B;
    text-decoration:none;
}
.sf-menu ul li ul li a {
    font-size:16px;
    visibility:        inherit; /* fixes IE7 'sticky bug' */
    color:#FFF;
    background-color:#9FB63B;
    text-decoration:none;
}
.sf-menu ul li ul li:hover {
    visibility:        inherit; /* fixes IE7 'sticky bug' */
    color:#FFF;
    background-color:#364049;
    text-decoration:none;
}
.sf-menu ul li ul li:hover a {
    visibility:        inherit; /* fixes IE7 'sticky bug' */
    color:#FFF;
    background-color:#364049;
    text-decoration:none;
}




.sf-menu li {
    float:            left;
    position:        relative;
}
.sf-menu a {
    display:        block;
    position:        relative;
}
.sf-menu li:hover ul,
.sf-menu li.sfHover ul {
    top:            46px; /* match top ul list item height */
    z-index:        99;
}
ul.sf-menu li:hover li ul,
ul.sf-menu li.sfHover li ul {
    top:            -999em;
}
ul.sf-menu li li:hover ul,
ul.sf-menu li li.sfHover ul {
    left:            10em; /* match ul width */
    top:            0;
}
ul.sf-menu li li:hover li ul,
ul.sf-menu li li.sfHover li ul {
    top:            -999em;
}
ul.sf-menu li li li:hover ul,
ul.sf-menu li li li.sfHover ul {
    left:            10em; /* match ul width */
    top:            0;
}
.sf-menu li:hover ul .align_right,
.sf-menu li:hover ul.align_right {
    left:auto;
    right:148px;
    /*right:-1px;
    left:auto;*/
}
.align_right {
    /*left:auto;
    right:-1px;*/
}
.sf-menu {
    float:left;
}
.sf-menu a {
    padding-left:24px;
    padding-right:24px;
    padding-top:14px;
    padding-bottom:14px;
    text-transform: none;
    font-weight: normal;
    text-decoration:none;
}
.sf-menu a, .sf-menu a:visited  { /* visited pseudo selector so IE6 applies text colour*/
}
</style>

Add a splash of jQuery:

<!-- scripts -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="js/hoverIntent.js"></script>
        <script type="text/javascript" src="js/supermenu.js"></script>
        <script type="text/javascript">
        // http://users.tpg.com.au/j_birch/plugins/superfish/#download
        // initialise plugins
        jQuery(function(){
            jQuery('ul.sf-menu').superfish();
        });

</script>

And fill your mixer with some great tasting navigation:

<div id="navigation">
    
    <ul class="sf-menu" style="min-width:980px;"><!-- supermenu -->   

        <?php foreach ($yourpage1NavRecords as $categoryRecord): ?> 
    <li><?php if ($categoryRecord['depth'] == 0): ?> 
    <?php if ($categoryRecord['redirect'] && $categoryRecord['open_redirect_in_new_window'] =='1'): ?>
    <!-- redirect -->
    <a href="<?php echo ($categoryRecord['redirect']) ?>" rel="nofollow" target="_blank" title="<?php echo $categoryRecord['name'] ?>"><?php echo $categoryRecord['name'] ?></a>
    <!-- /redirect -->
    <?php elseif ($categoryRecord['redirect'] && !$categoryRecord['open_redirect_in_new_window'] =='1'): ?>
    <!-- redirect -->
        <a href="<?php echo $categoryRecord['redirect'] ?>"><?php echo $categoryRecord['name'] ?></a>
    <!-- /redirect -->
    <?php else: ?>
        <a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a>
    <?php endif ?>
     <?php $parent=$categoryRecord['num'];?>
         <ul>
        <?php foreach ($yourpage1NavRecords as $categoryRecord): ?> 
        <?php if ($categoryRecord['parentNum'] == $parent): ?> 
            <?php if ($categoryRecord['redirect'] && $categoryRecord['open_redirect_in_new_window'] =='1'): ?>
            <!-- redirect -->
            <li><a href="<?php echo ($categoryRecord['redirect']) ?>" rel="nofollow" target="_blank" title="<?php echo $categoryRecord['name'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
            <!-- /redirect -->
            <?php elseif ($categoryRecord['redirect'] && !$categoryRecord['open_redirect_in_new_window'] =='1'): ?>
            <!-- redirect -->
            <li><a href="<?php echo $categoryRecord['redirect'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
            <!-- /redirect -->
            <?php else: ?>
            <li><a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
            <?php endif ?>
        <?php endif ?> 
        <?php endforeach; ?>
        </ul> 
    <?php endif ?><?php break; ?>
    </li>
    <?php endforeach; ?>
    
    
    <li><a href="drills_and_drillbits.php" title="Drills &amp; Drill Bits">Drills &amp; Drill Bits</a>
        <ul>
            <li><a href="drills.php" title="Drills" class="nav-common">Drills</a></li>
            <li><a href="drill_bits.php" title="Drill Bits" class="nav-common">Drill Bits</a></li>
        </ul>
    </li>
    
    
       <?php foreach ($yourpage2NavRecords as $categoryRecord): ?> 
    <li><?php if ($categoryRecord['depth'] == 0): ?> 
    <?php if ($categoryRecord['redirect'] && $categoryRecord['open_redirect_in_new_window'] =='1'): ?>
    <!-- redirect -->
    <a href="<?php echo ($categoryRecord['redirect']) ?>" rel="nofollow" target="_blank" title="<?php echo $categoryRecord['name'] ?>"><?php echo $categoryRecord['name'] ?></a>
    <!-- /redirect -->
    <?php elseif ($categoryRecord['redirect'] && !$categoryRecord['open_redirect_in_new_window'] =='1'): ?>
    <!-- redirect -->
        <a href="<?php echo $categoryRecord['redirect'] ?>"><?php echo $categoryRecord['name'] ?></a>
    <!-- /redirect -->
    <?php else: ?>
        <a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a>
    <?php endif ?>
     <?php $parent=$categoryRecord['num'];?>
         <ul>
        <?php foreach ($yourpage2NavRecords as $categoryRecord): ?> 
        <?php if ($categoryRecord['parentNum'] == $parent): ?> 
            <?php if ($categoryRecord['redirect'] && $categoryRecord['open_redirect_in_new_window'] =='1'): ?>
            <!-- redirect -->
            <li><a href="<?php echo ($categoryRecord['redirect']) ?>" rel="nofollow" target="_blank" title="<?php echo $categoryRecord['name'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
            <!-- /redirect -->
            <?php elseif ($categoryRecord['redirect'] && !$categoryRecord['open_redirect_in_new_window'] =='1'): ?>
            <!-- redirect -->
            <li><a href="<?php echo $categoryRecord['redirect'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
            <!-- /redirect -->
            <?php else: ?>
            <li><a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
            <?php endif ?>
        <?php endif ?> 
        <?php endforeach; ?>
        </ul> 
    <?php endif ?><?php break; ?>
    </li>
    <?php endforeach; ?>
    
    
       <?php foreach ($yourpage3NavRecords as $categoryRecord): ?> 
    <li><?php if ($categoryRecord['depth'] == 0): ?> 
    <?php if ($categoryRecord['redirect'] && $categoryRecord['open_redirect_in_new_window'] =='1'): ?>
    <!-- redirect -->
    <a href="<?php echo ($categoryRecord['redirect']) ?>" rel="nofollow" target="_blank" title="<?php echo $categoryRecord['name'] ?>"><?php echo $categoryRecord['name'] ?></a>
    <!-- /redirect -->
    <?php elseif ($categoryRecord['redirect'] && !$categoryRecord['open_redirect_in_new_window'] =='1'): ?>
    <!-- redirect -->
        <a href="<?php echo $categoryRecord['redirect'] ?>"><?php echo $categoryRecord['name'] ?></a>
    <!-- /redirect -->
    <?php else: ?>
        <a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a>
    <?php endif ?>
     <?php $parent=$categoryRecord['num'];?>
         <ul>
        <?php foreach ($yourpage3NavRecords as $categoryRecord): ?> 
        <?php if ($categoryRecord['parentNum'] == $parent): ?> 
            <?php if ($categoryRecord['redirect'] && $categoryRecord['open_redirect_in_new_window'] =='1'): ?>
            <!-- redirect -->
            <li><a href="<?php echo ($categoryRecord['redirect']) ?>" rel="nofollow" target="_blank" title="<?php echo $categoryRecord['name'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
            <!-- /redirect -->
            <?php elseif ($categoryRecord['redirect'] && !$categoryRecord['open_redirect_in_new_window'] =='1'): ?>
            <!-- redirect -->
            <li><a href="<?php echo $categoryRecord['redirect'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
            <!-- /redirect -->
            <?php else: ?>
            <li><a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
            <?php endif ?>
        <?php endif ?> 
        <?php endforeach; ?>
        </ul> 
    <?php endif ?><?php break; ?>
    </li>
    <?php endforeach; ?>
    
    
    <li><a href="contact.php" title="Contact">Contact</a></li>
       
    <!-- /supermenu --></ul>
    
    
    <div class="sf-menu-clear"></div>
      <!-- /navigation --></div>
    
    <div style="clear:both"></div>

This has worked well for me and has some fairly neat functions built into it. I think I've got everything packaged up in the zip file that you'll need to get this function.

Now it's time for you to shake the cocktail...

In your category record create a text field type called "redirect".
In your category record create a check box field type called "open_redirect_in_new_window".

These two fields provide a solution to redirect your category page to a different site page within your website. You can also click the check box to launch the redirect into a new window for websites that may not be part of the website you're building, such as a link to LinkedIn, Tumblr, Twitter and that colossal waste of time called Facebook. I'm looking forward to that dinosaur's extinction.

Now it's time to drink it all in and get hammered with a tall pint of Supermenu:

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
  /* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */
  
  // load viewer library
  $libraryPath = 'cmsbuilder/lib/viewer_functions.php';
  $dirsToCheck = array('/var/www/host/blablabla/httpdocs/blabla/','','../','../../','../../../');
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
  if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }
  
    // load record from 'yourpage1'
  list($yourpage1Records, $yourpage1MetaData) = getRecords(array(
    'tableName'   => 'yourpage1',
    //'where'       => '', // load first record
    'where'       => whereRecordNumberInUrl(0),
    'loadUploads' => true,
    'allowSearch' => false,
    'limit'       => '1',
  ));
  $yourpage1Record = @$yourpage1Records[0]; // get first record
  if (!$yourpage1Record) { dieWith404("Record not found!"); } // show error message if no record found
?>
<?php /*?>// You'll find it easier to manage all your navigation categories using the php require_once as seen below. So create your includes directory and place your php file navRecords.php within the includes directory, then place every instance of your navigation records within this file. Or just use the files I created for you and modify as needed.<?php */?>
<?php require_once("includes/navRecords.php"); ?>

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>SuperMenu</title>

<link rel="stylesheet" type="text/css" href="css/supermenu.css" media="screen" />

<!-- scripts -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="js/hoverIntent.js"></script>
        <script type="text/javascript" src="js/supermenu.js"></script>
        <script type="text/javascript">
        // http://users.tpg.com.au/j_birch/plugins/superfish/#download
        // initialise plugins
        jQuery(function(){
            jQuery('ul.sf-menu').superfish();
        });

</script>

</head>

<body>

<div id="navigation">
    
    <ul class="sf-menu" style="min-width:980px;"><!-- supermenu -->   

        <?php foreach ($yourpage1NavRecords as $categoryRecord): ?> 
    <li><?php if ($categoryRecord['depth'] == 0): ?> 
    <?php if ($categoryRecord['redirect'] && $categoryRecord['open_redirect_in_new_window'] =='1'): ?>
    <!-- redirect -->
    <a href="<?php echo ($categoryRecord['redirect']) ?>" rel="nofollow" target="_blank" title="<?php echo $categoryRecord['name'] ?>"><?php echo $categoryRecord['name'] ?></a>
    <!-- /redirect -->
    <?php elseif ($categoryRecord['redirect'] && !$categoryRecord['open_redirect_in_new_window'] =='1'): ?>
    <!-- redirect -->
        <a href="<?php echo $categoryRecord['redirect'] ?>"><?php echo $categoryRecord['name'] ?></a>
    <!-- /redirect -->
    <?php else: ?>
        <a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a>
    <?php endif ?>
     <?php $parent=$categoryRecord['num'];?>
         <ul>
        <?php foreach ($yourpage1NavRecords as $categoryRecord): ?> 
        <?php if ($categoryRecord['parentNum'] == $parent): ?> 
            <?php if ($categoryRecord['redirect'] && $categoryRecord['open_redirect_in_new_window'] =='1'): ?>
            <!-- redirect -->
            <li><a href="<?php echo ($categoryRecord['redirect']) ?>" rel="nofollow" target="_blank" title="<?php echo $categoryRecord['name'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
            <!-- /redirect -->
            <?php elseif ($categoryRecord['redirect'] && !$categoryRecord['open_redirect_in_new_window'] =='1'): ?>
            <!-- redirect -->
            <li><a href="<?php echo $categoryRecord['redirect'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
            <!-- /redirect -->
            <?php else: ?>
            <li><a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
            <?php endif ?>
        <?php endif ?> 
        <?php endforeach; ?>
        </ul> 
    <?php endif ?><?php break; ?>
    </li>
    <?php endforeach; ?>
    
    
    <li><a href="drills_and_drillbits.php" title="Drills &amp; Drill Bits">Drills &amp; Drill Bits</a>
        <ul>
            <li><a href="drills.php" title="Drills" class="nav-common">Drills</a></li>
            <li><a href="drill_bits.php" title="Drill Bits" class="nav-common">Drill Bits</a></li>
        </ul>
    </li>
    
    
       <?php foreach ($yourpage2NavRecords as $categoryRecord): ?> 
    <li><?php if ($categoryRecord['depth'] == 0): ?> 
    <?php if ($categoryRecord['redirect'] && $categoryRecord['open_redirect_in_new_window'] =='1'): ?>
    <!-- redirect -->
    <a href="<?php echo ($categoryRecord['redirect']) ?>" rel="nofollow" target="_blank" title="<?php echo $categoryRecord['name'] ?>"><?php echo $categoryRecord['name'] ?></a>
    <!-- /redirect -->
    <?php elseif ($categoryRecord['redirect'] && !$categoryRecord['open_redirect_in_new_window'] =='1'): ?>
    <!-- redirect -->
        <a href="<?php echo $categoryRecord['redirect'] ?>"><?php echo $categoryRecord['name'] ?></a>
    <!-- /redirect -->
    <?php else: ?>
        <a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a>
    <?php endif ?>
     <?php $parent=$categoryRecord['num'];?>
         <ul>
        <?php foreach ($yourpage2NavRecords as $categoryRecord): ?> 
        <?php if ($categoryRecord['parentNum'] == $parent): ?> 
            <?php if ($categoryRecord['redirect'] && $categoryRecord['open_redirect_in_new_window'] =='1'): ?>
            <!-- redirect -->
            <li><a href="<?php echo ($categoryRecord['redirect']) ?>" rel="nofollow" target="_blank" title="<?php echo $categoryRecord['name'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
            <!-- /redirect -->
            <?php elseif ($categoryRecord['redirect'] && !$categoryRecord['open_redirect_in_new_window'] =='1'): ?>
            <!-- redirect -->
            <li><a href="<?php echo $categoryRecord['redirect'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
            <!-- /redirect -->
            <?php else: ?>
            <li><a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
            <?php endif ?>
        <?php endif ?> 
        <?php endforeach; ?>
        </ul> 
    <?php endif ?><?php break; ?>
    </li>
    <?php endforeach; ?>
    
    
       <?php foreach ($yourpage3NavRecords as $categoryRecord): ?> 
    <li><?php if ($categoryRecord['depth'] == 0): ?> 
    <?php if ($categoryRecord['redirect'] && $categoryRecord['open_redirect_in_new_window'] =='1'): ?>
    <!-- redirect -->
    <a href="<?php echo ($categoryRecord['redirect']) ?>" rel="nofollow" target="_blank" title="<?php echo $categoryRecord['name'] ?>"><?php echo $categoryRecord['name'] ?></a>
    <!-- /redirect -->
    <?php elseif ($categoryRecord['redirect'] && !$categoryRecord['open_redirect_in_new_window'] =='1'): ?>
    <!-- redirect -->
        <a href="<?php echo $categoryRecord['redirect'] ?>"><?php echo $categoryRecord['name'] ?></a>
    <!-- /redirect -->
    <?php else: ?>
        <a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a>
    <?php endif ?>
     <?php $parent=$categoryRecord['num'];?>
         <ul>
        <?php foreach ($yourpage3NavRecords as $categoryRecord): ?> 
        <?php if ($categoryRecord['parentNum'] == $parent): ?> 
            <?php if ($categoryRecord['redirect'] && $categoryRecord['open_redirect_in_new_window'] =='1'): ?>
            <!-- redirect -->
            <li><a href="<?php echo ($categoryRecord['redirect']) ?>" rel="nofollow" target="_blank" title="<?php echo $categoryRecord['name'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
            <!-- /redirect -->
            <?php elseif ($categoryRecord['redirect'] && !$categoryRecord['open_redirect_in_new_window'] =='1'): ?>
            <!-- redirect -->
            <li><a href="<?php echo $categoryRecord['redirect'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
            <!-- /redirect -->
            <?php else: ?>
            <li><a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
            <?php endif ?>
        <?php endif ?> 
        <?php endforeach; ?>
        </ul> 
    <?php endif ?><?php break; ?>
    </li>
    <?php endforeach; ?>
    
    
    <li><a href="contact.php" title="Contact">Contact</a></li>
       
    <!-- /supermenu --></ul>
    
    
    <div class="sf-menu-clear"></div>
      <!-- /navigation --></div>
    
    <div style="clear:both"></div><br />
    
    <h1>This has worked well for me and has some fairly neat functions built into it. I think I've got everything packaged up in the zip file that you'll need to get this function.</h1>
<h2 style="font-weight:200;">In your category record create a <strong>text</strong> field type called "<strong>redirect</strong>".<br>
In your category record create a <strong>check box</strong> field type called "<strong>open_redirect_in_new_window</strong>".</h2>

<p>These two fields provide a solution to <strong>redirect</strong> your category page to a different site page within your website. You can also click the check box to <strong>launch the redirect into a new window</strong> for websites that may not be part of the website you're building, such as a link to LinkedIn, Tumblr, Twitter and that colossal waste of time - the dinosaur called Facebook, looking forward to it's extinction.</p>

</body>
</html>

Attachments:

supermenu.zip 10K

By drewh01 - January 24, 2014

wow - that's huge. Looks very nice.

i tried to pull this part of the code that I thought was relevant to what I am trying to do and modified it to match my category table:  pages1

But - I get this error:  Notice: Undefined variable: pages1NavRecords in /home/illumina/public_html/includes/nav.php on line 4 Warning: Invalid argument supplied for foreach() in /home/illumina/public_html/includes/nav.php on line 4

---------------------------
<div id="nav">

<ul class="sf-menu" id="example">
<?php foreach ($pages1NavRecords as $categoryRecord): ?>
<li><?php if ($categoryRecord['depth'] == 0): ?>
<?php if ($categoryRecord['redirect'] && $categoryRecord['open_redirect_in_new_window'] =='1'): ?>
<!-- redirect -->
<a href="<?php echo ($categoryRecord['redirect']) ?>" rel="nofollow" target="_blank" title="<?php echo $categoryRecord['name'] ?>"><?php echo $categoryRecord['name'] ?></a>
<!-- /redirect -->
<?php elseif ($categoryRecord['redirect'] && !$categoryRecord['open_redirect_in_new_window'] =='1'): ?>
<!-- redirect -->
<a href="<?php echo $categoryRecord['redirect'] ?>"><?php echo $categoryRecord['name'] ?></a>
<!-- /redirect -->
<?php else: ?>
<a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a>
<?php endif ?>
<?php $parent=$categoryRecord['num'];?>
<ul>
<?php foreach ($pages1NavRecords as $categoryRecord): ?>
<?php if ($categoryRecord['parentNum'] == $parent): ?>
<?php if ($categoryRecord['redirect'] && $categoryRecord['open_redirect_in_new_window'] =='1'): ?>
<!-- redirect -->
<li><a href="<?php echo ($categoryRecord['redirect']) ?>" rel="nofollow" target="_blank" title="<?php echo $categoryRecord['name'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
<!-- /redirect -->
<?php elseif ($categoryRecord['redirect'] && !$categoryRecord['open_redirect_in_new_window'] =='1'): ?>
<!-- redirect -->
<li><a href="<?php echo $categoryRecord['redirect'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
<!-- /redirect -->
<?php else: ?>
<li><a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
<?php endif ?>
<?php endif ?>
<?php endforeach; ?>
</ul>
<?php endif ?><?php break; ?>
</li>
<?php endforeach; ?>

</ul>
<p style="clear:both;">&nbsp;</p>

</div><!--end nav-->

By Mikey - January 24, 2014 - edited: January 24, 2014

Can you include a little more code showing what you placed within the nav.php and how you linked to the nav.php as the include/nav.php ... we're looking for what's producing the error on line 4. Also, I've never actually used a number in a record name before such as "page1" and I'm a bit curious if that may be part of the issue or not... maybe someone else can confirm that's it's okay to use a number in a category section editor name.

But the code you have used all looks good at a double glance over, so I think there's something conflicting in your :

<?php require_once("includes/navRecords.php"); ?>

By drewh01 - January 24, 2014

Attached is my nav.php file and below is my load records. I also changed the 'pages1' --> to 'pages' and removed the number just in case.

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
/* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */

// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/home/illumina/public_html/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

// load record from 'home_page_content'
list($home_page_contentRecords, $home_page_contentMetaData) = getRecords(array(
'tableName' => 'home_page_content',
'where' => '', // load first record
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
));
$home_page_contentRecord = @$home_page_contentRecords[0]; // get first record
if (!$home_page_contentRecord) { dieWith404("Record not found!"); } // show error message if no record found

// load detail record from 'pages'
list($pagesRecords, $pagesMetaData) = getRecords(array(
'tableName' => 'pages',
'where' => whereRecordNumberInUrl(1), // If no record # is specified then latest record is shown
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
));

$detailRecord = @$pagesRecords[0]; // get first record
if (!$detailRecord) { dieWith404("Record not found!"); } // show error message if no record found

?>

Attachments:

nav_004.php 3K

By Mikey - January 24, 2014

I think I see where the issue is... you're not calling to the pageNavRecords used in the actual navigation. See the code below and I think it will fix things up for you.

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
 /* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */

 // load viewer library
 $libraryPath = 'cmsAdmin/lib/viewer_functions.php';
 $dirsToCheck = array('/home/illumina/public_html/','','../','../../','../../../');
 foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
 if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }


// load record from 'home_page_content'
 list($home_page_contentRecords, $home_page_contentMetaData) = getRecords(array(
 'tableName' => 'home_page_content',
 'where' => '', // load first record
 'loadUploads' => true,
 'allowSearch' => false,
 'limit' => '1',
 ));
 $home_page_contentRecord = @$home_page_contentRecords[0]; // get first record
 if (!$home_page_contentRecord) { dieWith404("Record not found!"); } // show error message if no record found

 // load detail record from 'pages'
 list($pagesRecords, $pagesMetaData) = getRecords(array(
 'tableName' => 'pages',
 'where' => whereRecordNumberInUrl(1), // If no record # is specified then latest record is shown
 'loadUploads' => true,
 'allowSearch' => false,
 'limit' => '1',
 ));

 $detailRecord = @$pagesRecords[0]; // get first record
 if (!$detailRecord) { dieWith404("Record not found!"); } // show error message if no record found


    // load records pages
    list($pagesNavRecords, $selectedCategory) = getCategories(array(
    'tableName'   => 'pages',
    'categoryFormat' => 'showall'
    //'categoryFormat' => 'onelevel' // showall, onelevel, twolevel
  ));


?>

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>SuperMenu</title>

<link rel="stylesheet" type="text/css" href="css/supermenu.css" media="screen" />

<!-- scripts -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="js/hoverIntent.js"></script>
        <script type="text/javascript" src="js/supermenu.js"></script>
        <script type="text/javascript">
        // http://users.tpg.com.au/j_birch/plugins/superfish/#download
        // initialise plugins
        jQuery(function(){
            jQuery('ul.sf-menu').superfish();
        });

</script>

</head>

<body>

<div id="navigation">
    
    <ul class="sf-menu" style="min-width:980px;"><!-- supermenu -->   

        <?php foreach ($pagesNavRecords as $categoryRecord): ?> 
    <li><?php if ($categoryRecord['depth'] == 0): ?> 
    <?php if ($categoryRecord['redirect'] && $categoryRecord['open_redirect_in_new_window'] =='1'): ?>
    <!-- redirect -->
    <a href="<?php echo ($categoryRecord['redirect']) ?>" rel="nofollow" target="_blank" title="<?php echo $categoryRecord['name'] ?>"><?php echo $categoryRecord['name'] ?></a>
    <!-- /redirect -->
    <?php elseif ($categoryRecord['redirect'] && !$categoryRecord['open_redirect_in_new_window'] =='1'): ?>
    <!-- redirect -->
        <a href="<?php echo $categoryRecord['redirect'] ?>"><?php echo $categoryRecord['name'] ?></a>
    <!-- /redirect -->
    <?php else: ?>
        <a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a>
    <?php endif ?>
     <?php $parent=$categoryRecord['num'];?>
         <ul>
        <?php foreach ($pagesNavRecords as $categoryRecord): ?> 
        <?php if ($categoryRecord['parentNum'] == $parent): ?> 
            <?php if ($categoryRecord['redirect'] && $categoryRecord['open_redirect_in_new_window'] =='1'): ?>
            <!-- redirect -->
            <li><a href="<?php echo ($categoryRecord['redirect']) ?>" rel="nofollow" target="_blank" title="<?php echo $categoryRecord['name'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
            <!-- /redirect -->
            <?php elseif ($categoryRecord['redirect'] && !$categoryRecord['open_redirect_in_new_window'] =='1'): ?>
            <!-- redirect -->
            <li><a href="<?php echo $categoryRecord['redirect'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
            <!-- /redirect -->
            <?php else: ?>
            <li><a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
            <?php endif ?>
        <?php endif ?> 
        <?php endforeach; ?>
        </ul> 
    <?php endif ?><?php break; ?>
    </li>
    <?php endforeach; ?>
    
    
    <li><a href="drills_and_drillbits.php" title="Drills &amp; Drill Bits">Drills &amp; Drill Bits</a>
        <ul>
            <li><a href="drills.php" title="Drills" class="nav-common">Drills</a></li>
            <li><a href="drill_bits.php" title="Drill Bits" class="nav-common">Drill Bits</a></li>
        </ul>
    </li>
    
    <li><a href="contact.php" title="Contact">Contact</a></li>
       
    <!-- /supermenu --></ul>
    
    
    <div class="sf-menu-clear"></div>
      <!-- /navigation --></div>
    
    <div style="clear:both"></div><br />
    
    <h1>This has worked well for me and has some fairly neat functions built into it. I think I've got everything packaged up in the zip file that you'll need to get this function.</h1>
<h2 style="font-weight:200;">In your category record create a <strong>text</strong> field type called "<strong>redirect</strong>".<br>
In your category record create a <strong>check box</strong> field type called "<strong>open_redirect_in_new_window</strong>".</h2>

<p>These two fields provide a solution to <strong>redirect</strong> your category page to a different site page within your website. You can also click the check box to <strong>launch the redirect into a new window</strong> for websites that may not be part of the website you're building, such as a link to LinkedIn, Tumblr, Twitter and that colossal waste of time - the dinosaur called Facebook, looking forward to it's extinction.</p>

</body>
</html>

By Mikey - January 24, 2014

So this navigation structure was originally built to use one top tier parent category, with subcategories to create the secondary site pages of the singular parent category page. Then I created an entirely new category in the section editor for my next set of site pages. But you could try adding a second top tier with sub pages to the same "pages" section record such as seen below and see if it creates your second top tier navigation:

Parent Top Tier

  • Sub page
  • Sub page two
  • Sub page three

Parent Top Tier 2

  • Sub page of 2
  • Sub page two of 2
  • Sub page three of 2

If that doesn't work, then you could follow my method which this was built for and powered by individual category pages per section of the site, with sub categories of a single parent category. Such as seen below:

Products (your first category section editor record)

  • Sub page one of Products
  • Sub page two of Products
  • Sub page three of Products

Services (your second category section editor record)

  • Sub page of Services
  • Sub page two of Services
  • Sub page three of Services

And you'd load these as so:

    // load records products
    list($productsNavRecords, $selectedCategory) = getCategories(array(
    'tableName'   => 'products',
    'categoryFormat' => 'showall'
    //'categoryFormat' => 'onelevel' // showall, onelevel, twolevel
  ));

    // load records services
    list($servicesNavRecords, $selectedCategory) = getCategories(array(
    'tableName'   => 'services',
    'categoryFormat' => 'showall'
    //'categoryFormat' => 'onelevel' // showall, onelevel, twolevel
  ));

and your navigation would look like this:

<div id="navigation">
    
    <ul class="sf-menu" style="min-width:980px;"><!-- supermenu -->   

        <?php foreach ($productsNavRecords as $categoryRecord): ?> 
    <li><?php if ($categoryRecord['depth'] == 0): ?> 
    <?php if ($categoryRecord['redirect'] && $categoryRecord['open_redirect_in_new_window'] =='1'): ?>
    <!-- redirect -->
    <a href="<?php echo ($categoryRecord['redirect']) ?>" rel="nofollow" target="_blank" title="<?php echo $categoryRecord['name'] ?>"><?php echo $categoryRecord['name'] ?></a>
    <!-- /redirect -->
    <?php elseif ($categoryRecord['redirect'] && !$categoryRecord['open_redirect_in_new_window'] =='1'): ?>
    <!-- redirect -->
        <a href="<?php echo $categoryRecord['redirect'] ?>"><?php echo $categoryRecord['name'] ?></a>
    <!-- /redirect -->
    <?php else: ?>
        <a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a>
    <?php endif ?>
     <?php $parent=$categoryRecord['num'];?>
         <ul>
        <?php foreach ($productsNavRecords as $categoryRecord): ?> 
        <?php if ($categoryRecord['parentNum'] == $parent): ?> 
            <?php if ($categoryRecord['redirect'] && $categoryRecord['open_redirect_in_new_window'] =='1'): ?>
            <!-- redirect -->
            <li><a href="<?php echo ($categoryRecord['redirect']) ?>" rel="nofollow" target="_blank" title="<?php echo $categoryRecord['name'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
            <!-- /redirect -->
            <?php elseif ($categoryRecord['redirect'] && !$categoryRecord['open_redirect_in_new_window'] =='1'): ?>
            <!-- redirect -->
            <li><a href="<?php echo $categoryRecord['redirect'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
            <!-- /redirect -->
            <?php else: ?>
            <li><a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
            <?php endif ?>
        <?php endif ?> 
        <?php endforeach; ?>
        </ul> 
    <?php endif ?><?php break; ?>
    </li>
    <?php endforeach; ?>
    
    
    <li><a href="drills_and_drillbits.php" title="Drills &amp; Drill Bits">Drills &amp; Drill Bits</a>
        <ul>
            <li><a href="drills.php" title="Drills" class="nav-common">Drills</a></li>
            <li><a href="drill_bits.php" title="Drill Bits" class="nav-common">Drill Bits</a></li>
        </ul>
    </li>

<?php foreach ($servicesNavRecords as $categoryRecord): ?> 
    <li><?php if ($categoryRecord['depth'] == 0): ?> 
    <?php if ($categoryRecord['redirect'] && $categoryRecord['open_redirect_in_new_window'] =='1'): ?>
    <!-- redirect -->
    <a href="<?php echo ($categoryRecord['redirect']) ?>" rel="nofollow" target="_blank" title="<?php echo $categoryRecord['name'] ?>"><?php echo $categoryRecord['name'] ?></a>
    <!-- /redirect -->
    <?php elseif ($categoryRecord['redirect'] && !$categoryRecord['open_redirect_in_new_window'] =='1'): ?>
    <!-- redirect -->
        <a href="<?php echo $categoryRecord['redirect'] ?>"><?php echo $categoryRecord['name'] ?></a>
    <!-- /redirect -->
    <?php else: ?>
        <a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a>
    <?php endif ?>
     <?php $parent=$categoryRecord['num'];?>
         <ul>
        <?php foreach ($servicesNavRecords as $categoryRecord): ?> 
        <?php if ($categoryRecord['parentNum'] == $parent): ?> 
            <?php if ($categoryRecord['redirect'] && $categoryRecord['open_redirect_in_new_window'] =='1'): ?>
            <!-- redirect -->
            <li><a href="<?php echo ($categoryRecord['redirect']) ?>" rel="nofollow" target="_blank" title="<?php echo $categoryRecord['name'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
            <!-- /redirect -->
            <?php elseif ($categoryRecord['redirect'] && !$categoryRecord['open_redirect_in_new_window'] =='1'): ?>
            <!-- redirect -->
            <li><a href="<?php echo $categoryRecord['redirect'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
            <!-- /redirect -->
            <?php else: ?>
            <li><a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
            <?php endif ?>
        <?php endif ?> 
        <?php endforeach; ?>
        </ul> 
    <?php endif ?><?php break; ?>
    </li>
    <?php endforeach; ?>
    
    <li><a href="contact.php" title="Contact">Contact</a></li>
       
    <!-- /supermenu --></ul>
    
    
    <div class="sf-menu-clear"></div>
      <!-- /navigation --></div>
    
    <div style="clear:both"></div><br />

See where this is going?

By drewh01 - January 24, 2014

Yes, I have a single category viewer page which has a structure like the attached. I'd like to keep everything contained in that one area so I can re-order the nav display for the site within the CMS. I have done this before, but am a bit limited with my knowledge so thanks for helping me out.

By Mikey - January 24, 2014

Okay, so you'll be using a single category, with multiple top tiers and each top tier may have x amount of sub category pages under them. The top teirs will be what appears in the main navigation across the top. And below is the fix to make this work. Just delete the instance of  <?php break; ?>  as seen in bold below and you should be set.

<div id="navigation">
    
    <ul class="sf-menu" style="min-width:980px;"><!-- supermenu -->   

        <?php foreach ($productsNavRecords as $categoryRecord): ?> 
    <li><?php if ($categoryRecord['depth'] == 0): ?> 
    <?php if ($categoryRecord['redirect'] && $categoryRecord['open_redirect_in_new_window'] =='1'): ?>
    <!-- redirect -->
    <a href="<?php echo ($categoryRecord['redirect']) ?>" rel="nofollow" target="_blank" title="<?php echo $categoryRecord['name'] ?>"><?php echo $categoryRecord['name'] ?></a>
    <!-- /redirect -->
    <?php elseif ($categoryRecord['redirect'] && !$categoryRecord['open_redirect_in_new_window'] =='1'): ?>
    <!-- redirect -->
        <a href="<?php echo $categoryRecord['redirect'] ?>"><?php echo $categoryRecord['name'] ?></a>
    <!-- /redirect -->
    <?php else: ?>
        <a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a>
    <?php endif ?>
     <?php $parent=$categoryRecord['num'];?>
         <ul>
        <?php foreach ($productsNavRecords as $categoryRecord): ?> 
        <?php if ($categoryRecord['parentNum'] == $parent): ?> 
            <?php if ($categoryRecord['redirect'] && $categoryRecord['open_redirect_in_new_window'] =='1'): ?>
            <!-- redirect -->
            <li><a href="<?php echo ($categoryRecord['redirect']) ?>" rel="nofollow" target="_blank" title="<?php echo $categoryRecord['name'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
            <!-- /redirect -->
            <?php elseif ($categoryRecord['redirect'] && !$categoryRecord['open_redirect_in_new_window'] =='1'): ?>
            <!-- redirect -->
            <li><a href="<?php echo $categoryRecord['redirect'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
            <!-- /redirect -->
            <?php else: ?>
            <li><a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
            <?php endif ?>
        <?php endif ?> 
        <?php endforeach; ?>
        </ul> 
    <?php endif ?><?php break; ?>
    </li>
    <?php endforeach; ?>
    
    
    <li><a href="drills_and_drillbits.php" title="Drills &amp; Drill Bits">Drills &amp; Drill Bits</a>
        <ul>
            <li><a href="drills.php" title="Drills" class="nav-common">Drills</a></li>
            <li><a href="drill_bits.php" title="Drill Bits" class="nav-common">Drill Bits</a></li>
        </ul>
    </li>

<?php foreach ($servicesNavRecords as $categoryRecord): ?> 
    <li><?php if ($categoryRecord['depth'] == 0): ?> 
    <?php if ($categoryRecord['redirect'] && $categoryRecord['open_redirect_in_new_window'] =='1'): ?>
    <!-- redirect -->
    <a href="<?php echo ($categoryRecord['redirect']) ?>" rel="nofollow" target="_blank" title="<?php echo $categoryRecord['name'] ?>"><?php echo $categoryRecord['name'] ?></a>
    <!-- /redirect -->
    <?php elseif ($categoryRecord['redirect'] && !$categoryRecord['open_redirect_in_new_window'] =='1'): ?>
    <!-- redirect -->
        <a href="<?php echo $categoryRecord['redirect'] ?>"><?php echo $categoryRecord['name'] ?></a>
    <!-- /redirect -->
    <?php else: ?>
        <a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a>
    <?php endif ?>
     <?php $parent=$categoryRecord['num'];?>
         <ul>
        <?php foreach ($servicesNavRecords as $categoryRecord): ?> 
        <?php if ($categoryRecord['parentNum'] == $parent): ?> 
            <?php if ($categoryRecord['redirect'] && $categoryRecord['open_redirect_in_new_window'] =='1'): ?>
            <!-- redirect -->
            <li><a href="<?php echo ($categoryRecord['redirect']) ?>" rel="nofollow" target="_blank" title="<?php echo $categoryRecord['name'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
            <!-- /redirect -->
            <?php elseif ($categoryRecord['redirect'] && !$categoryRecord['open_redirect_in_new_window'] =='1'): ?>
            <!-- redirect -->
            <li><a href="<?php echo $categoryRecord['redirect'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
            <!-- /redirect -->
            <?php else: ?>
            <li><a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a></li>
            <?php endif ?>
        <?php endif ?> 
        <?php endforeach; ?>
        </ul> 
    <?php endif ?><?php break; ?>
    </li>
    <?php endforeach; ?>
    
    <li><a href="contact.php" title="Contact">Contact</a></li>
       
    <!-- /supermenu --></ul>
    
    
    <div class="sf-menu-clear"></div>
      <!-- /navigation --></div>
    
    <div style="clear:both"></div><br />