Function help!
Posted: Tue Oct 26, 2004 7:50 am
Ok, here goes.
This is the function that I am using to display the Codecrypt nav.
[code]// Function to show the header of the page
function pageHeader($navActive) {
// This is the array of nav items
$this-> _dNavList[0] = 'home';
$this-> _dNavList[1] = 'forums';
$this-> _dNavList[2] = 'articles';
$this-> _dNavList[3] = 'tutorials';
$this-> _dNavList[4] = 'resources';
$this-> _dNavList[5] = 'info';
// Starts of the header, opens up the nav list
print '
<div id="header">
<img src="images/banner.gif" border="0" />
<!-- Navigation goes here -->
<div id="nav">
<ul id="navlist">
';
// Code for printing the nav, selecting the active one
$x = 0;
while ($x < 6) {
if ($navActive = $this-> _dNavList[$x]) {
print '
<li class="current"><a href="#" class="active">'. $this-> _dNavList[$x] .'</a></li>
';
}
else {
print '
<li><a href="#">'. $this-> _dNavList[$x] .'</a></li>
';
}
$x = $x + 1;
}
// Close the list and the divs
print '
</ul>
</div>
</div>
';
}[/code]
When i use it, it looks like this:
[code]$layout->pageHeader('home');[/code]
What i want to do is display this HTML:
[code]<div id="nav">
<ul id="navlist">
<li class="current"><a href="#" class="active">home</a></li>
<li><a href="#">forums</a></li>
<li><a href="#">articles</a></li>
<li><a href="#">tutorials</a></li>
<li><a href="#">resources</a></li>
<li><a href="#">info</a></li>
</ul>
</div>[/code]
The problem is it displays this HTML:
[code]<div id="nav">
<ul id="navlist">
<li class="current"><a href="#" class="active">home</a></li>
<li class="current"><a href="#" class="active">forums</a></li>
<li class="current"><a href="#" class="active">articles</a></li>
<li class="current"><a href="#" class="active">tutorials</a></li>
<li class="current"><a href="#" class="active">resources</a></li>
<li class="current"><a href="#" class="active">info</a></li>
</ul>
</div>[/code]
It seems that it thinks that every part of the array = $navActive, when only the array that contains 'home' should match $navActive. Any suggestions?
This is the function that I am using to display the Codecrypt nav.
[code]// Function to show the header of the page
function pageHeader($navActive) {
// This is the array of nav items
$this-> _dNavList[0] = 'home';
$this-> _dNavList[1] = 'forums';
$this-> _dNavList[2] = 'articles';
$this-> _dNavList[3] = 'tutorials';
$this-> _dNavList[4] = 'resources';
$this-> _dNavList[5] = 'info';
// Starts of the header, opens up the nav list
print '
<div id="header">
<img src="images/banner.gif" border="0" />
<!-- Navigation goes here -->
<div id="nav">
<ul id="navlist">
';
// Code for printing the nav, selecting the active one
$x = 0;
while ($x < 6) {
if ($navActive = $this-> _dNavList[$x]) {
print '
<li class="current"><a href="#" class="active">'. $this-> _dNavList[$x] .'</a></li>
';
}
else {
print '
<li><a href="#">'. $this-> _dNavList[$x] .'</a></li>
';
}
$x = $x + 1;
}
// Close the list and the divs
print '
</ul>
</div>
</div>
';
}[/code]
When i use it, it looks like this:
[code]$layout->pageHeader('home');[/code]
What i want to do is display this HTML:
[code]<div id="nav">
<ul id="navlist">
<li class="current"><a href="#" class="active">home</a></li>
<li><a href="#">forums</a></li>
<li><a href="#">articles</a></li>
<li><a href="#">tutorials</a></li>
<li><a href="#">resources</a></li>
<li><a href="#">info</a></li>
</ul>
</div>[/code]
The problem is it displays this HTML:
[code]<div id="nav">
<ul id="navlist">
<li class="current"><a href="#" class="active">home</a></li>
<li class="current"><a href="#" class="active">forums</a></li>
<li class="current"><a href="#" class="active">articles</a></li>
<li class="current"><a href="#" class="active">tutorials</a></li>
<li class="current"><a href="#" class="active">resources</a></li>
<li class="current"><a href="#" class="active">info</a></li>
</ul>
</div>[/code]
It seems that it thinks that every part of the array = $navActive, when only the array that contains 'home' should match $navActive. Any suggestions?