Zen Cart Logo

Anchor Links

Views: 864

Results 1 to 4 of 4
19 Feb 2011, 10:51 PM
#1
autoace avatar

autoace

Totally Zenned

Join Date:
Jun 2009
Posts:
618
Plugin Contributions:
0

Anchor Links

I'm trying to set up some anchor linking on my product info display page and can not seem to get the syntax right.

I've been trying to follow w3schools.com on this and its not exactly working... can someone show me the error of my ways please:

<?php echo '<a href="#reviews"' . 'Read all reviews' . '</a>'; ?> <?php echo '<a name="reviews"' . TEXT_PRODUCT_REVIEWS . '</a>'; ?>
19 Feb 2011, 10:54 PM
#2
stevesh avatar

stevesh

Black Belt

Join Date:
Feb 2005
Location:
Lansing, Michigan USA
Posts:
19,793
Plugin Contributions:
2

Re: Anchor Links

I don't know about a PHP version, but it's just a special form of the HTML 'anchor' tag, which you should be able to insert into tpl_product_info_display.php. You would put the first line where you want the link to take the visitor, and the second where you want the link:

<a name="top">top</a>

Create your link and make sure you use the same name as you used in your anchor:

<a href="#top">Go to Top of Page</a>

I have had browser incompatibilty issues with that tag.

20 Feb 2011, 12:37 AM
#3
autoace avatar

autoace

Totally Zenned

Join Date:
Jun 2009
Posts:
618
Plugin Contributions:
0

Re: Anchor Links

I tried just the simply html way, not working either. I tried my php versions because I didn't think the simple one would. Right now neither are working... I think it has something to do with the path.

When I hover over the link, it reads mydomain.com/#reviews and then when I click on it, it goes to the home page not the reviews section at the bottom.

For now, I'm working on some other things, if you have any suggestions please do so, thanks.

2 Mar 2011, 11:32 AM
#4
rbarbour avatar

rbarbour

Totally Zenned

Join Date:
Feb 2010
Posts:
2,159
Plugin Contributions:
10

Re: Anchor Links

autoace:

<?php echo '<a href="#reviews"' . 'Read all reviews' . '</a>'; ?> <?php echo '<a name="reviews"' . TEXT_PRODUCT_REVIEWS . '</a>'; ?>

In zen cart anchor links need to be called in a specific way to work.

for your product info page:
<a href="<?php echo zen_href_link(zen_get_info_page($_GET['products_id']), zen_get_all_get_params(array('number_of_uploads')) ) . '#reviews'; ?>"><?php echo TEXT_READ_REVIEWS; ?></a>

I use this to return to top of page:
<a name="reviews"><?php echo TEXT_PRODUCT_REVIEWS; ?></a><a href="#" id="productInfoTop" onclick="window.scrollTo(0,0); return false"> Back to Top</a>

hope this helps!