SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Apr 2003
    Location
    Perth W.A.
    Posts
    131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Calling the current page

    Hi Guys,
    I have a footer.php included file from which I need to run a PHP script which extracts the current containing page URL to then echo it to HTML code inside footer.php for a 'Back to top of page' button.

    Top of page code inside footer.php: <div id="upArrow"><a href="current-page.php#top"></a></div>

    Am I on the right track here? -> <?php get_page( $page_id ) ?>

    The following URL shows the page with the working 'Top of Page' button, but the link inside the #upArrow is static it needs it to 'sense' the current page URL regardless of where you are on the site.

    http://www.temp.elementdrilling.com.au/gallery.php

    Any help greatly appreciated.

  2. #2
    SitePoint Zealot
    Join Date
    Apr 2003
    Location
    Perth W.A.
    Posts
    131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I Googled
    get page url using php
    and found this -> http://webcheatsheet.com/php/get_current_page_url.php

    Right on the money!

  3. #3
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,509
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Ain't search engines great?

  4. #4
    SitePoint Evangelist MobileBadBoy's Avatar
    Join Date
    Jun 2002
    Location
    Mobile, Alabama
    Posts
    451
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe I'm misunderstanding, but why not just use a generic javascript?

    Code:
    <a href="javascript:scroll(0,0)">Back to Top</a>
    I include that in footer includes, it scrolls to the top on every page.
    Shawn Kerr .com

  5. #5
    SitePoint Guru bronze trophy
    Join Date
    Dec 2003
    Location
    Poland
    Posts
    930
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Argent View Post
    Hi Guys,
    Top of page code inside footer.php: <div id="upArrow"><a href="current-page.php#top"></a></div>

    Am I on the right track here? -> <?php get_page( $page_id ) ?>
    If you don't use <base href="..."> in your documents then you don't need the current page at all, just use this:
    Code:
    <div id="upArrow"><a href="#top"></a></div>
    If you use <base href> then $_SERVER['REQUEST_URI'] has everything you need for the link:
    Code:
    <div id="upArrow"><a href="<?=htmlspecialchars($_SERVER['REQUEST_URI']) ?>#top"></a></div>


Bookmarks

Posting Permissions

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