+ Reply to Thread
Results 1 to 7 of 7

Thread: a:active long URL problem

  1. #1
    freecrm's Avatar
    freecrm is offline x10 Elder freecrm is an unknown quantity at this point
    Join Date
    May 2008
    Location
    UK
    Posts
    629

    a:active long URL problem

    Hi all..

    It's been a while since I've posted, but I have an interesting problem.

    Very simply, I have a menu

    menu, ul, li, span etc etc. and want to add an a:active attribute to the css.

    BUT - many of the URL's are dynamic and include variable data for $_GET requests.

    How do I strip out the unecessary stuff after the ? and then how do I get the a:active attribute working on the result.

    I just can't get my head around this at all..

    Rich

  2. #2
    garrettroyce's Avatar
    garrettroyce is offline Generally Helpful Member garrettroyce is a glorious beacon of lightgarrettroyce is a glorious beacon of light
    Join Date
    Apr 2008
    Location
    IL, USA
    Posts
    3,746

    Re: a:active long URL problem

    a:active is used when the link is activated by mouse click. You can define it in a stylesheet, but I don't think you can do it inline (ie <a style="....)

    Code:
    a:active {
    ....
    }
    You can remove everything after the question mark using strstr():

    Code:
    strstr($url, '?', true); //returns everything before ? is found in $url (true means before, false means including and after)
    gjr.gr - coming soon: secrets of OCD coding from a self taught tinkerer

  3. #3
    freecrm's Avatar
    freecrm is offline x10 Elder freecrm is an unknown quantity at this point
    Join Date
    May 2008
    Location
    UK
    Posts
    629

    Re: a:active long URL problem

    Thanks my friend..

    I already knew about the css definition, but the strstr function I'd missed and was trying a combination of others...

    Now this is the tricky bit..

    If a link (menu) has a static url address and you visit a dynamic address (say /forums?id=1), I know I can replace the value for the url, but that doesn't actually replace the url itself.

    ie, I can add a value $shorturl = strstr(current url) etc. but that does'nt change the current url to $shorturl.

    Even if this were possible, I need the dynamic url to get the page to work....

    So...

    How do I maintain my dynamic url and get the static a href link in the menu to recognise when it's active??

    (surely a css a:active will only recognise an exact match?)

    Is this clearer (it's not to me :D)

    Rich

  4. #4
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: a:active long URL problem

    The :active class isn't dependent on the value of element attributes, including linked URIs. The attribute value would matter only if you were using an attribute selector, such as [href^=/forums] or [href$=id=1] (note: using "^=" and "$=" in attribute selectors is CSS3).

    In short, just use a:active in you selector and don't worry about the URI.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  5. #5
    xav0989's Avatar
    xav0989 is offline Community Public Relation xav0989 is just really nice
    Join Date
    Jul 2008
    Location
    ifk
    Posts
    4,438

    Re: a:active long URL problem

    Quote Originally Posted by misson View Post
    The :active class isn't dependent on the value of element attributes, including linked URIs. The attribute value would matter only if you were using an attribute selector, such as [href^=/forums] or [href$=id=1] (note: using "^=" and "$=" in attribute selectors is CSS3).

    In short, just use a:active in you selector and don't worry about the URI.
    I was wondering what the url parameters had to do with css.
    Xavier L | Community Public Relations Manager (Free Hosting Support)
    █ Yes, my position is too cool to even exist!
    How am I helping? Rate this post by clicking the icon below! (this is even better than "liking" a post)
    Terms of Service | Acceptable Use Policy | x10Hosting Wiki

  6. #6
    freecrm's Avatar
    freecrm is offline x10 Elder freecrm is an unknown quantity at this point
    Join Date
    May 2008
    Location
    UK
    Posts
    629

    Re: a:active long URL problem

    Aaaarrgghhh - this explains the confusion...

    My fault...

    I meant a:current, not a:active!!!

    Sorry for the wasted time... this issue is still unresolved though.

  7. #7
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: a:active long URL problem

    There is no ":current" pseudo-class in CSS1, 2.1 or 3. Are you using jQuery?
    Last edited by misson; 07-07-2009 at 05:36 AM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

+ Reply to Thread

Similar Threads

  1. DB number problem
    By lionheart8 in forum Free Hosting
    Replies: 5
    Last Post: 04-08-2008, 08:26 AM
  2. Site Problem
    By himgar in forum Free Hosting
    Replies: 3
    Last Post: 03-10-2008, 03:36 PM
  3. SQL connection problem
    By matsaleh in forum Free Hosting
    Replies: 1
    Last Post: 01-24-2008, 03:52 AM
  4. Ad code problem!
    By Akkarin in forum Free Hosting
    Replies: 8
    Last Post: 08-29-2005, 10:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers