Simple method to highlight active link |
[eluser]John_Betong[/eluser]
Hi All, Wish List I have always wanted a simple solution to highlight the active page link. I stumbled upon I came across an ingenious solution and adapted it very quickly to this CodeIgniter site. Theory In order to get the links to be highlighted: 1. a simple line of CSS code is required 2. the view code requires an individual <body id='<?= $PAGE ?>'> 3. each link requires an additional unique CSS 'class' statement Implementation, additions and changes CSS File Code: #home .home, Controller Code Code: function index() { View code Code: <html> Cheers, John_Betong
[eluser]jedre[/eluser]
CSS definition should looks like this: Code: #home a.home:link, #home a.home:visited{ Check It! Edit: and reamember links must be in example: Code: <div id="home"> <a .....>link</a>
[eluser]John_Betong[/eluser]
Hi jedre, I was previously unsuccessful in trying to get the CSS statements a:active to work in the three most common Windows browsers. I am happy that supplied code works in all three browsers. I also tried you code and it worked just the same as it worked without using your code? I do not know why the code works in all the browsers I tried but I am just happy that it does. If it is not broken then why try to fix it? Cheers, John_Betong
[eluser]xwero[/eluser]
instead of using and id and a class why don't you add an active class to the links? Code: // controller
[eluser]John_Betong[/eluser]
[quote author="xwero" date="1193575612"]instead of using and id and a class why don't you add an active class to the links? Code: ... Hi xwero, Version 002 Code: // css file I agree that "you don’t have to change your css file if there is a link removed or added" but it seems a lot of controller code is required to achieve the same results. I am in two minds as to which method is better but at least I now I have a choice Cheers, John_Betong
[eluser]xwero[/eluser]
You can put the normal status in a config file and in your controller you just have to change the class from the link that is active. So it can come down to Code: // controller
[eluser]xwero[/eluser]
and to make it even easier to change the default class in the config file you can do something like this Code: $defaultclass = ''; |
Welcome Guest, Not a member yet? Register Sign In |