![]() |
achor highlighting - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: achor highlighting (/showthread.php?tid=9052) |
achor highlighting - El Forum - 06-10-2008 [eluser]soupdragon[/eluser] I am sure this has been asked before but i have failed to find the answer i have a side navi which i include as a view all over the place. in it obviously lots of this sort of thing <?=anchor('start/help', 'Hilfe', 'onfocus="blur()"');?> i have in the controllers a $data['page] so know where i am but how can i easily highlight which navi point i am on ? so far i have come up with this <li><?=($page == 'help') ? '<b>' : '';?><?=anchor('start/help', 'Hilfe', 'onfocus="blur()"');?><?=($page == 'help') ? '</b>' : '';?></li> but to be honest thats more code than if i just hard coded the link :-P achor highlighting - El Forum - 06-10-2008 [eluser]Gavin Blair[/eluser] This may be slightly shorter: <li><?php if($page=='help') $attributes = array( 'class' => 'current' ); echo anchor('start/help', 'Hilfe', $attributes); ?></li> (in your css, make sure .current { font-weight: bold; } ) But I tend to use html anchors: <li><a href="<?=base_url()?>index.php/start/help" class="<?=($page == 'help') ? 'current' : '' ?>">Hilfe</a> This is the shortest and seems the easiest to read. Hope this helps! achor highlighting - El Forum - 06-10-2008 [eluser]soupdragon[/eluser] yep we are thinking along the same lines ! i'm thinking $attributes = $spoon = array('title' => 'val1', 'onfocus' => '"blur()"', 'id' => $page.'x'); and then a css rule with bold for all pages achor highlighting - El Forum - 06-10-2008 [eluser]soupdragon[/eluser] and in fact i just need once at the top of the side nav $attributes = array( 'onfocus' => '"blur()"', 'id' => $page.'x'); and then each anchor becomes <?=anchor('start/help', 'Hilfe', $attributes);?> so in fact shorter than before :-) achor highlighting - El Forum - 06-10-2008 [eluser]Gavin Blair[/eluser] ooh clever! I'll have to give that a try |