You are here:  » Wordpress and PT for Dummies

Support Forum



Wordpress and PT for Dummies

Submitted by Al on Mon, 2011-01-24 20:36 in

Hi there,

I want to start a new site in Wordpress and integrate PT. This site will not be in English.
I have read a lot of threads here on the forum about problematic integration into WP. Conflicts in the scripts etc. Half a year ago I tried to build a WP/PT site, but I 'gave up'. Well, I wanted to try it again later... So here I am again!
Who can point out how to start? First install WP, then PT or the other way around? All tips are mostly welcome. I remember the 'translate' problem in the script, which gave me a hard time.

Cheerio,
Al

Submitted by support on Tue, 2011-01-25 13:19

Hello Al,

I am working on a database API and subsequently full Wordpress plugin for price comparison based on a Price Tapestry managed database, but in the mean team you can obtain good results with the external scripts - latest versions can be found in this thread...

Assuming that you want your main site to be Wordpress powered, install Wordpress in your main folder, and Price Tapestry into a sub-directory, suitably named (for example /shopping/). For the least conflicts, use the same database for both scripts. Wordpress uses a table prefix of wp_ by default, so before installation, edit your Price Tapestry config.php and use a prefix of pt_ by changing line 30 to:

  $config_databaseTablePrefix = "pt_";

With that in place, you should be able to use the external scripts as describe without any database conflicts...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by Al on Sat, 2011-01-29 16:12

As a hint for other users using a different language than English:
Replace ALL 'translate' words into 'pt_translate' (also change translate.php into pt_translate.php). This avoids conflicts in WP.
You can do this with a simpel search and replace in any code editing program.

