marty.net 1001 Postcards Love Love Love Meep Meep ZenZodiac DailyQuotation

YOU ARE HERE:
Disabling CafeWish in your cpshop

HOME

CPSHOP|

|

|

EMAIL MARTY
  marty.net message board
  « Disabling CafeWish in your cpshop »
Welcome, Guest. Please Login or Register.
12/18/17 at 06:43:49
Home Help Search Login Register
   marty.net message board
   About cpshop
   Tutorials
   Disabling CafeWish in your cpshop
(Moderator: Marty)
Pages: 1 Reply Notify of replies Send the topic Print 
   Author  Topic: Disabling CafeWish in your cpshop  (Read 2725 times)
Hex Angel - Patrick
Gold Dragon
****

Posts: 500



Our nature lies in movement; complete calm is death.
   

WWW
Disabling CafeWish in your cpshop
« on: 04/29/07 at 10:53:41 »
Reply with quote Modify message

If you haven't, you should check out CafeWish (http://www.cafewish.com), a nifty bit of javascript that enables premium shop owners to divide products into category sections and put these and the products they contain in any order they wish.

Very cool. See this example

And you can get cpshop to display the categories and product order as well. (http://www.mycjreports.com/cafewishbb/viewtopic.php?f=7&t=4)

However, this does create issues for folks who use cpshop for generating affiliate content.  What if install CW but you like the way your cpshop looks already? Or what if one of the shops you affiliate with suddenly installs CW? The product thumbnail pages of that shop will lose everything after <[content]> and up to the first </noscript> found after it, or the end of file if there isn't a </noscript>. You'll lose all or most of your footer and the first script after <[content]>.

Fortunately, it's possible to make cpshop ignore CW with a very small modification to cpshop.cgi.

By default the CW javascript code will look something like the following in your cpshop product thumbnail pages:

Code:
<script language="javascript"><!--
var isScriptedPage=true;
//--></script>
<script src=http://www.cafewish.com/catscript.asp?sn=1381432&s=criticalgraphic&a=234991>
</script>
<!-- start cp hide -->
<noscript>

There may be more lines beginning with "var" but that's no matter.

Open cpshop.cgi in your editor and look for the following lines of code, near the bottom.

Code:
   &gettemplate;
   $html =~ s/<\[title\]>/$pagetitle/g;
   $html =~ s/<\[breadcrumb\]>/$breadcrumb/g;
   $html =~ s/<\[content\]>/$content/;

   unless (@ARGV) {
       print "Content-Type: text/html\n\n";
   }
   print $html;
   exit;

Copy and paste it after these lines which appear above it in the file:

Code:
  if ($hacked) {

      # Your code here. You have $content, $breadcrumb and $pagetitle
      # to work with.  Have fun.

Now in the code block you've just created, find this line

Code:
  $html =~ s/<\[content\]>/$content/;

and add a couple lines before it so it looks like this:

Code:
   #strip out CW javascript
   $content =~ s/<script src="*http:\/\/www.cafewish.com\/.*?<noscript>//si;
   $html =~ s/<\[content\]>/$content/;

That will strip out the code that calls the CW javascript while hiding the CP default output. It leaves behind the variable declaration, but that's harmless without the script call.

Finally, go to the line

Code:
$hacked = 0;

and change it to

Code:
 $hacked = 1;

Save cpshop.cgi and your template and upload them to your cpshop installation.

If you're an affiliate cpshopper you may wish to make this code change now for defensive purposes, just in case one of your affiliated shops installs CW in the future. If there is no CW in the page, it won't hurt anything.

This is a pretty safe modification. Marty hasn't made any changes to cpshop.cgi in a long time, at least since cpshop 2.0 if memory serves me. (It's cppage.lib and cpdata.lib that get modified the most often.) So the next time he releases an upgrade or update it's very unlikely you'll need to copy the 'updated' cpshop.cgi over your CW-less copy. Check the date on the file, and if it's older the one in the cpshop zip file then you'll need to upgrade it as well and recreate these changes in the upgraded copy.


hth,

p
« Last Edit: 07/26/08 at 09:22:25 by Hex Angel - Patrick » Logged

CPSHOP
www.PeaceAndLoveShop.com Namaste
BLOG
www.TheNomadicSpirit.com Inspired by travel
www.GodBeautyPerfectionLove.com Inspired by spirit
www.MyMuseMoviesMusicAndBooks.com Inspired by the arts
mikerose23
White Dragon
**

Gender: male
Posts: 19




   

WWW E-Mail
Re: Disabling CafeWish in your cpshop
« Reply #1 on: 06/07/07 at 06:20:55 »
Reply with quote Modify message


on 04/29/07 at 10:53:41, Hex_Angel wrote:
Fortunately, it's possible to make cpshop ignore CW with a very small modification to cpshop.cgi.


I have tried several times and have been unable to get this modification to work--the CW categories still appear. Before I start ripping my hair out (and trying yet again to find what I'm doing wrong), I just want to make absolutely sure the code in your post was correct.
Logged

Mike

http://designsbymike.net
Hex Angel - Patrick
Gold Dragon
****

Posts: 500



Our nature lies in movement; complete calm is death.
   

WWW
Re: Disabling CafeWish in your cpshop
« Reply #2 on: 06/07/07 at 21:34:12 »
Reply with quote Modify message

It should work fine.

Reply with an example of the CW code you're putting in the section descriptions of your Cafe Press stores.

p.
Logged

CPSHOP
www.PeaceAndLoveShop.com Namaste
BLOG
www.TheNomadicSpirit.com Inspired by travel
www.GodBeautyPerfectionLove.com Inspired by spirit
www.MyMuseMoviesMusicAndBooks.com Inspired by the arts
mikerose23
White Dragon
**

Gender: male
Posts: 19




   

WWW E-Mail
Re: Disabling CafeWish in your cpshop
« Reply #3 on: 06/08/07 at 06:29:45 »
Reply with quote Modify message


Code:
<script language="javascript"><!--
var isScriptedPage=true;
//--></script>
<script src="http://www.cafewish.com/catscript.asp?a=235221&s=comedancing&sn=2807607"></script>
<!-- start cp hide -->
<noscript>
Logged

Mike

http://designsbymike.net
Hex Angel - Patrick
Gold Dragon
****

Posts: 500



Our nature lies in movement; complete calm is death.
   

WWW
Re: Disabling CafeWish in your cpshop
« Reply #4 on: 06/08/07 at 07:35:16 »
Reply with quote Modify message

Ahh.  Jim has changed his code just enough to break my code -- there's a double quote in there now.

Try this in your cpshop.cgi instead:


Code:
#strip out CW javascript
  $content =~ s/<script src="*http:\/\/www.cafewish.com\/.*?<noscript>//si;
  $html =~ s/<\[content\]>/$content/;
Logged

CPSHOP
www.PeaceAndLoveShop.com Namaste
BLOG
www.TheNomadicSpirit.com Inspired by travel
www.GodBeautyPerfectionLove.com Inspired by spirit
www.MyMuseMoviesMusicAndBooks.com Inspired by the arts
mikerose23
White Dragon
**

Gender: male
Posts: 19




   

WWW E-Mail
Re: Disabling CafeWish in your cpshop
« Reply #5 on: 06/08/07 at 13:31:10 »
Reply with quote Modify message

THANK YOU! Yes, it's working now.
Logged

Mike

http://designsbymike.net
Pages: 1 Reply Notify of replies Send the topic Print 
Jump to:


marty.net message board (http://www.marty.net/cgi/marty/board/messageboard)

Powered by YaBB 1 Gold - Release (Yet Another Bulletin Board)
Copyright 2000-2001, X-Null. All Rights Reserved.