You are here:  » Use Pricetapestry like a Wordpress plug-in except meta tags...

Support Forum



Use Pricetapestry like a Wordpress plug-in except meta tags...

Submitted by kempo on Tue, 2010-08-17 12:58 in

Hi David,
I have applied the following things to combine wordpress and pricetapestry and now it works very well. But I have just a problem which I could not solve. Let me explain what I did ( I am using revision 11/09A ) :
1. I have made a search and replace for translate function in whole pricetapestry folder for all pricetapestry files. I replaced all the instances of translate word with pttranslate and also renamed translate.php to pttranslate.php because there is a conflict between wordpress and pricetapestry.
2. I have installed the replaced code of pricetapestry in the root of my website.
2. I have installed wordpress in wp directory under root.
3. I have modified the /html/header.php as follows:

<?php
$root 
$_SERVER['DOCUMENT_ROOT'];
require( 
$root'/wp/wp-load.php' );
get_header(); 
?>

4. I have modified the/html/footer.php as follows:
<?php
 get_sidebar
(); get_footer(); 
?>

5. I have commented out unnecessary files like /html/searchform.php, /html/menu.php from the required files because I want to use wordpress search box and menus.
6. I have modified the /wordpress_template_path/searchform.php by changing action="/search.php" and also changed the name="s" to name="q" in order to use pricetapestry search function.
7. I have modified the necessary files by puuting or removing necessary tags in order to make the site looks like as wordpress site.
After above modifications my site is now working like a wordpress site which installed pricetapestry plug-in. You can check it at the following: {link saved}
At that time I have only a small problem with meta tags of the pricetapestry generated pages. I could not find a way to bring the pricetapesrty meta tags to the pages. So all my product pages etc. have no any metatags, title description etc. I have modified the /wordpress_template_path/header.php in order to solve this problem as the following:

<?php
$uri = $_SERVER['REQUEST_URI'];
if ($uri == "/wp/") { ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
<meta name="description" content="<?php bloginfo('description'?>" />
<title><?php wp_title(''); ?><?php if(wp_title(''false)) { echo ' :'; } ?> <?php bloginfo('name'); ?></title>
<meta name="generator" content="WordPress <?php bloginfo('version'); ?>" />
<?php } else { ?>
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
<head>
<link media='all' href='<?php print $config_baseHREF?>default.css' type='text/css' rel='stylesheet' />
<title><?php print (isset($header["title"])?$header["title"]:$config_title); ?></title>
<?php if (isset($header["meta"])): foreach($header["meta"] as $name => $content): ?>
<meta name='<?php print $name?>' content='<?php print $content?>' />
<?php endforeach; endif; ?>
<?php ?>

But it does not work. I could not succeeded to print any meta tags. Could you please help me solve the problem. If I solve it I will publish a tutorial for step by step integration any wordpress theme to pricetapestry.
Cheers,

Submitted by support on Tue, 2010-08-17 13:04

Hi kempo,

It looks like the $header variable is out of scope; try adding the following to the top of /wordpress_template_path/header.php:

<?php
  
global $header;
?>

..but you may also need to declare as global within products.php - just add the same code right at the very top...

Hope this helps!

Cheers,
David.
--

PriceTapestry.com

Submitted by kempo on Tue, 2010-08-17 13:26

Thank you very much David,
You have solved my problem. Noe I have a wordpress site with pricetapestry plug-in. -:)
P.S.: Needed to put the code to products.php too.
Cheers,
kempo.

Submitted by tisbris on Sat, 2010-12-25 21:04

Hi kempo or David

I'm trying to make a wordpress/pt site and i'm almost there, but i have trouble making the translation work.

I have wordpress installed in root and pt installed in sub \pt.

I have translated every word 'translate' to 'pt_translate' including filename translate.php to pt_translate.php.

In the troubleshooting i have forced an error and seen that pt is looking for the correct pt_translate.php but still no words is translated inside wordpress. All word is translated correctly in the normal pt installation.

Any idea why the words in wordpress isn't translated?

//Brian

Submitted by support on Tue, 2010-12-28 12:58

Hi Brian,

The call in include() includes/translate.php is conditional upon the function not existing - so check that in your external.php, look for the following code at line 101:

    if (!function_exists("translate")) require_once($external_path."includes/translate.php");

...and REPLACE that with:

    require_once($external_path."includes/pt_translate.php");

That should be all it is...

Cheers,
David.
--
PriceTapestry.com

