1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Check if the current url contains xxx

Discussion in 'XenForo Questions and Support' started by Ahmed, Dec 5, 2011.

  1. Ahmed

    Ahmed Well-Known Member

    Hi,

    Is it possible to convert this code to xF template code syntax:
    PHP:
    if (stripos($_SERVER['REQUEST_URI'], '#post') !== false) {echo 'class="newClass"';}
    ?

    While working in a simple skin, I faced an odd CSS issue which appears only when the page URL contains "#post-xxx", couldn't figure what causes this issue and the best thing I could came up with for now is to check if the current URL contains "#post" or not.

    Any suggestions?
     
  2. Ahmed

    Ahmed Well-Known Member

    Anyone? :whistle:
     
  3. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Page anchors are not visible to the server (not part of the URI) so you can't perform that check. It may be possible with javascript though.

    What is the CSS problem? Maybe there is a different fix.
     
    Ahmed likes this.
  4. Ahmed

    Ahmed Well-Known Member

    I know about the JavaScript, but I thought I'd do it with PHP if possible.

    The CSS problem is when the url contains "#post-xxx", the titleBar block/div is moved up 10px and and pass the top border of the "extra_border_bg" container/div top border that is around the whole thing between the upper and lower navbars.

    See the images:

    n1.png n2.png n3.png n4.png

    This doesn't happen in any page, only on thread page when the current page link contains "#post-xxx"
     
  5. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Weird. I don't see why the anchor would affect it. What browser is that?

    It appears you are losing the top margin for some reason. I recently encountered a problem with some browsers where two margins up against each other don't work right. For example, when a div with a bottom margin is followed by a div with a top margin. I wasn't able to fix the problem so I just avoided that situation completely in my layout.

    Try viewing the page in some different browsers.
     
    Ahmed likes this.
  6. Ahmed

    Ahmed Well-Known Member

    Yeah, that's exactly my thought.
    This happens in all of these browsers:
    FifeFox 8, Opera 11.52, Safari 5.1, IE9 and Google Chrome 15.

    I noticed there is no issue when the page first load, once it jumped to the "#post-xxx", it moved up. :confused:
     
  7. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    If the forum was online then I would offer to take a look, but I see from the picture that it's a local server.
     
    Ahmed likes this.
  8. Ahmed

    Ahmed Well-Known Member

    Yeah, it's still on a local server,. Thanks for the offer, I really appreciate it.

    I was going to let you have a look once I upload it to the live site (still not opened officially), but I think I've found a solution for this issue by removing "overflow: hidden;" from the "extra_border_bg" container/div, but I'm still wondering why this behavior is caused by "#post-xxx" in the link, it doesn't make any sense. Well, I hope someone could explain that.
     
  9. Ahmed

    Ahmed Well-Known Member

    OK, after thinking about it, I might have came up with an idea why this behavior is occurring.
    The "titleBar" block/div normally should not exceed the top border of the "extra_border_bg" container/div that contains the "titleBar" block/div, when the URL has "#xxx" in it, the browser scrolls down to the "xxx" area and considers that area as the top of the page. Normally, that won't affect anything, but when "overflow: hidden;" is applied to an outer div/container the contains the contents of the "xxx" area the border limitation of that container is ignored by the browser.

    Well, I could be 100% wrong and have no idea about what I'm talking about. :whistle:
     

Share This Page