Zen Cart Logo
Forums / General Questions / Named Anchors Not Working?

Named Anchors Not Working?

Views: 5,391

Results 1 to 14 of 14
3 Mar 2010, 3:37 PM
#1
tracstev avatar

tracstev

New Zenner

Join Date:
Apr 2008
Posts:
61
Plugin Contributions:
0

Named Anchors Not Working?

Hi Guys

Just a small issue, I'm trying to add dynamic name anchor on the product pages which a customer can click which will scroll the page down to more information about the certain attributes of the item.

If I simply add the following html for some reason the link generated links back to the home page ie /# which i think is an issue with Ultimate SEO URLS ( i have checked the seo thread with no joy)

<p><a href="#C6">See also Chapter 6</a></p> <h2><a id="c6" name="C6">Chapter 6</a></h2> <p>This chapter explains ba bla bla</p>

Is there a piece of PHP code I can use to generate the product URL dynamically which I can wrap around with HTML to create the name anchor?

I basically want to mimic the following website which when the user clicks the "Personalize this Item" button the screen scrolls down to the additional attributes.

http://www.personalizationmall.com/Family-Name-Photo-Collage-Personalized-Canvas-Art-p8379.prod?sdest=dept&sdestid=1359&storeid=34&categoryid=1359

Any Ideas gladly appreciated :)

4 Mar 2010, 2:33 PM
#2
tracstev avatar

tracstev

New Zenner

Join Date:
Apr 2008
Posts:
61
Plugin Contributions:
0

Re: Named Anchors Not Working?

Hi

It looks like the problem isn't with SEO URLS, it is with the <base> tag in the html_header.php file. I have commented out the line and now named anchors point to the current page not the home page.

PS: If anyone sees a problem with this let me know! so far so good no issues.

Thanks

4 Mar 2010, 2:47 PM
#3
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Named Anchors Not Working?

tracstev:

Hi

It looks like the problem isn't with SEO URLS, it is with the <base> tag in the html_header.php file. I have commented out the line and now named anchors point to the current page not the home page.

PS: If anyone sees a problem with this let me know! so far so good no issues.

Thanks

VERY BAD MOVE... restore this...

Dt Byte addressed anchors somewhere on the forum. Apparently you have to put the full page path into the anchor.

Search for anchors with Dr Byte as the poster...

4 Mar 2010, 2:55 PM
#4
tracstev avatar

tracstev

New Zenner

Join Date:
Apr 2008
Posts:
61
Plugin Contributions:
0

Re: Named Anchors Not Working?

Thanks for the quick reply :smile:

Unfortunately I can't put the whole path in as I want the code as part of the template in the product_info_display file, otherwise i would have to edit every single product page. I have tried using a few Php commands to get the URL into the page however it doesn't display the SEO url structure instead it shows the original zencart url structure.

4 Mar 2010, 2:59 PM
#5
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Named Anchors Not Working?

SEO url rewriters are obsolete and have no value in SE indexing. In fact MATT CUTTS (Head of Google Search) said way back in 2006 that the SE's now PREFER the dynamic link to be retained as the SE's are more than capable of indexing dynamic url's

In fact, there is a RISK of creating the impression of duplicate content with SE's (for which you are penalized), when using badly configured SEO url re-writes.

4 Mar 2010, 3:31 PM
#6
tracstev avatar

tracstev

New Zenner

Join Date:
Apr 2008
Posts:
61
Plugin Contributions:
0

Re: Named Anchors Not Working?

If i could turn back time I would never have installed it :) but I can't uninstall it as it would be too risky for my business to lose any google ranking :(

4 Mar 2010, 4:51 PM
#7
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Named Anchors Not Working?

tracstev:

If i could turn back time I would never have installed it :) but I can't uninstall it as it would be too risky for my business to lose any google ranking :(

It would probably improve ! :D

Are you using Andrew Berezin's SITEMAPS XML to interface with your SE webmaster dashboards?

If not, this is a better way to work hand-in-hand with the SE's.

5 Mar 2010, 8:29 AM
#8
tracstev avatar

tracstev

New Zenner

Join Date:
Apr 2008
Posts:
61
Plugin Contributions:
0

Re: Named Anchors Not Working?

I am using an XML site map which is working well.

I am looking at increasing the number of conversions at the moment and reducing bailed carts and the product info screen is a problem as people need to scroll down the page to find the attributes I'd prefer a button at the top which the user clicks which scrolls them to the location of the attributes where they can add extras and add to cart, this also allows me to push additional images and descriptions up the page and also add more content.

I was thinking about this again last night, instead of losing the BASE tag I think a better way would be to mimic what Ultimate seo Urls does but my SQL/PHP knowlege isnt great.

The format for the URLS is:

[product-name]-p-[pid].html

Any ideas how i pull this from the mysql database and put into the html safely?

Thanks

Andy

5 Mar 2010, 8:45 AM
#9
drbyte avatar

drbyte

Sensei

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

Re: Named Anchors Not Working?

Definitely don't mess with the <base> tag.

Where exactly on the page are you wanting to put the anchor tag?
Will it be the SAME on every page?
Are there any exceptions? if yes, why? and what are they?
Is there a particular spot inside tpl_product_info_display.php where you want the anchor link to appear? Where? Paste here the 5 lines above and below it.
And where are you placing the anchor name?

5 Mar 2010, 9:31 AM
#10
tracstev avatar

tracstev

New Zenner

Join Date:
Apr 2008
Posts:
61
Plugin Contributions:
0

Re: Named Anchors Not Working?

Hi Dr Byte :)

I am wanting to put the new anchor text attached to a new button above the product description but below the title of the product.

The anchor text will need to go onto every product page with no exceptions.