I would like to make an advanced filter in a WP sidebar. You can PHP or HTML there anything you like, the promise...
Several sidebar filter threads are found on the PT forum, however not one to use external filters in WP (correct me if I'm wrong).
I would like to filter search results in i.e. price ranges:

1-50
51-100
101-200
etc.

Would it be easy to implement this?

Best regards,
Al

Submitted by Al on Sat, 2011-01-29 20:18

.htaccess in the WP directory:

# BEGIN WordPress
RewriteEngine on
# Unless you have set a different RewriteBase preceding this point,
# you may delete or comment-out the following RewriteBase directive:
RewriteBase /
# if this request is for "/" or has already been rewritten to WP
RewriteCond $1 ^(index\.php)?$ [OR]
# or if request is for image, css, or js file
RewriteCond $1 \.(gif|jpg|jpeg|png|css|js|ico)$ [NC,OR]
# or if URL resolves to existing file
RewriteCond %{REQUEST_FILENAME} -f [OR]
# or if URL resolves to existing directory
RewriteCond %{REQUEST_FILENAME} -d
# then skip the rewrite to WP
RewriteRule ^(.*)$ - [S=1]
# else rewrite the request to WP
RewriteRule . /index.php [L]
# END WordPress

In the /shopping directory:

RewriteEngine On
RewriteBase /shopping/
RewriteRule ^/product/(.*).html$ /products.php?q=$1&rewrite=1&%{QUERY_STRING} [L]
RewriteRule ^/review/(.*).html$ /reviews.php?q=$1&rewrite=1&%{QUERY_STRING} [L]
RewriteRule ^/shop/$ shops.php
RewriteRule ^/shop/(.*)/$ /search.php?q=shop:$1:&rewrite=1%{QUERY_STRING} [L]
RewriteRule ^/shop/(.*)/(.*).html$ /search.php?q=shop:$1:&page=$2&rewrite=1%{QUERY_STRING} [L]
RewriteRule ^/category/$ categories.php
RewriteRule ^/category/(.*)/$ /search.php?q=category:$1:&rewrite=1%{QUERY_STRING} [L]
RewriteRule ^/category/(.*)/(.*).html$ /search.php?q=category:$1:&page=$2&rewrite=1%{QUERY_STRING} [L]
RewriteRule ^/brand/$ brands.php
RewriteRule ^/brand/(.*)/$ /search.php?q=brand:$1:&rewrite=1%{QUERY_STRING} [L]
RewriteRule ^/brand/(.*)/(.*).html$ /search.php?q=brand:$1:&page=$2&rewrite=1%{QUERY_STRING} [L]

When using external.php inside WP (which works fine) it outputs ugly URLS. Can someone see what is wrong?
I do want pretty urls for SEO purposes...

Submitted by Al on Sat, 2011-01-29 21:04

Regarding the .htaccess:

I found out the when browsing : http://www.mywordpress-site.com/shopping/
the mod rewrite works fine.

However inside WordPress (http://www.mywordpress-site.com), using external.php the URLs are 'ugly'.

Submitted by support on Sun, 2011-01-30 08:57

Hello Al,

Unfortunately the external scripts are not ideal for where clean URLs are a priority - there is no control over the URL i'm afraid, and would strongly recommend looking at creating a dedicated Price Tapestry site, and blending the look and feel to merge seamlessly with your Wordpress site.

I recently posted instructions for taking any .html page and converting it into an equivalent html/header.php and html/footer.php for use with Price Tapestry - more details on the following page...

http://www.pricetapestry.com/node/3619

Cheers,
David.
--
PriceTapestry.com

Submitted by koen on Tue, 2011-03-22 21:38

Hello,

Im also trying to get the sidebar filters work in Wordpress. I'm using the files from sidebarfilters.zip and searchexternal.php.

Only question i have is what code to implement in the sidebar (widget) area. I'm able to display all brands etc. using a modified version of brands.php (and calling it from a text-widget), but I can't get the filter working.

Do you have any tips/code for me to try?

Thanks,
Koen

Submitted by support on Wed, 2011-03-23 09:18

Hi Koen,

The download verison of html/searchresults.php contains a check to see that it is running within search.php (to avoid the filters being displayed when the same HTML module is being used to display related products), so this needs to be changed when using this version via an external script. In the sidebar filters version of html/searchresults.php look for this code around line 13:

if (strpos($_SERVER["PHP_SELF"],"search.php"))

...and REPLACE with:

if (!isset($mainProduct))

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by koen on Fri, 2011-04-22 10:04

Thanks, it works... but...

Is there a way to get the filters in a different "section" of the Wordpress template (e.g. the wordpress sidebar)? For example by putting the filter code in a seperate .php file which can be called from a different Wordpress widget?

Thanks,
Koen

Submitted by support on Fri, 2011-04-22 10:22

Hello Koen,

You could try that; it would be dependent on the location from where the filter code is included being generated after the search code has executed, otherwise the variables required by the filter code will not yet have been generated (although it's not impossible to pull that forward if necessary).

Start by extracting the filter PHP code from your html/searchresults.php file - it's the section from the IF statement described above, down to the closing brace of the IF construct (line 102).

Create a new file called "externalFilter.php" in the main Price Tapestry folder (not in /html/) and PASTE the code extracted from html/searchresults.php into, enclosed by PHP tags. A change will also be required to the IF statement, so all in all you should end up with:

<?php
if (!isset($mainProduct) && isset($searchresults))
{
....
rest of filter code here....
}
?>

Finally, add the following "calling code" where required...

<?php
  $external_path 
"/path/to/pricetapestry/";
  require(
$external_path."externalFilter.php");
?>

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by koen on Sun, 2011-05-01 21:09

Hello David,

I fear it's time to call your help on this one again... I've put the filter code in a filterExternal.php and inserted the IF statement you've given me above. Unfortunately the result is an nothing but an empty textbox...
I've added an else statement in the filterExternal.php:

else {
echo "The if statement evaluated to false";
}?>

This shows me the given "if statement" returns a FALSE.
Next thing I've done is testing the parts of the if statement by removing one part of it and hope to get some results.... Both partial "returns" gave me the following errors:

{code saved}

Errors appeared a few times, the textboxes for the low/high prices were showed.

Can you please help me on this?
Thanks!

Koen

Submitted by support on Sun, 2011-05-01 21:27

Hi Koen,

That sounds like it could be a database contention issue. This can happen with the external scripts if Price Tapestry is configured to be using a different database connection (any combination of server, username and password) as an external site which is assuming a persistent database connection.

To check if this is the case, you can ensure that Price Tapestry uses a new database connection by modifying includes/database.php in your Price Tapestry installation. Look for the following code at line 14:

    $link = @mysql_connect($config_databaseServer,$config_databaseUsername,$config_databasePassword);

...and REPLACE with:

    $link = @mysql_connect($config_databaseServer,$config_databaseUsername,$config_databasePassword,TRUE);

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by koen on Sun, 2011-05-01 22:47

Hi David,

Thanks for your quick reply. Unfortunately, this doesn't help... Are there more (possible) solutions?

Regards,
Koen

Submitted by support on Mon, 2011-05-02 05:48

Hi Koen,

Yes - it may be a variable scope issue.

To check this, add the following code immediately prior to the require statement in each block of calling code (main block and the filter block):

 global $mainProduct;
 global $searchresults;

This will ensure that both variables are in global scope at each point...

Cheers,
David.
--
PriceTapestry.com

Submitted by koen on Mon, 2011-05-02 08:32

Thanks,

I've been putting the code both in the calling codes as well in the scripts (searchExternal, externalFilters). No results, still the "False" result.
The calling code I use:

<?php
  $common_baseHREF 
"http://test.xxxyyyy.nl/vergelijk/";
  
$common_path "/home/w1234567/domains/xxxyyyy.nl/public_html/test/vergelijk/";
  
$_GET["q"] = "category:irons";
  global 
$mainProduct;
  global 
$searchresults;
require(
$common_path."searchExternal.php");
?>

and for the ExternalFilter:
<?php
$external_path 
"/home/w1234567/domains/xxxyyyy.nl/public_html/test/vergelijk/";
global 
$mainProduct;
global 
$searchresults;
require(
$external_path."filterExternal.php");
?>

Any other ideas? ;-)

Submitted by support on Mon, 2011-05-02 09:07

Hi koen,

Can you confirm that the page is showing the search results - just no filters?

Cheers,
David.
--
PriceTapestry.com

Submitted by koen on Mon, 2011-05-02 10:58

Yes, it shows me the correct output.

Please have a look at:
{link saved}

I've also discovered some strange things by browsing to the PT folder (it opens very nice in the WP template, required some minor changes). When I use the "classic" search (search.php) for the same category, it returns all the items in the category, but the header states "no results" (although I got the whole list...).
In this case the external filter returns the MySQL error messages 27. Please have a look at:
{link saved}

Hope you can find something, I'm geting quite desperate.. :-$

Cheers,
Koen

Submitted by support on Mon, 2011-05-02 11:16

Hi Koen,

I think the sidebar code may actually be being evaluated before the main content area, so the $searchresults variable won't yet have been set by the main calling code.

Could you test this by including both sets of calling code together in the same post - I think that will display the filters and indicate that the problem is the order of evaluation - in which case we can have a think about how to handle that...

Regarding the MySQL errors on the native search page, that looks like SELECT FOUND_ROWS() is returning zero on your MySQL configuration. If you could email me your search.php from that site, and also the page containing the sidebar filters (presumably html/searchresults.php but whichever file the code is contained in if not) and I'll take a look...

Cheers,
David.
--
PriceTapestry.com