You are here:  » Meta tag categories hierarchy custom descriptions and logo in results and product


Meta tag categories hierarchy custom descriptions and logo in results and product

Submitted by smartprice24 on Wed, 2017-10-04 00:14 in

Hi David.

I have few problem with PT!

In order https://www.pricetapestry.com/node/3237#comment-24637

1) I followed the process to enter the description into categories and brands.

Works well for the brands

However, in the hierarchy categories, the description meta tag does not appear and the title shown is the one generated by the code

$ header ["title"] = translate ("Category"). "A-Z";

(both in the main category and in the subcategories).

Following the procedure for creating new fields on hierarchy categories and brands

es.

$ description = trim ($ _ POST ["description"]);
    $ sql = "UPDATE` ". $ config_databaseTablePrefix." categories_hierarchy` SET alternates = '' .database_safe ($ alternates). '', description = '' database_safe ($ description). '' WHERE id = '" $ id). " '";
$ description = trim ($ _ POST ["meta_title"]);
    $ sql = "UPDATE` ". $ config_databaseTablePrefix." categories_hierarchy` SET alternates = '' .database_safe ($ alternates). '', description = '' database_safe ($ meta_title). '' WHERE id = '" $ id). " '";
$ description = trim ($ _ POST ["description"]);
    $ sql = "UPDATE` ". $ config_databaseTablePrefix." categories_hierarchy` SET alternates = '' .database_safe ($ alternates). '', description = '' database_safe ($ description). '' WHERE id = '" $ id). " '";
etc

widget_textArea ( "Description", "description", FALSE, $ category [ "description"], 100,12);
widget_textArea ( "Description", "meta_title", FALSE, $ category [ "meta_title"], 100,12);
widget_textArea ( "Description", "meta_description", FALSE, $ category [ "meta_description"], 100,12);
etc

etc, saves only one field and does not allow the change of other fields.

Ultimately, I would like to be able to create the meta, title, description and keywords that I can get from the mapping of the categories.

Same thing for brands and stores.

2) How I can implement the shopkeeper's logo in the search results and on the product page with a link referring to all the merchant's products.

Use pt 16 / 10A

Submitted by support on Wed, 2017-10-04 08:55

Hi,

If fields are not being saved it is most likely a database error occurring. Database debug mode can be used to check this but before enabling, edit includes/database.php and look for the following code at line 56:

      print "[".$sql."][".mysqli_error($link)."]";

...and REPLACE with:

      print "[".$sql."][".mysqli_error($link)."]";exit();

(that will enable you to see a database error that occurs when submitting a form if output buffering is enabled and the page redirects without a change to capture the error)

Then enable debug by changing line 6 in config.advanced.php as follows;

  $config_databaseDebugMode = TRUE;

It may just be that the required dbmod.php script to add the fields has not yet been applied, for example;

<?php
  set_time_limit
(0);
  require(
"includes/common.php");
  
$sql "ALTER TABLE `".$config_databaseTablePrefix."categories_hierarchy` ADD `meta_title` text";
  
database_queryModify($sql,$result);
  
$sql "ALTER TABLE `".$config_databaseTablePrefix."categories_hierarchy` ADD `meta_description` text";
  
database_queryModify($sql,$result);
  print 
"Done.";
?>

With meta_title and meta_description in place on both brands and categories_hierarchy tables, to include in search.php look for the following code at line 505:

    $header["title"] = $q;

...and REPLACE with:

    switch($parts[0])
    {
      case "category":
        $sql = "SELECT * FROM `".$config_databaseTablePrefix."categories_hierarchy` WHERE id='".$nodeInfo["id"]."'";
        if (database_querySelect($sql,$rows))
        {
          $header["title"] = $rows[0]["meta_title"];
          $header["meta"]["description"] = $rows[0]["meta_description"];
        }
        break;
      case "brand":
        $sql = "SELECT * FROM `".$config_databaseTablePrefix."brands` WHERE name='".database_safe($parts[1])."'";
        if (database_querySelect($sql,$rows))
        {
          $header["title"] = $rows[0]["meta_title"];
          $header["meta"]["description"] = $rows[0]["meta_description"];
        }
      default:
        $header["title"] = $q;
        break;
    }

The title element will be postfixed with page (when greater than 1) and sort (when not default) to avoid any duplicate title issues, if you would prefer your meta descriptions to show for page 1 only, replace each instance in the above of;

          $header["meta"]["description"] = $rows[0]["meta_title"];

with:

          if ($page==1)
          {
            $header["meta"]["description"] = $rows[0]["meta_title"];
          }

If you're still not sure or debug mode doesn't reveal anything or you're not sure how to extend for other meta tags, if you would like to email me your modified files I'll check it out further with you...

Regarding merchant logos in search results, bear in mind that search results are generated using a summary query so logos should only be displayed if numMerchants is 1, so to include this, edit html/searchresults.php and at the position required within the loop use:

<?php
  
if (($product["numMerchants"]==1) && (file_exists("logos/".$product["merchant"].$config_logoExtension)))
  {
    print 
"<a href='".tapestry_indexHREF("merchant",$product["merchant"])."'><img src='".$config_baseHREF."logos/".str_replace(" ","%20",$product["merchant"]).$config_logoExtension."' /></a>";
  }
?>

And similarly for product page in html/product.php for single merchant products;

<?php
  
if ((count($product["products"])==1) && (file_exists("logos/".$product_main["merchant"].$config_logoExtension)))
  {
    print 
"<a href='".tapestry_indexHREF("merchant",$product_main["merchant"])."'><img src='".$config_baseHREF."logos/".str_replace(" ","%20",$product_main["merchant"]).$config_logoExtension."' /></a>";
  }
?>

Hope this helps!

Cheers,
David.
--
PriceTapestry.com