Hi David,
I am hoping you may be able to help out with a small problem.
I have used PT on its own no problem, but I would like to use it within WP this time and for future websites.
What I would like to do is write a post in WP, then show the price comparison underneath.
I have followed the instructions in this thread - http://www.pricetapestry.com/node/2289
Which works fine on a normal html/php website I have written from scratch, but not when I paste the php code into my wordpress post.
I have installed and enabled the EXEC-PHP plugin, (which allows php code to be run in a page or post), which works OK when I type a simple php line such as
<?php
echo "Hello World";
?>
<?php
$common_baseHREF = "http://www.discountpressurewashers.co.uk/comparison";
$common_path = "/home/30554/domains/discountpressurewashers.co.uk/html/comparison/";
$_GET["q"] = "Karcher HD 512 C Plus Pressure Washer 120 Bar 2200w 240v";
require($common_path."pricesExternal.php");
?>
The PT script seems to work OK in the /comparison/ folder on its own (I am just testing with 1 feed for now).
But in WP, when I view source, the code just stops as soon as it hits the above php. I have tried it on 2 WP sites with different themes, and am getting the same result.
Do you know why this may be happening at all?
Thanks for any help!
Hi Craig,
It just occurred to me that making the variables global might be necessary...Try using:
<?php
global $common_baseHREF;
global $common_path;
$common_baseHREF = "http://www.discountpressurewashers.co.uk/comparison";
$common_path = "/home/30554/domains/discountpressurewashers.co.uk/html/comparison/";
$_GET["q"] = "Karcher HD 512 C Plus Pressure Washer 120 Bar 2200w 240v";
require($common_path."pricesExternal.php");
?>
Cheers,
David.
Hi Craig,
I have come across a conflict between Price Tapestry's translate() library and some versions of WordPress - could you perhaps try, in your copy of searchExternal.php deleting or commenting out the following code (line 40) and seeing if that helps...
require($common_path."includes/translate.php");
Cheers,
David.
Thanks David,
This has solved the issue!!
Maybe it would be a good idea for me to enable the showing of error messages, although I am sure I already had done (but maybe not)!
Thanks again for your help!
Craig
Hi David,
Thanks a lot. I got this problem as well and just fixed it by comment out line 40. Why this happen and what translate.php use for?
Hi,
It's just because WordPress already has a translate() function; so they conflict! Within Price Tapestry, translate() is used to make it easy to make a foreign language version of the script simply be editing includes/translate.php.
Cheers,
David.
Is it easy to make a Wordpress site, which incluses PT, in a foreign (non English) language? I still want to be able to use translate.php (PT).
Hello Al,
It would certainly be possible - it just requires a complete change of the function name used within Price Tapestry in ordrer to avoid the conflict.
I would suggest pt_translate() in place of translate for example.
Do you know if your text editor has a "Serach and Replace in Files..." function that would help with this?
If so, the easiest way I think would be to rename the actual file to includes/pt_translate.php - and then change every instance of "translate" in all files to "pt_translate" - that should take care of the include statements, the translation array and function calls...
Cheers,
David.
Aha! That sounds easy... Let's start working!
Thank you for your quick reply.
Best regards.
Hi,
Do you have access to your web server's error log - that might give an indication as to the problem...
Cheers,
David.