I am having trouble getting these classes for navbars working:
class nav_item {
var $url;
var $descrip;
function nav_item($u, $d) {
$this->url = $u;
$this->descrip = $d;
}
}
class subnav {
var $nav;
var $items;
var $current = 'no';
function subnav($n) {
$this->nav = $n;
}
function add($url, $descrip) {
$u = '/' . $this->nav . '/' . $url;
$this->items[] = new nav_item($u, $descrip);
}
function echo_subnav() {
echo '<ul>';
$last = count($this->items);
for($i = 0; $i < $last; $i++) {
echo '<li>';
echo '<a href="';
echo $items[$i]->url;
echo '">';
echo $items[$i]->descrip;
echo '</a>';
echo '</li>';
}
echo '</ul>';
}
}
I add info to the subnavbars here:
//Projects Subnav
$subnav['projects'] = new subnav('projects');
$subnav['projects']->add('/cbeta/', 'CBETA');
$subnav['projects']->add('/stepup/', 'StepUp Savannah');
$subnav['projects']->add('/sandbox/', 'My Sandbox');
$subnav['projects']->add('/toys/', 'Toys');
but when I try and make a call to the info (like this):
<?php $sn = $subnav[$subnav_name]; $sn->echo_subnav(); ?>
the only html that gets generated is this:
<ul>
<li><a href=""></a></li>
<li><a href=""></a></li>
<li><a href=""></a></li>
<li><a href=""></a></li>
</ul>
So...I'm perplexed as to why I don't see the content of the navbars (like I added using the add() method above.)
Help!