php - CodeIgniter: How to 'highlight' the link of the page the user is currently on? -
New to codeigner is still dependent on the MVC approach. I'm just wondering what's the best way to resolve it:
I've got my navigation bar to highlight the currently active link like this:
< Code> & lt; A href = "index .hml" id = "active" & gt; Index & lt; / A & gt; & Lt; A href = "blog.hml" & gt; Blogs & lt; / A & gt;
Now, when I go to blog.html, I want to change according to id = "active" accordingly. Normally I provide a variable in each link and then set it the value of 'id =' active '. Somehow I do not think this is the best way. any idea?
Update (12 Sept 2012) Since I have asked this, I have gone on Kohana and have expanded a module fully prepared for this purpose. Now, what I have to do, specifies my menu items in a config array and the highlighting is automatically module.
First of all, you should not use id for this type of thing, id is on each page To give a unique identification number for the DOM element, which class we use best.
Code igniter is very helpful and provides classes that become part of our tool, perhaps you have heard "URL segments" before.
$ is-> Yuri-> Segment (n )
Allows you to retrieve a specific segment. Segment number you want to retrieve Segment has been numbered from left to right. For example, if your url is this URL:
This section number will be:
- News <
- Local
- Metro
- crime_is_up
You can use the existing URL segment to retrieve which represents an active page that you are actually displaying on the browser.
Comments
Post a Comment