hi folks, i'm currently working on an open source content management system based on modules written in php.(yeah, I know there are others out there, you can't keep me from doing it)
i'm going to post the first VERY beta release in a few days or so on www.noeffred.net.
but i've encountered a little problem:
i've created a table which is the base for the navigation, i've also got a piece of code which reads the whole navigation with all subpoints and subsubpoints and subsubsub.. you get the point.the problem: it shows all the navigation at once.
i'd like the the points below the main entry to pop up when its clicked. I've thought of passing on a string which tells the code which groups to keep open.
i've posted the table below as well as the code which opens all the navigation.
#
Table structure for table content
#
CREATE TABLE content (
id int(11) NOT NULL auto_increment,
text text NOT NULL,
PRIMARY KEY (id)
) TYPE=MyISAM;
--------------------------------------------------------
#
Table structure for table navi_connection
#
CREATE TABLE navi_connection (
id int(11) NOT NULL auto_increment,
order int(11) NOT NULL default '0',
navi_label int(11) NOT NULL default '0',
content_id int(11) NOT NULL default '0',
group tinyint(4) NOT NULL default '0',
sub char(1) NOT NULL default '',
external text NOT NULL,
modules text NOT NULL,
PRIMARY KEY (id)
) TYPE=MyISAM;
--------------------------------------------------------
#
Table structure for table navi_label
#
CREATE TABLE navi_label (
id int(11) NOT NULL auto_increment,
label text NOT NULL,
PRIMARY KEY (id)
) TYPE=MyISAM;
<?php
/*---------------------------------
Navigation (tree)
2002-01-06 by noeffred
---------------------------------*/
require "db.inc.php";
function main($a,$file,$imain,$isub,$left=0){
$query=mysql_query("select * from navi_connection,navi_label where
navi_connection.navi_label=navi_label.id and
navi_connection.group=0
order by navi_connection.order");
while($result=mysql_fetch_array($query)){
if ($result["external"]!=''){
echo "$imain <a href='".$result["external"]."' class='aex'>".$result["label"]."</a><br>\n";
}
else{
echo "$imain <a href='$file?c=".$result["content_id"]."&a=".$result[0]."&mod=".$result["modules"]."' class='amain'>".$result["label"]."</a><br>\n";
$counter=1;
if ($result["sub"]){
sub($result[0],$counter,$file,$isub,$left);
}
}
}
}
function sub($id,$counter,$file,$isub,$left){
if ( ($id!=0) && ($id!='') ){
$query=mysql_query("select * from navi_connection,navi_label where
navi_connection.navi_label=navi_label.id and
navi_connection.group='$id'
order by navi_connection.order");
while($result=mysql_fetch_array($query)){
if ($result["external"]!=''){
if ($left){
$counter2=$counter;
while($counter2!=0){
echo " ";
$counter2--;
}
}
echo "$isub <a href='".$result["external"]."' class='aexsub'>".$result["label"]."</a><br>\n";
}
else{
if ($left){
$counter2=$counter;
while($counter2!=0){
echo " ";
$counter2--;
}
}
echo "$isub <a href='$file?c=".$result["content_id"]."&a=".$a."&mod=".$result{"modules"}."' class='asub'>".$result["label"]."</a><br>\n";
//echo "".$result[0]." <a href=scribble.php?a=".$result[0].">".$result["label"]."</a><br>";
$counter2=$counter;
if ($result["sub"]){
$counter2++;
sub($result[0],$counter2,$file,$isub,$left);
}
}
}
}
}
main($a,$PHP_SELF,$imain,$isub,$left);
?>
thanks