Submitted by tisbris on Tue, 2010-12-28 19:18

Hi David

Thx for your help... I've already tried this, but this doesn't make any change - still no word is translated.

I just tried to change your code line to 'pttranslate.php' to see if it is called and it is called, because this generate this forced error:

Warning: require_once(/home/www/mydomain.com/pt_new/includes/pttranslate.php) [function.require-once]: failed to open stream: No such file or directory in /home/www/mydomain.com/pt_new/externalSidebar_new.php on line 119

Fatal error: require_once() [function.require]: Failed opening required '/home/www/mydomain.com/pt_new/includes/pttranslate.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/www/mydomain.com/pt_new/externalSidebar_new.php on line 119

sample of my pt_translate.php:

<?php
  
// add custom translations here, for example to pt_translate "Example" (English) into "Beispiel" (German):
  
$pt_translate["Best Price"] = "Bedste pris";
  
$pt_translate["Submit"] = "Godkend";
  
$pt_translate["This reviewer did not leave any comments"] = "Denne anmelder efterlod ingen kommentarer";
  
$pt_translate["to"] = "til";
  
$pt_translate["Visit Store"] = "...mere";
  
$pt_translate["Your Comments (optional)"] = "Dine kommentarer (option)";
  function 
pt_translate($text)
  {
    global 
$pt_translate;
    return (isset(
$pt_translate[$text])?$pt_translate[$text]:$text);
  }
?>

hope this help a little :o)

//Brian

Submitted by support on Tue, 2010-12-28 19:23

Hi Brian,

You mentioned you changed it to pttranslate.php but the error is a
file not found ("could not open" in PHP), so if you actually
changed the name of the file, modify the following line..

    require_once($external_path."includes/pt_translate.php");

...to the actual name (instead of pt_translate.php), however if you
didn't change the filename at all, leaving it as translate.php is
fine, it won't cause any PHP errors...

Cheers,
David.
--
PriceTapestry.com

Submitted by tisbris on Tue, 2010-12-28 19:47

Hi David

I have translated every word and filename from translate to pt_translate.

The error above was only a test to see if it was 'looking' for a translation file and because i changed the your codeline to a 'wrong' filename, then the error was 'file not found'.

my translation file is named pt_translate.php

and like i mentioned earlier, the normal pt installation is translated correctly with all the new words - pt_translate.

But no words is translated inside wordpress?

//Brian

Submitted by support on Tue, 2010-12-28 19:52

Hi Brian,

Ah - I think the $pt_translate (as you have renamed it) array needs to be globaled in. At the top of your includes/translate.php (or current file name of course if you have changed it), add

  global $pt_translate;

...just after the opening PHP tag, and I think that will do it...

Cheers,
David.
--
PriceTapestry.com

Submitted by tisbris on Tue, 2010-12-28 20:04

Hi David

Perfect, that did the trick...

Thank you very much :o)

//Brian

PS. Your site is missing a 'Donation' or 'Buy me a beer' button - how do I buy your a beer for all your support - paypal account?

Submitted by support on Tue, 2010-12-28 20:08

No probs - all part of the service!

Cheers,
David.
--
PriceTapestry.com

Submitted by Aslex on Sat, 2011-01-15 21:15

Hello Support,

I have a problem with this ... I included this in die header.php of the wordpress-theme:

<?php
$uri 
$_SERVER['REQUEST_URI'];
if(
strpos($uri'/handydeals/') !== false) { global $header
?>

<?php
 
print (isset($header["title"])?$header["title"]:$config_title); 
?>

<?php
 
if (isset($header["meta"])): foreach($header["meta"] as $name => $content): 
?>

<?php
 
endforeach; endif; }
?>

the products have metatags, but the main-site (of the pricetapestry-script) and sites like merchants.php have no metatags...

I hope you have a solution...

Submitted by support on Sat, 2011-01-15 21:58

Hi Aslex,

A Price Tapestry home page and the indexes (merchant, category and brand) don't set either keywords or description meta tags by default, but this is easy to add. In each file, look for where the default header is included:

  require("html/header.php");

...and immediate BEFORE that point, add the following lines as required:

  $header["meta"]["keywords"] = "Keyword1,Keyword2,Keyword3,etc.";
  $header["meta"]["description"] = "Page description here...";

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by Aslex on Sat, 2011-01-15 22:34

Hi David,

Problem solved!

Thank you - Cheers, Alex