Page 1 of 2 12 LastLast
Results 1 to 10 of 17
  1. #1
    Join Date
    Oct 2006
    Location
    Alberta, Canada
    Posts
    4,571
    Plugin Contributions
    1

    Default Creating a 'Page Top' link / anchor

    Would like to create a link at the bottom of each page for "Page Top". As the script puls in URLs from various places, the normal HTML code will not work -- other than on the Home page. Once you go into a Catagory and start getting product IDs added, it gets a bit tricky.

    PHP Code:
    <a href="' . $_GET['main_page'] . '#ptop" title="Go to top of this Page">Page Top</a
    Just focusing on the code required within the '<a /a>' the above is what I have so far. My coding is not up to snuff enough to know which coding is required, to pull in the rest of the required URL.

    Can anyone point me in the right direction for the rest of the code needed?

  2. #2
    Join Date
    May 2006
    Location
    Texas
    Posts
    565
    Plugin Contributions
    4

    Default Re: Creating a 'Page Top' link

    if you wanted to.. you could just put this:

    Code:
    <a href="#ptop" title="Go to top of this Page">Page Top</a>
    and it should work, assuming you have an anchor at the top of the page (like in the header). it should automatically tag the url you're at with the #ptop

    so.. if you're at mydomain.com/index.php ... it will show mydomain.com/index.php#ptop

    if you're at mydomain.com/index.php?main_page=shippinginfo , it will show mydomain.com/index.php?main_page=shippinginfo#ptop

  3. #3
    Join Date
    Oct 2006
    Location
    Alberta, Canada
    Posts
    4,571
    Plugin Contributions
    1

    Default Re: Creating a 'Page Top' link

    One would think that but not so.

  4. #4
    Join Date
    Oct 2006
    Location
    Alberta, Canada
    Posts
    4,571
    Plugin Contributions
    1

    Default Re: Creating a 'Page Top' link

    Actually, to correct my last post, the 'id' tag does work for basic pages such as described. The problem comes in when you are in a Catagory and/or on a specific Product page.

    Once 'product_info' or 'cPath' gets put into the URL, the 'page top' link no longer works.

  5. #5
    Join Date
    Sep 2006
    Location
    San Antonio, TX, USA
    Posts
    32
    Plugin Contributions
    0

    Default Re: Creating a 'Page Top' link

    Quote Originally Posted by getyourgameshere.com View Post
    ...assuming you have an anchor at the top of the page (like in the header).
    Quote Originally Posted by Website Rob View Post
    One would think that but not so.
    Is that assumption correct?

  6. #6
    Join Date
    Oct 2006
    Location
    Alberta, Canada
    Posts
    4,571
    Plugin Contributions
    1

    Default Re: Creating a 'Page Top' link

    Yes. This was confirmed earlier, "the 'id' tag does work for basic pages".

  7. #7
    Join Date
    Nov 2003
    Location
    Haarlem | Netherlands
    Posts
    1,987
    Plugin Contributions
    15

    Default Re: Creating a 'Page Top' link

    A way it really* works for me on a "similar to Zen Cart site" is:
    Code:
    <a href="<?php echo $_SERVER['REQUEST_URI']; ?>#top">Top</a>
    (*really => without reloading the page when clicking the link)

  8. #8
    Join Date
    Nov 2003
    Location
    Haarlem | Netherlands
    Posts
    1,987
    Plugin Contributions
    15

    Default Re: Creating a 'Page Top' link

    And now that I think of it, this looks like it invokes a security problem
    Doesn't it?

  9. #9
    Join Date
    Oct 2006
    Location
    Alberta, Canada
    Posts
    4,571
    Plugin Contributions
    1

    Default Re: Creating a 'Page Top' link

    As it is only an 'echo' statement I do not see much of a security breach, that any other page would not have as well.

    Also, thank you for posting, Paul. Your code solved my problem.

  10. #10
    Join Date
    Nov 2003
    Location
    Haarlem | Netherlands
    Posts
    1,987
    Plugin Contributions
    15

    Default Re: Creating a 'Page Top' link

    Hi Rob,

    glad to hear that it works for you too :-)
    (I guess relative url's by default are not made to work with query strings, which seems more or less logical)

    The security issue I was thinking of is that $_SERVER['REQUEST_URI'] contains the query string, and the query string is user input. And, if echoed back, I would think this allows cross site scripting attacks.

    So I think it's better to use:
    Code:
    <a href="<?php echo zen_output_string_protected($_SERVER['REQUEST_URI']); ?>#top">Top</a>

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 3
    Last Post: 22 May 2010, 11:41 PM
  2. Creating a link to an Ez-Page
    By secarrol in forum Customization from the Admin
    Replies: 1
    Last Post: 24 Mar 2009, 06:41 AM
  3. creating anchor links in defined pages like shippinginfo.html
    By shocker in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 7 Dec 2008, 11:35 AM
  4. Creating link back to top of page
    By ctcentralinfo in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 12 Jul 2008, 11:48 PM
  5. Back to top anchor in footer.
    By ale.elatey in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 28 Nov 2006, 06:02 PM

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
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR