3 things down-- managed to work the navigation as i wanted, but now i'm down to what i think is the last PHP issue: in the calendar page there is a sub navigation which simply lists all the months. When clicking on a month, you get taken to its page (with the appropriate listings.)
Now, remember the navigation used above?
<ul>
<?php
for($i=0; $i<$navigation_count; $i++)
{
echo "<li><a href=\"".$navigation_links[$i]['href']."\"";
if(ereg($page_name."$", $navigation_links[$i]['href'])){echo "id=\"current\""; }
echo ">".$navigation_links[$i]['name']."</a></li>\n";
}
?>
</ul>
this was successfully modified to:
<ul>
<?php
for($i=0; $i<$navigation_count; $i++)
{
echo "<li";
if($navigation_links[$i]['href']=="/contact")
{
echo " class=\"lastTab\"";
}
echo "><a href=\"".$navigation_links[$i]['href']."\"";
if(ereg($page_name."$", $navigation_links[$i]['href']))
{
echo " id=\"current\"";
}
echo ">".$navigation_links[$i]['name']."</a></li>\n";
}
?>
</ul>
so i can add the appropriate CSS styling. The calendar has two of the above lists, the first is exactly the same (but highlights calendar as #current by default,) I need to be able to set #current to the secondary nav as well, and for now, nothing I'm doing works...
here's all the php on the page:
//top of document...
<?php
error_reporting(0);
include("csv_data.inc");
$navigation_links = quick_read_csv("../content/data/navigation_links.txt", array('name', 'href'));
$navigation_count = count($navigation_links);
$calendar = quick_read_csv("../content/data/calendar.txt", array('month', 'day', 'text'));
function calendar_cmp($a, $b) { return ($a['month']*60+$a['day']) - ($b['month']*60+$b['day']); }
usort($calendar, "calendar_cmp");
$t = localtime();
$month_names =
array('January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December');
$month = $t[4];
$day = $t[3];
$year = $t[5]+1900;
if( isset($month_names[$_REQUEST['month']-1]) )
{
$month = $_REQUEST['month']-1;
}
if( $month < $t[4] ){$year++;}
$month_name = $month_names[$month];
function calendar_filter($a)
{
global $month;
return $a['month'] == $month+1;
}
$calendar = array_filter($calendar, "calendar_filter");
?>
//this is the relevant portion: the navigation bars
<div id="nav">
<ul>
<?php
for( $i = 0; $i < $navigation_count; $i++ )
{
echo "<li";
if($navigation_links[$i]['href']=="/contact")
{
echo " class=\"lastTab\"";
}
echo "><a href=\"".$navigation_links[$i]['href']."\"";
if($navigation_links[$i]['href']=="/calendar")
{
echo " id=\"current\"";
}
echo ">".$navigation_links[$i]['name']."</a></li>\n";
}
?>
</ul>
</div>
<div id="secondaryNav">
<ul>
<?php
for( $i = 1; $i < 13; $i++ )
{
echo "<li";
if($i==12)
{
echo " class=\"lastTab\"";
}
echo "><a href=\"/calendar/".$i."\"";
if(ereg($month_names."$", $i)) // <-- this is the line with which I have no clue what to do.
{
echo " id=\"current\"";
}
echo ">".$month_names[$i-1]."</a></li>\n";
}
?>
</ul>
</div>
I highlighted above the problematic line- i think I've tried any combination of all variables over there, i just don't know how to use the ereg correctly I guess, but it's just not working. again, when clicking on any of the subnav items (the list of months) the user gets redirected to a calendar/X URL, where X is the list-place of the month they selected. (i.e. June being 6.) What doesn't happen is in the <li> for june, the <a> should become <a href="#" id="current">
any help appreciated. it's 3am already, can't think of anything.