The anchor name will need to go where it says "Add Personalisation Details:" at the top of the attributes column.

Thanks !!!

--
product_info_display (attributes & product description portion)


<!--eof Main Product Image--> <div style="border: 1px solid #666666; margin: 0px; padding: 2px; width: 295px; float:left;"><div> <p style="color: #ffffff; border:#666666; background-color: #00CC66; font-weight: bold; padding: 2px; font-size: 14px;">Add Personalisation Details:</p></div> <!--bof Add to Cart Box --> <?php if (CUSTOMERS_APPROVAL == 3 and TEXT_LOGIN_FOR_PRICE_BUTTON_REPLACE_SHOWROOM == '') { // do nothing } else { ?> <?php $display_qty = (($flag_show_product_info_in_cart_qty == 1 and $_SESSION['cart']->in_cart($_GET['products_id'])) ? '<p>' . PRODUCTS_ORDER_QTY_TEXT_IN_CART . $_SESSION['cart']->get_quantity($_GET['products_id']) . '</p>' : ''); if ($products_qty_box_status == 0 or $products_quantity_order_max== 1) { // hide the quantity box and default to 1 $the_button = '<input type="hidden" name="cart_quantity" value="1" />' . zen_draw_hidden_field('products_id', (int)$_GET['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT, 'onclick="javascript:toggleLayer(\'errorCaution\'); return upload_progress();"'); } else { // show the quantity box $the_button = PRODUCTS_ORDER_QTY_TEXT . '<input type="text" name="cart_quantity" value="' . (zen_get_buy_now_qty($_GET['products_id'])) . '" maxlength="6" size="4" /><br />' . zen_get_products_quantity_min_units_display((int)$_GET['products_id']) . '<br />' . zen_draw_hidden_field('products_id', (int)$_GET['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT, 'onclick="javascript:toggleLayer(\'errorCaution\'); return upload_progress();"'); } $display_button = zen_get_buy_now_button($_GET['products_id'], $the_button); ?> <?php if ($display_qty != '' or $display_button != '') { ?> <div id="cartAdd"> <?php echo $display_qty; echo $display_button; ?> </div> <?php } // display qty and button ?> <?php } // CUSTOMERS_APPROVAL == 3 ?> <!--eof Add to Cart Box--> <!--bof Attributes Module -->

<a href='faq.html' onClick="window.open('faq.html', 'RIC','width=800px,resizable=yes,scrollbars=yes');return false;" rel="nofollow">Help?</a>

<?php if ($pr_attr->fields['total'] > 0) { ?> <?php /** * display the product atributes */ require($template->get_template_dir('/tpl_modules_attributes.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_attributes.php'); ?> <?php } ?> <!--eof Attributes Module --> </div> </div> <div style="background: #fff;"> <!--bof Product description --> <!--bof Product Name--> <img style="float:right;" src="/includes/templates/toyshop/images/productinfo/in-stock.gif" /> <!-- AddThis Button END --> <h1 id="productName" class="productGeneral"><?php echo $products_name; ?></h1> <!--bof Product Price block --> <h2 id="productPrices" class="productGeneral"> <?php // base price if ($show_onetime_charges_description == 'true') { $one_time = '<span >' . TEXT_ONETIME_CHARGE_SYMBOL . TEXT_ONETIME_CHARGE_DESCRIPTION . '</span><br />'; } else { $one_time = ''; } echo $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE : '') . zen_get_products_display_price((int)$_GET['products_id']); ?></h2> <!--eof Product Price block --> <!--bof free ship icon --> <?php if(zen_get_product_is_always_free_shipping($products_id_current) && $flag_show_product_info_free_shipping) { ?> <div id="freeShippingIcon"><?php echo TEXT_PRODUCT_FREE_SHIPPING_ICON; ?></div> <?php } ?> <!--eof free ship icon --> <!--eof Product Name--> <?php if ($products_description != '') { ?> <div id="productDescription" class="productGeneral biggerText"><?php echo stripslashes($products_description); ?></div> <?php } ?> <!--eof Product description -->
5 Mar 2010, 9:52 AM
#11
drbyte avatar

drbyte

Sensei

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

Re: Named Anchors Not Working?

Put this in your tpl_product_info_display.php template where you want the clickable "button" to appear:<a href="<?php echo zen_href_link(zen_get_info_page($_GET['products_id']), zen_get_all_get_params(array('number_of_uploads')) ) . '#personalise'; ?>"><img src="INSERT BUTTON IMAGE PATH HERE" />click</a>and then in whichever template is rendering the selections (tpl_modules_attributes.php perhaps?), simply add this where you want the page to jump to:```
<a name="personalise" />

5 Mar 2010, 3:42 PM
#12
tracstev avatar

tracstev

New Zenner

Join Date:
Apr 2008
Posts:
61
Plugin Contributions:
0

Re: Named Anchors Not Working?

That works great thanks! :smile:

I reimputted the base tag back as a customer contacted me that the checkout success page didn't display properly which was likely to be the cause of my tinkering over the past few days!

If either of you want anything engraved PM me!

9 Feb 2011, 9:53 AM
#13
bonnit avatar

bonnit

Zen Follower

Join Date:
Jun 2009
Location:
Kent, UK
Posts:
350
Plugin Contributions:
0

Re: Named Anchors Not Working?

is there any way of only showing the clickable button when there is attributes? much like the attributes only show if they are assigned?

or using php within product descriptions possibly so i can manually add this for each applicable product?

16 Feb 2011, 6:12 AM
#14
drbyte avatar

drbyte

Sensei

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

Re: Named Anchors Not Working?

If you put it in the tpl_module_attributes like I mentioned a couple posts above, then it will only appear if that template file is called, and if you put it inside the logic that tests for active attributes, then it will only show if there are attributes.