Active menu, and submenu

9 posts by 3 authors in: Forums > CMS Builder
Last Post: January 30, 2009   (RSS)

How could I make it so that when I have.. let's say 2-3 level menu and have chosen from the website a link from second menu level.

I would like the first level link to be active (eg bold) as well as the second level link from the selected ones.

Thank you,
Martin

Re: [solar_sys] Active menu, and submenu

By Kenny - January 29, 2009

Martin,

Are you talking about the program itself or menus that you are creating on your website? If you are talking about your website, you will need to pick out (or write your own) a menu script that you would want to use. This would be our mock-up. From there, it may be possible to implement automatic menu building from CMS depending on the code we are looking at.

Try going here: http://www.dynamicdrive.com/dynamicindex1/index.html or http://www.javascriptkit.com/script/cutindex23.shtml and looking at these menu scripts.

Let us know what you find

Kenny

Re: [sagentic] Active menu, and submenu

First level;

<?php foreach ($lehe_ylesehitusRecords as $categoryRecord): ?>

<?php if (!$categoryRecord['depth'] && $categoryRecord['_isSelected']): ?>
<a href="<?php echo $categoryRecord['_link'] ?>"><font color="#4D0267"><?php echo $categoryRecord['name'] ?></font></a><br />
<?php endif; ?>

<?php if (!$categoryRecord['depth'] && !$categoryRecord['_isSelected']): ?>
<a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a><br />
<?php endif; ?>

<?php endforeach; ?>

Second level, is in another place;

<?php foreach ($lehe_ylesehitusRecords as $categoryRecord): ?>

<?php if ($categoryRecord['_isSelected'] && $categoryRecord['depth']): ?>
<a href="<?php echo $categoryRecord['_link'] ?>"><font color="#4D0267"><?php echo $categoryRecord['name'] ?></font></a><br />
<?php endif; ?>

<?php if (!$categoryRecord['_isSelected'] && $categoryRecord['depth']): ?>
<a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a><br />
<?php endif; ?>

<?php endforeach; ?>

The second level menu is in the first level category. I would like the first level menu text to be marked as active when the second level menu is selected from this category.

Re: [Dave] Active menu, and submenu

By solar_sys - January 29, 2009 - edited: January 29, 2009

That's good. It worked. There is one more thing I would like to get working. It is shortcuting - i have made a structure category section in admin. It has a list like this.... SELECT num, name FROM cms_lehe_ylesehitus .... with number and name. I have the same menu but i would like it to act so that when I choose a page from the list of my meny structure then it forwards a page to the second level page... it helps to avoid empty pages in the first level, instead it links the first level page to second level page.

Re: [solar_sys] Active menu, and submenu

<?php if (!$categoryRecord['depth'] && !$categoryRecord['_isSelected'] && !$isChildSelected && $categoryRecord['suuna_lehele'] != 0): ?>
<a href="<?php echo 'index.php?'.$categoryRecord['suuna_lehele'] ?>"><?php echo $categoryRecord['name'] ?></a><br />
<?php endif; ?>

<?php if (!$categoryRecord['depth'] && !$categoryRecord['_isSelected'] && !$isChildSelected && !$categoryRecord['suuna_lehele']): ?>
<a href="<?php echo 'index.php?'.$categoryRecord['num'] ?>"><?php echo $categoryRecord['name'] ?></a><br />
<?php endif; ?>

Got it working like this! :)

Re: [solar_sys] Active menu, and submenu

One thing, that annoys me is the endless amount of whitespace characters in the source from browser view and that the code generator uses spaces instead of tabs. My index.php is nicely tab'ed and very correct, but in the view source the code is flooded with white space.

Re: [solar_sys] Active menu, and submenu

Dave - thank you for the sample code - it was really helpful! :)

Re: [solar_sys] Active menu, and submenu

By Dave - January 30, 2009

No worries. I wasn't sure from all your posts, did you figure everything out or did you still need help with anything?

Regarding tabs vs. spaces, everyone has different preferences. The main reason we use spaces over tabs is because people have different tab widths specified. Sometimes you can get programs that automatically reformat your code to your preferences.

Anyways, let me know if you still have any outstanding issues.
Dave Edis - Senior Developer
interactivetools.com