Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Would like to edit tpl_product_info_display.php to create hyperlink to URL

Would like to edit tpl_product_info_display.php to create hyperlink to URL

Views: 1,558

Results 1 to 9 of 9
24 Nov 2014, 2:10 PM
#1
hols_club avatar

hols_club

New Zenner

Join Date:
Nov 2014
Location:
Paignton
Posts:
39
Plugin Contributions:
0

Would like to edit tpl_product_info_display.php to create hyperlink to URL

I am trying to change my product display template so that each product will show the $products_url as a hyperlink

My site is an affiliate site so there are no products on this site
http://hols.club/butlins/index.php?main_page=product_info&cPath=1&products_id=7

At the moment I have each product showing as:
For more information and to make a booking for this holiday Visit: Butlins | What's On and Special Offers

using a generic url link, however I would like to use the url I have populated in the catalog.

However when I use href for $products_url it is adding hols.club/Butlins before the redirect and I can't work out how to just to get href to use only the $products_url which I know when I echo the variable is just the www address I need?

I have been searching the last few days through help and forums and tested a number of options but can't quite get it to work.
All help very much appreciated
Kind Regards
Thomas

24 Nov 2014, 4:31 PM
#2
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Would like to edit tpl_product_info_display.php to create hyperlink to URL

There's a couple of things that come to mind, one of which is a post that lat9 put out there a while back about templates and ZC version 1.5.3 and using the product url that you are trying to access/use. I can't seem to find it at the moment, but it does relate. Also without my looking deeper, I was thinking that there is/was a selection that can be made to make a zen_href_link call as a static uri. (Not sure that's considered a solution, but thought it bypassed adding the server info when set true.)

At the moment though this is something of an educated guess, I haven't tried it or looked at the associated code today to validate.

24 Nov 2014, 5:20 PM
#4
hols_club avatar

hols_club

New Zenner

Join Date:
Nov 2014
Location:
Paignton
Posts:
39
Plugin Contributions:
0

Re: Would like to edit tpl_product_info_display.php to create hyperlink to URL

Hi, sorry for the delay in replying as my hosting servers went down. Many thanks for the response, I will go and try that out right now :) I did see the post earlier but was concerned it might not be what I want, but an educated guess is good and will look at it carefully, if you happened remember selection that can be made to make a zen_href_link call as a static uri that would be great as well.

24 Nov 2014, 6:37 PM
#5
hols_club avatar

hols_club

New Zenner

Join Date:
Nov 2014
Location:
Paignton
Posts:
39
Plugin Contributions:
0

Re: Would like to edit tpl_product_info_display.php to create hyperlink to URL

Many thanks mc12345678 for giving me the confidence to try that out (as it needed a few files to be replaced) but worked through the instructions and voila I now have a url pointing to the address which is in the product url.

All I have to do now is fiddle around with the formatting to get the word "webpage" in blue. Problem solved though to get redirection working.

24 Nov 2014, 6:54 PM
#6
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Would like to edit tpl_product_info_display.php to create hyperlink to URL

hols.club:

Hi, sorry for the delay in replying as my hosting servers went down. Many thanks for the response, I will go and try that out right now :) I did see the post earlier but was concerned it might not be what I want, but an educated guess is good and will look at it carefully, if you happened remember selection that can be made to make a zen_href_link call as a static uri that would be great as well.

Btw, I see that you were able to solve your problem, though for the benefit of others if you could post your solution that would help.

In regards to the above question of a static uri, I've looked at the function as provided in 1.5.0 through https://www.zen-cart.com/docs and found the following:
The call to the function as published there takes the following parameters: $page='', $parameters='', $connection='NONSSL', $add_session_id=true, $search_engine_safe = true, $static=false, $use_dir_ws_catalog=true where if a value is not provided or the call is shortened then the variable takes on the above default value(s).

As for the function, it always returns with at least a server string related to your site as the first part of the returned uri, so even a static page is in reference to your site... But it is possible to serve up any page that is hosted on your site, whether it be specifically in the ZC store, or elsewhere in the path. What is also noticed though through the above thread that was provided it is possible to redirect to somewhere else, so as discovered can make things work to use the zen_href_link function to redirect away from the site, even a static page...

Anyways, the applicable code is found in includes/functions/html_output.php to understand how the function zen_href_link works based on the input of the above variables... Just remember that generally speaking you are trying to get things purchased from your site, not someone else's. :)

24 Nov 2014, 6:59 PM
#7
hols_club avatar

hols_club

New Zenner

Join Date:
Nov 2014
Location:
Paignton
Posts:
39
Plugin Contributions:
0

Re: Would like to edit tpl_product_info_display.php to create hyperlink to URL

Ah, although I think I have messed it up as now it is not doing it! I am sure once I updated the site it did redirect but now it is just going back to the index directory?

Any thoughts?

24 Nov 2014, 7:06 PM
#8
hols_club avatar

hols_club

New Zenner

Join Date:
Nov 2014
Location:
Paignton
Posts:
39
Plugin Contributions:
0

Re: Would like to edit tpl_product_info_display.php to create hyperlink to URL

Apologies, my fault, in a rush and placed back my old non working file onto the new one before taking a copy and editing that one. All working again now. Will update what I have done and will also look at your other post as that also seems excellent.

Many thanks again

24 Nov 2014, 7:28 PM
#9
hols_club avatar

hols_club

New Zenner

Join Date:
Nov 2014
Location:
Paignton
Posts:
39
Plugin Contributions:
0

Re: Would like to edit tpl_product_info_display.php to create hyperlink to URL

The Following steps will hopefully detail how I resolved the problem.

Problem:
For my store I wished to reproduce the $products_url directly under the Product Name and Price to reinforce to the customer that by clicking on the link it will take them to the product.

However my URLs are external to the site so did not follow sitename/websitefolder but directly to a www page
and as such just using $products_url meant the redirection failed.

Solution
User lat9 developed compatible_redirects.zip http://www.zen-cart.com/attachment.php?attachmentid=14296&d=1405686000

I downloaded the zip file
Backed up my site
And extracted the files in the correct directories

Once uploaded I found <!--eof free ship icon --> within tpl_product_info_display.php and moved the section from the end of the file to this point <!--bof Product URL -->

<?php if (zen_not_null($products_url)) { if ($flag_show_product_info_url == 1) { //-bof-compatible_redirects-lat9 *** 1 of 1 *** /* ?>
<p id="productInfoLink" class="productGeneral centeredContent"><?php echo sprintf(TEXT_MORE_INFORMATION, zen_href_link(FILENAME_REDIRECT, 'action=product&products_id=' . zen_output_string_protected($_GET['products_id']), 'NONSSL', true, false)); ?></p>
<?php */ ?>
<p id="productInfoLink" class="productGeneral centeredContent"><?php echo sprintf(TEXT_MORE_INFORMATION, $product_redirect->products_url_link ($_GET['products_id'])); ?></p>
<?php //-eof-compatible_redirects-lat9 *** 1 of 1 *** } // $flag_show_product_info_url } ?> <!--eof Product URL -->

This then put the link where I wanted it to be.