PDA

View Full Version : php menu with secondary navigation



KirstyB
03 Jul 2008, 09:44 AM
Hi,
I'm trying to do something in PHP that is far more complicated than I have attempted before.

I have a navigation system that uses the jquery accordian plugin to show and hide the secondary navigation. I want to convert this to php so that when I click on the top level menu it shows the right secondary navigation.

I've set up 2 tables in phpmyadmin. One is prod_cat_01 which contains:
cat_ID
name
active (this is ENUM so that later on customers can switch off categories)

The other is products which contains:
prod_ID
cat_ID
prod_name
description
active

My HTML for the menu looks like this:

<div id="navigation">
<ul>
<li><a href="#" class="head">Feeding Range</a>
<ul>
<li><a href="products.php?">Big Daddy Pots</a></li>
<li><a href="">Feeding Pots</a></li>
</ul>
</li>
</ul>
</div>

What I want to do is display prod_cat_01.name in the top list and then when you click on that link it expands to display the nested list with all the products whose cat_ID in products match the cat_ID from prod_cat_01. Then when you click on the product name you are taken to a page with the details of that product on it.

The expanding menu works using jquery and a dummy link to trigger the expanding action.

Is this possible? Can someone talk me through it? I can get the categories to display and I can also do a simple link to a detail page but I don't seem to be able to combine all three.

Thanks
Kirsty

jnjc
03 Jul 2008, 07:41 PM
Hi,

I am not 100% sure I understand what you are asking, but I will give it a shot anyway.

If I am correct you want to dynamically create your accordion control based on the contents of your table. I am not familiar with the jquery control but it should just be a matter of using PHP to produce the JS for your control:



(loop through active categories) {
echo "JS or Markup to create accordion header using {prod_cat_01.name}";
(loop through active products) {
echo "JS or Markup to create accordion header using {prod_name}";
}
}


HTH,
JC