Creating a dynamic dropdown menu

31 posts by 7 authors in: Forums > CMS Builder
Last Post: October 12, 2012   (RSS)

By (Deleted User) - April 18, 2012

Hi Drewh01,

Yeah - forgot to attach the file to my previous post. Remedied that now.

Tom

Re: [Tom P] Creating a dynamic dropdown menu

By drewh01 - April 18, 2012

ok, thx - I think it's just that <div> section that needs to go in there somehow and i'm having a hard time figuring it out.

<div id="m1"
onmouseover="mcancelclosetime()"
onmouseout="mclosetime()">

Here is the link to the DEV page to see what is going on....

http://fp2marketing.com/~hummingb/index.php?Hummingbirds-101-3

By Jason - April 19, 2012

Hi,

I've taken a look at your page. I don't see where the <div id = ""> code takes place at all. On the page, you get a number of javascript errors. Basically it's trying to reference elements by id that don't exist.

In the past I've found that menu scripts that rely of extra javascript/divs being inserted into a list don't always lend themselves well to dynamically generated menus. If you're not able to get this particular script working, you may want to consider a different script. Here is one from dynamic drive that I've had success with:
http://www.dynamicdrive.com/dynamicindex1/ddsmoothmenu.htm#

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Creating a dynamic dropdown menu

By drewh01 - April 19, 2012

cool, thanks! That new menu is much easier to use.

By drewh01 - April 23, 2012

One other thing, in the past I was able to add some code to my nav that would allow me to set a URL override where "url" is the field name in the admin and when a value is listed it would default to that custom URL instead of the dynamic CMS.

Previously I used this piece of code:

<?php if ($categoryRecord['url']) { $categoryRecord['_link'] = $categoryRecord['url']; } ?>

Using the code below, what is needed for this to happen?

thanks!


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

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

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

<a href="<?php echo $page['_link'] ?>"><?php echo $page['name'] ?></a>
<?php else: ?>
<li>
<a href="<?php echo $page['_link'] ?>">
<?php echo $page['name'] ?>
</a>

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

By Jason - April 24, 2012

Hi,

So what you're saying is that you have a url field in your category section and that if that field has a value, you want to use that url instead of the _link pseudo field. Is that right?

If so, you can try something like this:

<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>


Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Creating a dynamic dropdown menu

By drewh01 - April 24, 2012

THANKS!

Re: [Tom P] Creating a dynamic dropdown menu

By drewh01 - May 7, 2012

What would this code look like if I wanted to use a multi-record type table?

Thanks!

By Jason - May 8, 2012

Hi,

You would use the same technique, except you wouldn't have the extra category pseudo fields:

For example:

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

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

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


<?php endforeach; ?>


Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/