Jump to content

Help with MySQL solutions for site navigation


latinomigs

Recommended Posts

Hello,

 

My overall goal is to build a website generated by PHP with a MySQL database storing content. From experimenting I have a good idea of how to do most of it. Where I'm confused is with the organization and generation of site navigation.

 

My site nav is split into two sections:

 

- A primary nav bar with 6 links

- A left column with any number of secondary and tertiary navigation

 

An example of the output markup for the primary nav is:

 

<div id="priNav">

<ul>

<li><a href="#">Primary Link One</a></li>

<li><a href="#">Primary Link Two</a></li>

<li><a href="#">Primary Link Three</a></li>

<li><a href="#">Primary Link Four</a></li>

</ul>

</div>

 

And an example of the output markup for the secondary/tertiary nav is:

 

<div id="secNav">

<ul>

<li><a href="#">Secondary Link One</a></li>

<li><a href="#">Secondary Link Two</a>

<ul>

<li><a href="#">Tertiary Link One</a></li>

<li><a href="#">Tertiary Link Two</a></li>

</ul>

</li>

<li><a href="#">Secondary Link Three</a></li>

</ul>

</div>

 

 

My first attempt at organizing the db tables for navigation resulted in the following table structures:

 

dbt_nav_root

--------------------

id = The primary key for this table

cont_id = A foreign key that links to the primary key of the content table

text = The anchor tag text

is_parent = a boolean designating whether this table has child links

 

 

dbt_nav_child1,

dbt_nav_child2

--------------------

id = The primary key for this table

cont_id = A foreign key that links to the primary key of the content table

parent_id = A foreign key that links to the primary key of it's parent link

text = The anchor tag text

is_parent = a boolean designating whether this table has child links

 

 

I'm not sure how to measure the success of this structure because I can't find anything to compare it to. I guess it's been successfull because I was able to make it work, but I'm anxious to validate and improve my attempt through comparison and your advice.

 

So how do you guys handle this sort of thing?

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.