[eluser]techguy101[/eluser]
Wow, they were speedy replies..thanks guys.
I'm after going with bobbob's solution..it works like a treat.
One more thing. I just put an array at the very beginning of header.php to store menu items. I then use a for each loop to print them out in the nav bar furhter down..it will make adding menu items easy but is it the right way to do things??
Example:
Code:
<?php
$navBar = array(
array('Home','home'),
array('Transactions','/transaction'),
array('Customers','/customer')
);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title><?php echo $title; ?></title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<style media="all" type="text/css">@import "http://192.168.72.128/grain/css/all.css";</style>
[removed][removed]
</head>
<body>
<div id="main">
<div id="header">
<a href="splash.php" class="logo"><img src="img/logo.gif" width="101" height="29" alt="" /></a>
<ul id="top-navigation">
<?php
// Print out top navigation bar and apply active state to currently open page link.
foreach($navBar as $link):
if(strnatcasecmp($this->uri->segment(2),$link[0]) == 0)
{
echo '<li class="active"'; ?>><span><span><?php echo $link[0];
}
else
{
echo '<li><span><span>'.anchor($link[1],$link[0]). '</span></span></li>';
}
endforeach;
?>
</ul>
</div>
What do you think of this code? How would you improve it?
Thanks guys..
P.S. I only have <5 hours experience with CI but I absolutely love it!!