Check if the current url contains xxx

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?
 
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.
 
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.webpn2.webpn3.webpn4.webp

This doesn't happen in any page, only on thread page when the current page link contains "#post-xxx"
 
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.
 
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:
 
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.
 
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:
 
Top Bottom