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?
Function help!
Moderators: Moderator, Global Moderator
Function help!
[color=\"green\"]hmm..i dont entirely know why..but maybe it has something to do with how you are setting out your \"print\" functions...there start and finish on different lines to the code, maybe the php see\'s that as you wanting a blank line on top of, and below the line of code?? mebbe..lol worth a try i guess
[code] print \'<div id="header">
<img src="images/banner.gif" border="0" />
<!-- Navigation goes here -->
<div id="nav">
<ul id="navlist">\';
$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;
}
print "</ul>
</div>
</div>";[/code]
apart from that...theres some puurdyful code in there
/blum.gif\' class=\'bbc_emoticon\' alt=\':P\' />[/color]
[code] print \'<div id="header">
<img src="images/banner.gif" border="0" />
<!-- Navigation goes here -->
<div id="nav">
<ul id="navlist">\';
$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;
}
print "</ul>
</div>
</div>";[/code]
apart from that...theres some puurdyful code in there
Function help!
Thanks for the suggestion verczeh, and yeh i do need to clean up the print functions but unfortuantly it still don't work >.<
Function help!
Is there a difference between print and echo? If not, why can't you use echo?
/biggrin.gif\' class=\'bbc_emoticon\' alt=\':D\' />
Function help!
Print can return true/false - really the only difference, it doesn't affect this code. But thanks for the suggestion all the same
/smile.gif\' class=\'bbc_emoticon\' alt=\':)\' />
Function help!
[quote]if ($navActive = $this-> _dNavList[$x])[/quote]
change it to
[quote]if ($navactive == $this-> _dNavList[$x])[/quote]
reason: 1 \'=\' will cause it to set $navactive to whatever $this-> _dNavList is...
thought I should explain myself incase anyone else ever has the problem.
change it to
[quote]if ($navactive == $this-> _dNavList[$x])[/quote]
reason: 1 \'=\' will cause it to set $navactive to whatever $this-> _dNavList is...
thought I should explain myself incase anyone else ever has the problem.
Last edited by ner0 on Wed Oct 27, 2004 8:06 am, edited 1 time in total.
[color=\"green\"]'class KPIM::ProcessManager' only defines private constructors and has no friends[/color] <-
poor class
[18:09:00] * ~Moppy stews ner0 erotically 1 times.
[18:09:00] * ~Moppy stews ner0 erotically 1 times.
Function help!
if trin = n00b then ner0 == g0d
/blum.gif\' class=\'bbc_emoticon\' alt=\':P\' />
Function help!
[color=\"green\"]if trin == n00b, verczeh == n0_h0pe
/blum.gif\' class=\'bbc_emoticon\' alt=\':P\' /> [/color]



