Zen Cart Logo
Forums / 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

Views: 1,063

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

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

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,513
Plugin Contributions:
176

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

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)

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

notageek

Zen Follower

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

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

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,017
Plugin Contributions:
2

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

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.