Quoting Ryan A <genphp@xxxxxxxxx>:
Hello,
First off, I admit this is not going to be as
interesting as the "helping someone" thread, and
hopefully there is not going to be any talk of DDOS or
flaming
:-p
Ok, here goes, I have never done anything _exactly_
like this but since typo 3 has this kind of
functionality (and i have never used typo 3 myself)
I'm guessing some of you would be able to help me out,
or guide me...If i'm wrong, just ignore this thread.
Heres what i have; I have a table with the main
(parent) categories and another table with the
sub-categories (children) which will/is supposed to be
"compiled" into a navigation menu and then be
displayed on the left side of each and every page on
the site.
There are around 15 parents and X children under each
parent, children content have upto 10 links on their
own pages.
I was thinking of passing three valiables on each page
for the above:
parent_id (int)
display_children (1=yes 0=no)
active_sub-menu (string or int, depending on the DB
structure)
and accordingly build and display the menu.
Am I on the right track or missing something? Advise,
links and suggestions welcome.
Thanks!
Ryan
Ryan,
I have run into a similar problem with one of the sites I'm designing.
Here's the approach I took. You can see if it fits your needs.
I have only 1 database table of menu items. That table is defined as such:
menu_item_id
name
parent_id
location
By doing it this way, you are able to have a dynamic number of menu
items and your menu structure is very flexible. Here's an example of
what I have:
MID NAME PARENT_ID LOCATION
1 Home <null> index.php
2 Products <null> products.php
3 Information <null> info.php
10 Profile 1 profile.php
11 Account 1 account.php
20 Hardware 2 hardware.php
21 Software 2 software.php
210 M$ Word 21 msword.php
211 iLife 21 ilife.php
And I think you get the drift. The first 3 are the main menu items.
Then Home has 2 children and Products has 2 children. Then Software
(under Products) has two children. You can keep getting deeper in the
tree structure and not have to worry about adding more tables.
Notice that the menu_item_id (MID) actually has some organization to
it, but this is completely optional. As the menu items grow, this will
probably be more difficult to keep track of. Anyway, hope that helps!
~Philip
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php