argent — 2012-05-18T01:11:52-04:00 — #1
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.
Any help greatly appreciated.
argent — 2012-05-18T07:45:04-04:00 — #2
get page url using php
and found this -> http://webcheatsheet.com/php/get_current_page_url.php
Right on the money!
guido2004 — 2012-05-18T11:04:07-04:00 — #3
Ain't search engines great?
mobilebadboy — 2012-05-21T01:37:44-04:00 — #4
I include that in footer includes, it scrolls to the top on every page.
lemon_juice — 2012-05-21T03:48:32-04:00 — #5
If you don't use <base href="..."> in your documents then you don't need the current page at all, just use this:
<div id="upArrow"><a href="#top"></a></div>
If you use <base href> then $SERVER['REQUESTURI'] has everything you need for the link:
<div id="upArrow"><a href="<?=htmlspecialchars($_SERVER['REQUEST_URI']) ?>#top"></a></div>