Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

PHP - Compare url directory to current directory


  • Please log in to reply

#1
Daemonicus

Daemonicus

    New Member

  • Member
  • Pip
  • 3 posts
[SOLVED]

I'm running into problems trying to highlight a menu item in my CSS navigation bar to keep track of where the user currently is.

I'm trying to pass a url into a function, get it's directory and then compare it with the directory of the page that the user is on, and then return a boolean value based on if it matches or not. Then while I run through a loop to generate my menu i want it to give the item that returns true class="current"

Not sure if that makes sense, i'll attach the code. If anyone can help me out that would be great :)


Lines 251-261 generate the top menu where i want the active directory to be highlighted.

The DisplayButton function at line 329 is where it generate the list element for each menu item which is where it will either create it with id="current" or with no id. And the IsURLCurrentDirectory function right above that at line 312 is where i'm trying to compare the current directory with the passed url.

Sorry if my code is messy...

Attached Files

  • Attached File  page.txt   8.66KB   132 downloads

Edited by Daemonicus, 03 May 2011 - 11:51 AM.

  • 0

Advertisements


#2
Metallica

Metallica

    Spyware Veteran

  • GeekU Moderator
  • 31,675 posts
Way over my head, but is this useful?

http://blog.crondesi...attributes.html
  • 0

#3
Daemonicus

Daemonicus

    New Member

  • Topic Starter
  • Member
  • Pip
  • 3 posts
Thats way more complicated than what i need to do...but i think it made me realize how much i was over complicating what i'm trying to do. i think i know what i need to do now. thanks for the quick response.
  • 0

#4
Daemonicus

Daemonicus

    New Member

  • Topic Starter
  • Member
  • Pip
  • 3 posts
yay i got it. Thanks again for that link, it got my brain on the right track.
  • 0

#5
Metallica

Metallica

    Spyware Veteran

  • GeekU Moderator
  • 31,675 posts
My pleasure. :)
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP