View Full Version : Hiding graphic with if($_SERVER["PHP_SELF"]

07-06-2005, 08:15 PM
Here's the scenarios:

I have a page:


...which contains an iframe:


In the forums, I have a graphic allowing the user to bust out of the iframe and into "full screen" mode (which is simply a hyperlink with target=_top)

Is it possible to modify the code below to convert the "full screen" mode graphic to a spacer (effectively making it disappear) once they've gone full screen?

As you can see below, I've tried a couple different approaches (one is commented out). This code normally works but the iframe functionality is complicating things. :(

<table align="center" width="<?=$twidth?>" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
if(basename($_SERVER["PHP_SELF"]) == '/forums/index.php') {
//if($_SERVER["PHP_SELF"] == '/forums/index.php') {

<td align="center" valign="middle" width="98%"><div align="right"><img src="images/spacer.gif" alt="" width="24" height="24" border="0"></div><!-- <span class="finfo"><?=$upb_info?></span><br> --><span class="tbar"><?=$tools?></span></td>
} else {
<td align="center" valign="middle" width="98%"><div align="right"><a href="http://www.mysite.com/forums/" target="_top" title="Switch to Full Screen Mode"><img src="images/full.screen.gif" alt="" width="24" height="24" border="0"></a></div><!-- <span class="finfo"><?=$upb_info?></span><br> --><span class="tbar"><?=$tools?></span></td>

07-06-2005, 09:02 PM
$_SERVER['PHP_SELF'] is just the name of the actual page, not the page that is calling the iframe page.

The filename of the currently executing script, relative to the document root. For instance, $_SERVER['PHP_SELF'] in a script at the address http://example.com/test.php/foo.bar would be /test.php/foo.bar. The __FILE__ constant contains the full path and filename of the current (i.e. included) file.

07-06-2005, 09:42 PM
$_SERVER['PHP_SELF'] is just the name of the actual page, not the page that is calling the iframe page.

That said, how can I make this work?

07-06-2005, 09:45 PM
Could you not set a variable when you click the button to tell it to go to fullscreen then check this, if it is set hide the image?

e.g. the link goes to forums/index.php?image=1

and if image=1 do not show the image.

07-06-2005, 10:02 PM
I might be wrong but I don't think you can get the name of the parent window of an iframe using PHP, it can only return information regarding the iframe itself.

There are a couple of things that may work, you could try a javascript solution, I'm not great at javascript but I think it'd be something along the lines of:

<script type="text/javascript">
if(top.location.href != 'http://www.domain.com/forums/index.php') {
document.write('your code to display the full screen mode link');

Alternatively, in your http://www.mysite.com/forums.htm page, when you specify the iframe src, add a querystring variable. Then in your iframe page, check if the querystring variable is present, if it is then it's likely that you are inside the iframe:

// http://www.mysite.com/forums.htm
<iframe src="http://www.mysite.com/forums/index.php?framed=yes">

// http://www.mysite.com/forums/index.php
if(isset($_GET['framed'])) {
// we are in the frame, show full screen mode link
} else {
// we are in full screen mode, don't show the link

07-07-2005, 04:51 PM
Hmm, nothing seems to be working. Any other suggestions?

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum