View Single Post
  #146  
Old 11-05-2009, 11:01 PM
 
TheWrongGrape TheWrongGrape is offline
 

Advanced Member
  
Join Date: Nov 2002
Location: Los Angeles, CA
Posts: 68
 

Default 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.
Reply With Quote