homepage Welcome to WebmasterWorld Guest from 54.161.246.212
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Exclude a div from specific URL
Asia_Expat

5+ Year Member



 
Msg#: 4264952 posted 3:45 am on Feb 10, 2011 (gmt 0)

I have a section of faqs. I want the index page of that section to be exempted from displaying a certain div. At the moment, I've got this working...

<?
$url=$_SERVER['PHP_SELF'];
if ( strstr( $url, "faq/" ) )
echo "";
else
echo "<div>groovy stuff</div>";
?>


However, this is omitting the div from every page of the faq directory. I've been trying to figure something out with preg_match but I'm getting nowhere. I can't figure how to detect that the 'faq/' is the end of the URL and I only want to exclude the div that specific URL, and continue to display the div on every other page of the site.

Any pointers? It would also be nice if I could find a way to exlude a list of URLs, rather than just one.

 

willybfriendly

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 4264952 posted 4:40 am on Feb 10, 2011 (gmt 0)

Would something like parse_url [php.net] work?

Readie

WebmasterWorld Senior Member



 
Msg#: 4264952 posted 12:47 pm on Feb 10, 2011 (gmt 0)

$_SERVER['REQUEST_URI']


Take a look at this variable :)

Asia_Expat

5+ Year Member



 
Msg#: 4264952 posted 6:39 am on Feb 11, 2011 (gmt 0)

Thanks for commenting folks. I think I've got it working with the following, can you see any potential problem with it? I'm a bit of a php duffer but I'm havin' a go and learning...

<?
$uri=$_SERVER['REQUEST_URI'];
if($uri == "/example-directory/faq/")
echo "";
else
echo "<div>groovy stuff</div>";
?>

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved