Hi,
I have a class that outputs drop down menu options. The sub menu is calling a 3D array where one layer is a sub menus id, labels and links. The problem I'm having is the output to the browser is wack. The feature is partially working and repeating itself. Somehow, I've messed up the iterations. Any thoughts are appreciated:
Here is the site (in progress)
http://www.ohiostrophyquestoutfitters.com/aboutus.php
Here is the class script:
//drop menus, inherits properties and methods from mainnav
class dropnav extends mainnav
{
//the arrary
public $sublinks = array(array(array('id'=>'About','sublabel'=>'Page1-About','sublink'=>'page1.html'),
array('id'=>'About','sublabel'=>'Page2-About','sublink'=>'page2.html'),
array('id'=>'About','sublabel'=>'Page3-About','sublink'=>'page3.html'),
),
array(array('id'=>'Packages','sublabel'=>'Page4-Package','sublink'=>'page4.html'),
array('id'=>'Packages','sublabel'=>'Page5-Package','sublink'=>'page5.html'),
array('id'=>'Packages','sublabel'=>'Page6-Package','sublink'=>'Page6.html'),
),
);
public function subnavigate()
{
$this->subnavigateMenu($this->sublinks);
}
public function subnavigateMenu($sublinks)
{
//make available outside this function.
global $label, $url;
//Start outer loop, should loop once for each layer
$cycle_layer=count($sublinks);
//layers outer loop
for ($i=0; $i < $cycle_layer; $i++){
//row outerloop
for ($e=0; $e < $cycle_layer; $e++){
//assign the layer id for the div id.
$subid=$sublinks[$i][$e]['id'];
//Output open div tag with layer id
printf ("<div id=\"dropmenu\"><ul id=\"%s\">", $subid);
//iterate through menu links
$subarr_size=count($sublinks);
for ($layer=$i; $layer < $subarr_size; $layer++){
for ($row = $e; $row < $subarr_size; $row++){
$label = $sublinks[$layer][$row]['sublabel'];
$url = $sublinks[$layer][$row]['sublink'];
//call the function with variable page label and link attributes.
$this->subnavigateLink($label, $url);
}//close row loop
}//close layer loop
echo "</div>";
}//close layer outer loop
}//close row outerloop
}//closed function
//function for building menu labels and links.
public function subnavigateLink($label,$url,$active=true)
{
if ($active) {
printf ("<a href=\"%s\" target=\"_self\">", $url);
echo $label;
echo '</a>',"\n\r";
}
}
}
Thanks in advance
rwhite35