Making the "halo" template dynamic or how to set up database driven navigation menue

M

macworker

Hi all,
I am new to this forum, I hope my three weeks odysse will end soon. I need HELP! Otherwise i will go crazy ;-)
The other thing is I am quite new to dynamic web design, so maybe there is a simple solution to my problem.
The problem is to design a site navigation wich is driven by a database. I try to redesign a page wich exist of about 100-150 pages. And my chief is quite "unstable", which means to change the site navigation every 3 hours, ad pages, delete pages,... I think you imagine.
So I decided to generate the page navigation by database using dreamweaver.
I want to make it similar to the halo template in dreaweaver or on the macromedia webpage http://www.macromedia.com (It doesnt have to look exatly like it, but has to have a submenue, and this rollover effekts).
What I did 3 weeks long and failed is as follows:
1. To generate the global nav i designed a MySQL-database and created a table called "nav" with fields "home", "id". In the filed "home" I write all the menue items, "id" is primary key and autoincreament.
The first big struggle was, that I wantetd to put the data using dynamic table. But the problem was that both, the rollovers didn`t work as the should, the whole menue is making rollovers, but the more important thing, no submenues where working, only the submenue 1, which is clear, because of the CSS style sheet.
BUT HOW IS IT POSSIBLE TO GIVE DYNAMICAL DATA IN A TABLE ITS OWN STYLE AN LINK
What I have don is to make for every menue item a single binding, wich looks like this:
Code:
mysql_select_db($database_navigation, $navigation);
$query_nav = "SELECT nav.home FROM nav WHERE nav.id = 2";
$nav = mysql_query($query_nav, $navigation) or die(mysql_error());
$row_nav = mysql_fetch_assoc($nav);
$totalRows_nav = mysql_num_rows($nav);
and give out the data wich looks like this:
<div id="globalNav">
      <div id="globalLink" class="glink">        
	  <a href="#" id="gl3" class="glink" onmouseover="ehandler(event,menuitem3);">global
      link</a><a href="#" id="gl4" class="glink" onmouseover="ehandler(event,menuitem4);"><?php echo $row_nav['home']; ?>
	  </a><a href="nav.php" id="gl5" class="glink" onmouseover="ehandler(event,menuitem5);"><?php echo $row_ortho['home']; ?></a><a href="#" id="gl6" class="glink" onmouseover="ehandler(event,menuitem6);"><?php echo $row_trauma['home']; ?>global
      link</a><a href="#" id="gl7" class="glink" onmouseover="ehandler(event,menuitem7);">global
      link</a>
    </div>
This works perfektly, but I thinks it ia lot of code, and if I need to add a menue item, there is no chance. I thougth about to write code for additional items an genrate bindings as dummys, so if a menue item is addes to the database, all is ste up.
BUT THIS CODE IS VERY COMPICATED AND I CAN NOT IMAGINE THAT DOING LIKE THIS IS LIKE SOMEBODY IS DOING WHO IS KNOWING WHAT HE DOES!

the sekond problem is the pretty much the same as mentioned above, regarding the submenues.
I created another tabel in the MySQl-database, calles "subnav" containing the fields "id", "subnav1". "subnav1" is containing the menue items and "id" is primary key, autoincrement.
for the reason not to generate for every submenue item a "personal"-binding, I decided to use a dynamic table again, because roll overs are not that important in submenue, but if it would be possible this would be perfect! But the same problem again: how can I assign a spezific link to the data displayed dynamically by the tabel?

The plan I have in my mind is, to ad a field in the MySQL table "subnav" called "url". Plan is to write in the link the menue item should have. BUT I FAILED TO REALIZE THIS IDEA, BECAUSE I HAVE NO IDEA HOW TO MAKE IT. But this would be the gold solution for me, beause, then everthing is made dynamically, so no preconfigured code will be neccessary!

So thanks for reading all this and to try ro understand my problems. Is something like I am dreaming of possible?
Thanks again.

Cheers stephan
 
Hi,
have you noticed, that this is a german board? No? So please excuse my english :-)
I would make the following MySQL Tables:
MainNavi: ID, mLink, mTitle, MainID, SubID
SubNavi: ID, sLink, sTitle, SubID

Then asking with "SELECT T1.*, T2.* FROM `MainNavi` T1, `SubNavi` T2 WHERE T1.SubID = T2.SubID ORDER BY T1.MainID ASC;" the MySQL Database for the data.

Here the rough structure:
PHP:
//the mysql query here
$nowID = 0;

while ($row = mysql_fetch_assoc($result)) {
	if ($nowID != $row['KategorieID']) {
		if ($nowID != 0) {
			$navileft.= $brake;
			}
			$navileft.= MakeMain($row['sLink'], $row['mTitle']);
			$navileft.= $brake;
			$navileft.= MakeSub($row['sLink'], $row['sTitle']);
			$nowID = $row['MainID'];
		} else {
			$navileft.= MakeSub($row['sLink'], $row['sTitle']);
		}
	}
}
The functions MakeMain and MakeSub are functions to generate the HTML Part.

Hope have helped you.
 
Zuletzt bearbeitet:
Hm i think you find a lot of englisch speaking boards. And there you get better and faster help then here.
 
Zurück