Fixing Current Tab Color Using 1 Php File Only
im sorry for the poor title, i dont know how to explain it. You see i have already created my panel tabs with the help of ol, li and css. it is working perfectly but then there is
Solution 1:
This function will loop through a to z and check if the current page is index.php?namelist=a or b,c ect determining where to place the class="current"
functiontoc_menu($current){
$return ='<ol id="toc">
<li> </li>'."\n";
$return .= ($current=='') ? '<li class="current"><a href="index.php"><span>#</span></a></li>'."\n" : '<li><a href="index.php"><span>#</span></a></li>'."\n";
foreach(range('a','z') as$link){
$return .= ($current==$link) ? '<li class="current"><a href="index.php?namelist='.$link.'"><span>'.strtoupper($link).'</span></a></li>'."\n" : '<li><a href="index.php?namelist='.$link.'"><span>'.strtoupper($link).'</span></a></li>'."\n";
}
$return .="</ol>\n";
return$return;
}
//echo where you want the menuecho toc_menu(strtolower($_REQUEST['namelist']));
//or hold it in a variable to display later on$tocmenu = toc_menu(strtolower($_REQUEST['namelist']));
//outputs this is E was clicked
<olid="toc"><li> </li><li><ahref="index.php"><span>#</span></a></li><li><ahref="index.php?namelist=a"><span>A</span></a></li><li><ahref="index.php?namelist=b"><span>B</span></a></li><li><ahref="index.php?namelist=c"><span>C</span></a></li><li><ahref="index.php?namelist=d"><span>D</span></a></li><liclass="current"><ahref="index.php?namelist=e"><span>E</span></a></li><li><ahref="index.php?namelist=f"><span>F</span></a></li><li><ahref="index.php?namelist=g"><span>G</span></a></li><li><ahref="index.php?namelist=h"><span>H</span></a></li><li><ahref="index.php?namelist=i"><span>I</span></a></li><li><ahref="index.php?namelist=j"><span>J</span></a></li><li><ahref="index.php?namelist=k"><span>K</span></a></li><li><ahref="index.php?namelist=l"><span>L</span></a></li><li><ahref="index.php?namelist=m"><span>M</span></a></li><li><ahref="index.php?namelist=n"><span>N</span></a></li><li><ahref="index.php?namelist=o"><span>O</span></a></li><li><ahref="index.php?namelist=p"><span>P</span></a></li><li><ahref="index.php?namelist=q"><span>Q</span></a></li><li><ahref="index.php?namelist=r"><span>R</span></a></li><li><ahref="index.php?namelist=s"><span>S</span></a></li><li><ahref="index.php?namelist=t"><span>T</span></a></li><li><ahref="index.php?namelist=u"><span>U</span></a></li><li><ahref="index.php?namelist=v"><span>V</span></a></li><li><ahref="index.php?namelist=w"><span>W</span></a></li><li><ahref="index.php?namelist=x"><span>X</span></a></li><li><ahref="index.php?namelist=y"><span>Y</span></a></li><li><ahref="index.php?namelist=z"><span>Z</span></a></li></ol>
Solution 2:
From what I understand, you want a different color of the link on the current page. For e.g. if someone goes to index.php?namelist=a, the color for link A should be different than others. If this is the case, then just add a check for $_REQUEST['namelist'] while adding the class and you should be okay.
Post a Comment for "Fixing Current Tab Color Using 1 Php File Only"