How might I add a "Back To Top" link in Drupal? My first stab:

<a name="top"></a>
...
<a href="#top">Back to top</a>

When I hover over the link "Back to top" it displays http://example.org/d/#top no matter what page I am on.

How do I get the name of the current page in Drupal? Has anyone else successfully gotten this to work in Drupal? This seems like an easy question, but did not find anything from my search in the Drupal forums.

Thank you for your time.

Kevin
Citrus Heights, CA

Comments

iokevins’s picture

This worked for me:

<a href="/<?php print url($_GET['q'], NULL, NULL, TRUE); ?>#top">Back to top</a>

"Extraordinary claims require extraordinary evidence"
-- Carl Sagan

venkat-rk’s picture

Great tip. Thanks for sharing this.

iokevins’s picture

You are welcome :)

"Extraordinary claims require extraordinary evidence"
-- Carl Sagan

salimshaik’s picture

Hi,

Please use this module: back to top module.
http://drupal.org/project/back_to_top.

It will works nice.