X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Recently Viewed Mod (https://forum.x-cart.com/showthread.php?t=36753)

siobahn 10-13-2009 06:21 AM

Re: Recently Viewed Mod
 
For those struggling with thumbnails; I hacked it up a little....
In the product.tpl file, I replaced the code with:

Code:

<script type="text/javascript">
prodImage='<img src="{$product.image_url}"/>';
prodName='<{$product.product}>';
var p0=('<br/><a href="'+document.URL+'">{include file="product_thumbnail.tpl" productid=$product.productid image_x=$product.tmbn_x image_y=$product.tmbn_y product=$product.product tmbn_url=$product.tmbn_url}<br/>{$product.product}</a><br/>${$product.taxed_price}<br/>');
</script>


Works for me now (NOTE: I have the "Recently Viewed" section on the right side...)

siobahn 10-20-2009 12:02 PM

Re: Recently Viewed Mod
 
Ok, while I fixed the thumbnail problem, I too am stumped by the "undefinedundefinedundefined" issue...

Anyone out there fix it??? I am no Javascript wiz so I can't figure it out...

lash 11-05-2009 04:56 AM

Re: Recently Viewed Mod
 
The original code works like a charm in 4.1.9. I had some issues, I guess still have with the encoding. It refused to accept some Swedish letters. I also had to change the currency and the way it is displayed since we display the currency symbol after the number and not before but that was pretty easy to do. Unfortunately I don't know how to add language variables in the admin so this can be translated into different languages. For example I tried to
Put lbl_recently_viewed in the "Variable:" box and entered the "Value:" box but nothing happened. Anyone that could enlighten me on how to add the language variables for lbl_no_recently_viewed_items" and "lbl_recently_viewed?

lash 11-05-2009 08:57 AM

Re: Recently Viewed Mod
 
Quote:

Originally Posted by MrSoft
Does anyone know how to resolve the issue with the thumbnails being called via http when the cart is in https?


I have to bump this. Seems many ppl are having this problem but so far no solution has been presented. I had to remove this wonderful mod when I discover all the secury warnings and the fact that the pics didn't show in secure mode. Anyone that has any solution for this?????? It should be in the interest of anyone using https...

TheWrongGrape 11-05-2009 09:06 AM

Re: Recently Viewed Mod
 
Quote:

Originally Posted by siobahn
Ok, while I fixed the thumbnail problem, I too am stumped by the "undefinedundefinedundefined" issue...

Anyone out there fix it??? I am no Javascript wiz so I can't figure it out...


I just installed this mod with certain changes to product.tpl and my CSS code to make it horizontal. However, I too was having the undefinedundefinedundefined issue. I figured this was whenever a variable hadn't been set yet. You can see you lose an "undefined" the more products you visit

Anyway, after some Googling on how to make a javascript if statement based on whether a variable is undefined or not, I've been able to fix it for me.

In your recently_viewed.tpl, find this:

Code:

  else {document.write("You have no recently viewed items.")
  }
  if (p1 !=null) {document.write(p1)}
  if (p2) {document.write(p2)}
  if (p3) {document.write(p3)}
  if (p4) {document.write(p4)}
  if(p0 !=null && p0 != p1 && p0 != p2 && p0 != p3 && p0 !=p4){
  setCookie("p1",p0)
  setCookie("p2",p1)
  setCookie("p3",p2)
  setCookie("p4",p3)
  }


and change to this

Code:

  else {document.write("You have no recently viewed items.")
  }
  if (p1 !=null) {document.write(p1)}
  if (p2 !=null && p2 !="undefined") {document.write(p2)}
  if (p3 !=null && p3 !="undefined") {document.write(p3)}
  if (p4 !=null && p4 !="undefined") {document.write(p4)}
  if(p0 !=null && p0 != p1 && p0 != p2 && p0 != p3 && p0 !=p4){
  setCookie("p1",p0)
  setCookie("p2",p1)
  setCookie("p3",p2)
  setCookie("p4",p3)
  }


It's basically saying "only try to write to the document if such-and-such variable IS NOT undefined"

Hope this helps someone!

TheWrongGrape 11-05-2009 11:01 PM

Re: Recently Viewed Mod
 
I wanted to share a few more things I did in case anyone else is looking to do the same.

To show nothing when there are no recently viewed products (meaning no title or text) I left the title blank (the include at the bottom) and made this change in recently_viewed.tpl

Code:

  var p1=getCookie("p1");
  var p2=getCookie("p2");
  var p3=getCookie("p3");
if (p1 !=null) {document.write('<p style="text-align:left; font-weight: bold;"><b>Recently Viewed</b></p>')}
  if (p1){
  }
  else {document.write()
  }


It basically only shows the title if the p1 variable (first product viewed) has been set, else it writes nothing. Use HTML and CSS to style. Note that I removed p4 because I am only showing the last 3.

In addition to changing my view to 3products, I made it horizontal as described by Qdox.

My full recently_viewed.tpl:

Code:

{capture name=menu}
<div class="recently">
{literal}
 <script type="text/javascript">
  if (p0){
  }
  else {var p0=null;
  }
  var p1=getCookie("p1");
  var p2=getCookie("p2");
  var p3=getCookie("p3");
if (p1 !=null) {document.write('<p style="text-align:left; font-weight: bold;"><b>Recently Viewed</b></p>')}
  if (p1){
  }
  else {document.write()
  }
  if (p1 !=null) {document.write('<div class="box1">'+p1+'</div>')}
  if (p2 !=null && p2 !="undefined") {document.write('<div class="box2">'+p2+'</div>')}
  if (p3 !=null && p3 !="undefined") {document.write('<div class="box3">'+p3+'</div>')}
  if(p0 !=null && p0 != p1 && p0 != p2 && p0 != p3){
  setCookie("p1",p0)
  setCookie("p2",p1)
  setCookie("p3",p2)
  }
 </script>
{/literal}
</div>
{/capture}
{include file="dialog.tpl" dingbats="dingbats_categorie.gif" title="" content=$smarty.capture.menu extra='width="100%"'}


Additionally, I wanted to display this in my main column (I have a 2-column layout: sidebar and main area) on the product pages only. As is, it was showing up on the home page, checkout pages, help pages, etc., at the very bottom. For my product pages, this meant it was showing up BELOW Tell a Friend and Reviews. I didn't want that. This was happening because the include for recently_viewed.tpl comes below the include for everything else (home_main.tpl which loads product.tpl) in my home.tpl file.

What I decided to do was to take out all the "extra" stuff on my product page (product.tpl) and pasted it into a new template which I called product_kickers.tpl. Decide where you want to "cut" the page and cut and paste into a new template.

Then on home.tpl, my new order is this:

Code:

{include file="customer/home_main.tpl"}
{if $main eq "product"}
{include file="customer/main/recently_viewed.tpl"}
{include file="customer/main/product_kickers.tpl"}
{/if}


The above code shows the Recently Viewed secton only on a product page AND position it after the main product stuff (home_main.tpl ends up loading my new top-half only product.tpl), beneath that will be recently_viewed.tpl, and then my new product_kickers.tpl which was the lower half of product.tpl.

I hope this makes sense and helps.

lash 11-05-2009 11:23 PM

Re: Recently Viewed Mod
 
TheWrongGrape, you don't happen to have a SSL and use this in https, secure mode? That's my only issue with this mod as for now. I get security warnings when being logged in, in secure mode and at first the pics are not showing, but after a little while they start to show, but they security warnings keeps on popping.

TheWrongGrape 11-06-2009 09:54 AM

Re: Recently Viewed Mod
 
Quote:

Originally Posted by lash
TheWrongGrape, you don't happen to have a SSL and use this in https, secure mode? That's my only issue with this mod as for now. I get security warnings when being logged in, in secure mode and at first the pics are not showing, but after a little while they start to show, but they security warnings keeps on popping.


Is it because the thumbnail URL for the recently viewed products aren't secure? Try this in product.tpl instad of the line that's there now.
Code:

<img src="{$product.image_url|replace:'http://':'https://'}">
It just replaces the http:// in the generated URL for the image with https://

lash 11-06-2009 07:16 PM

Re: Recently Viewed Mod
 
Quote:

Originally Posted by TheWrongGrape
Is it because the thumbnail URL for the recently viewed products aren't secure? Try this in product.tpl instad of the line that's there now.
Code:

<img src="{$product.image_url|replace:'http://':'https://'}">
It just replaces the http:// in the generated URL for the image with https://



So instead of:
prodImage='<img src="{$product.image_url}"/>';
I write:
prodImage='<img src="{$product.image_url|replace:'http://':'https://'}">

I tried the above and some other combinations but it didn't work for me. Please tell me I am wrong..:wink:

TheWrongGrape 11-06-2009 07:40 PM

Re: Recently Viewed Mod
 
Quote:

Originally Posted by lash
So instead of:
prodImage='<img src="{$product.image_url}"/>';
I write:
prodImage='<img src="{$product.image_url|replace:'http://':'https://'}">

I tried the above and some other combinations but it didn't work for me. Please tell me I am wrong..:wink:



Don't forget to put the semicolon (;) back in at the end of the new code.


All times are GMT -8. The time now is 05:52 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.