Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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>

  • #2
    Regular Coder
    Join Date
    Oct 2004
    Posts
    360
    Thanks
    0
    Thanked 17 Times in 17 Posts
    $_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.

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #4
    Regular Coder anarchy3200's Avatar
    Join Date
    Mar 2003
    Location
    England
    Posts
    261
    Thanks
    0
    Thanked 1 Time in 1 Post
    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

  • #5
    Regular Coder
    Join Date
    Feb 2005
    Location
    West Midlands, UK
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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


  • #6
    Regular Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hmm, nothing seems to be working. Any other suggestions?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •