Zen Cart Logo
If this is your first visit, check our documentation. To post, register or login.
Forums / Customizing the Look of Your Shop / Templates, Stylesheets, Page Layout / EZ Page "back to page top links"-how to code?

EZ Page "back to page top links"-how to code?

Locked

Started by notageek on 9 Apr 2010, 3:35 PM · Views: 1,066

Results 1 to 4 of 4
This thread is locked. New replies are disabled.
9 Apr 2010, 3:35 PM
#1
notageek avatar

notageek

Zen Follower

Join Date:
Mar 2009
Posts:
418
Plugin Contributions:
0

Post #1 by notageek

Hi. I copied working HTML code to create a page that starts out with a list of topics (i.e., FAQs), with each topic title linking to the paragraph on that topic, and after that paragraph a "back to top" link going back to the top of the page.

In EZ pages, none of the links work as expected. All links simply return to the home page. The home page shows the link name, i.e., "#publisher," or "#back," as an add-on to its web address.

My code is:

<a name="back"></a>

<ol> <li><a href="#publisher">Search by publisher</a></li> . . .

the above link in my html editor goes to:

<h3><a name="publisher">1. Search by publisher</a></h3> . . .

and when I finish the paragraph I can click a link

<a href="#back"> Back to Top</a>

which takes me back to the top.

It is puzzling that this works in my HTML editor but not in the actual EZ page.

It seems strange that the home page link would just rename itself, i.e., to "www.homepage.com/#publisher," or "www.homepage.com/#back, and strange that ANY link goes to the home page, whether #publisher, or #back.

I suspect that this has something to do with PHP.

Thanks for any explanatory comments.

9 Apr 2010, 4:08 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #2 by drbyte

Those "back to page top links" are called "anchors" ... which is what the "a" in <a href> stands for.

Since Zen Cart uses <base href> to allow easy relative paths to be specified for images and stylesheets and javascripts, when you want to use named anchors, you must specify the full path to the page you're referencing.

So, you could make your <a name="back"> link somewhere on your page, and then wherever you want to put a link to jump up/down to that named anchor, you simply enter <a href="index.php?main_page=pages?id=12345#back">
You do have to specify all of that in addition to the #back anchor you're pointing to.
(you could include the domain name too if you really want, but that shouldn't be necessary)

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

10 Apr 2010, 12:37 AM
#3
notageek avatar

notageek

Zen Follower

Join Date:
Mar 2009
Posts:
418
Plugin Contributions:
0

Post #3 by notageek

Dr. Byte, Thanks very much for the clear explanation and especially the example code.

Notageek

20 May 2010, 10:31 AM
#4
dw08gm avatar

dw08gm

Totally Zenned

Join Date:
Sep 2008
Location:
DownUnder, overlooking South Pole.
Posts:
1,026
Plugin Contributions:
2

Post #4 by dw08gm

Putting the <a name="back"></a>, or <a name="top"></a>, or whatever you want to call the anchor, in

includes\templates\YOUR_TEMPLATE\common\tpl_header.php

immediately after and on the same line as <div id="headerWrapper">, or whatever you have to called the very first <div>,

eg <div id="headerWrapper"><a name="top"></a>

can save you having to put it on any other page.