You are here:  » change jump url's


change jump url's

Submitted by marco on Mon, 2010-08-30 15:21 in

Hello,

How can i change the jump url's from:
http://www.mywebsite.com/jump.php?id=74295

To something like:
http://www.mywebsite.com/out/74295/

Regards,
Marco

Submitted by support on Tue, 2010-08-31 08:09

Hi Marco,

First, add a new rule to the end of your .htaccess as follows:

RewriteRule ^out/(.*)/$ jump.php?id=$1 [L]

And then look for the following code on line 53 of includes/tapestry.php:

      return $config_baseHREF."jump.php?id=".$product["id"];

...and REPLACE that with:

      return $config_baseHREF."out/".$product["id"]."/";

Cheers,
David.
--
PriceTapestry.com

Submitted by richard on Sat, 2019-10-12 14:02

Hi David,

Just looking at ways to use jump urls. Obviously these change on each new import.

Would it be possible to create a jump url that uses product name and merchant as opposed to a number?

jump.php?id=4671 becomes jump.php?id=productname-merchant

This approach would create unique combination and the ability to have a jump url that will work after another import.

Best regards,

Richard

Submitted by support on Wed, 2019-10-16 08:57

Hello Richard,

Sure - base64 encoding can be used to keep things tidy. To do this, edit includes/tapestry.php and look for the following code at line 98:

      return $config_baseHREF."jump.php?id=".$product["id"];

...and REPLACE with:

      return $config_baseHREF."jump.php?id=".base64_encode($product["merchant"]."|".$product["normalised_name"]);

And then edit jump.php and look for the following code beginning at line 4:

  $id = (isset($_GET["id"])?intval($_GET["id"]):"");
  if (!$id) exit();
  $sql = "SELECT filename,buy_url FROM `".$config_databaseTablePrefix."products` WHERE id='".database_safe($id)."'";

...and REPLACE with:

  $id = (isset($_GET["id"])?base64_decode($_GET["id"]):"");
  if (!$id) exit();
  $parts = explode("|",$id);
  $sql = "SELECT filename,buy_url FROM `".$config_databaseTablePrefix."products` WHERE merchant='".database_safe($parts[0])."' AND normalised_name='".database_safe($parts[1])."'";

Cheers,
David.
--
PriceTapestry.com

Submitted by richard on Wed, 2019-10-16 11:08

Hi David,

Many thanks, I will give it ago :)

Best regards

Richard

Submitted by richard on Wed, 2019-10-16 11:29

Hi David,

Just looking at my jump file, it is different to the one you are amending. I have this code:

{code saved}

Submitted by support on Wed, 2019-10-16 11:40

Hi Richard,

In that version where you have the following code at line 2:

  $sql = "SELECT filename,buy_url FROM `".$config_databaseTablePrefix."products` WHERE id='".database_safe($_GET["id"])."'";

...REPLACE with:

  $id = (isset($_GET["id"])?base64_decode($_GET["id"]):"");
  if (!$id) exit();
  $parts = explode("|",$id);
  $sql = "SELECT filename,buy_url FROM `".$config_databaseTablePrefix."products` WHERE merchant='".database_safe($parts[0])."' AND normalised_name='".database_safe($parts[1])."'";

Cheers,
David.
--
PriceTapestry.com

Submitted by richard on Wed, 2019-10-16 11:56

Hi David

Just tried that but the jump still remained as a numeric, but on clicking the url could not be found.

Submitted by support on Wed, 2019-10-16 12:13

Hi Richard,

Have you made the change to the tapestry_buyURL() function in includes/tapestry.php in the first part of the mod - that is what should change the numeric to the merchant|name?

Cheers,
David.
--
PriceTapestry.com

Submitted by richard on Wed, 2019-10-16 12:17

Hi David,

I've just realised I'm working on a wordpress installation and I will need to modify the pto files rather pt files.

Sorry for the confusion. Can you please point me in the right direction for wordpress

Best regards

Richard

Submitted by support on Wed, 2019-10-16 13:13

Hi Richard,

You still need the modification to jump.php in the Price Tapestry installation as above but then in the plugin file pto/pto_common.php look for the following code at line 105:

    return $pto_config_externalBaseHREF."jump.php?id=".$product->id;

...and REPLACE with:

    return $pto_config_externalBaseHREF."jump.php?id=".base64_encode($product->merchant."|".$product->normalised_name);

Cheers,
David.
--
PriceTapestry.com

Submitted by richard on Wed, 2019-10-16 13:20

Hi David,

Many thanks.

Yes the jump works, although I'm a bit surprised by the jump url (see below). I was expecting to see merchant name & product name

{link saved}

Submitted by richard on Wed, 2019-10-16 13:28

Of course, it is encoded in to base 64!

What are the advantages for encoding the jump url?

Submitted by support on Wed, 2019-10-16 14:22

Hi Richard,

Base 64 encoding is a tidy way to ensure that everything being passed is URL safe however if you would prefer the merchant and product name visible in the link you can use urlencode() instead. In the mod to pto_common.php just replace base64_encode with urlencode and in jump.php since no decoding is necessary just use:

  $id = (isset($_GET["id"])?$_GET["id"]:"");

Cheers,
David.
--
PriceTapestry.com

Submitted by richard on Wed, 2019-10-16 14:31

Hi David,

Many thanks for your help.

Rich