Active menu, and submenu
9 posts by 3 authors in: Forums > CMS Builder
Last Post: January 30, 2009 (RSS)
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
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
<?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: [solar_sys] Active menu, and submenu
By Dave - January 29, 2009
The software doesn't support that by default but you can add that feature yourself with some custom php code.
Note that this assumes you have a variable called $selectedCategory (which is the default configuration). $selectedCategory has a field called "lineage" which has a list of the record number for all the parent records. It looks like this ":1:6:23:". So we can check that. Here's some sample code:
<?php foreach ($lehe_ylesehitusRecords as $categoryRecord): ?>
<?php $isChildSelected = ($selectedCategory['num'] != $categoryRecord['num'] &&
preg_match("/:{$categoryRecord['num']}:/", $selectedCategory['lineage'])); ?>
Basically this means: If the current category isn't the one that is selected, but _IS_ an ancestor or parent of the selected record.
You can then test that variable to bold the parents:
<?php if ($isChildSelected): ?><b><?php endif ?>
<a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a><br />
<?php if ($isChildSelected): ?></b><?php endif ?>
Hope that helps!
interactivetools.com
Re: [Dave] Active menu, and submenu
By solar_sys - January 29, 2009 - edited: January 29, 2009
Re: [solar_sys] Active menu, and submenu
<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
Re: [solar_sys] Active menu, and submenu
Re: [solar_sys] Active menu, and submenu
By Dave - January 30, 2009
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.
interactivetools.com