Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-06-2005, 08:15 PM   PM User | #1
AshleyQuick
Regular Coder

 
Join Date: Jun 2002
Location: USA
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts
AshleyQuick is an unknown quantity at this point
Hiding graphic with if($_SERVER["PHP_SELF"]

Here's the scenarios:

I have a page:

http://www.mysite.com/forums.htm

...which contains an iframe:

http://www.mysite.com/forums/

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.

PHP Code:
<table align="center" width="<?=$twidth?>" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<?php
if(basename($_SERVER["PHP_SELF"]) == '/forums/index.php') {
//if($_SERVER["PHP_SELF"] == '/forums/index.php') {
?>
<?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>
<?php
} 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>
<?php
}
?>
</tr>
</table>
AshleyQuick is offline   Reply With Quote
Old 07-06-2005, 09:02 PM   PM User | #2
schleppel
Regular Coder

 
Join Date: Oct 2004
Posts: 330
Thanks: 0
Thanked 13 Times in 13 Posts
schleppel is an unknown quantity at this point
$_SERVER['PHP_SELF'] is just the name of the actual page, not the page that is calling the iframe page.

Quote:
Originally Posted by http://uk2.php.net/reserved.variables
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.
schleppel is offline   Reply With Quote
Old 07-06-2005, 09:42 PM   PM User | #3
AshleyQuick
Regular Coder

 
Join Date: Jun 2002
Location: USA
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts
AshleyQuick is an unknown quantity at this point
Quote:
Originally Posted by schleppel
$_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?
AshleyQuick is offline   Reply With Quote
Old 07-06-2005, 09:45 PM   PM User | #4
anarchy3200
Regular Coder

 
anarchy3200's Avatar
 
Join Date: Mar 2003
Location: England
Posts: 261
Thanks: 0
Thanked 1 Time in 1 Post
anarchy3200 is an unknown quantity at this point
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.
__________________
Mike
anarchy3200 is offline   Reply With Quote
Old 07-06-2005, 10:02 PM   PM User | #5
delinear
Regular Coder

 
Join Date: Feb 2005
Location: West Midlands, UK
Posts: 623
Thanks: 0
Thanked 0 Times in 0 Posts
delinear is an unknown quantity at this point
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:
PHP Code:
<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');

</script> 
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:

PHP Code:
// 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

__________________
~ Bazzy
delinear is offline   Reply With Quote
Old 07-07-2005, 04:51 PM   PM User | #6
AshleyQuick
Regular Coder

 
Join Date: Jun 2002
Location: USA
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts
AshleyQuick is an unknown quantity at this point
Hmm, nothing seems to be working. Any other suggestions?
AshleyQuick is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:22 AM.


Advertisement
Log in to turn off these ads.