You are here:  » Category and Brand infopages

Support Forum



Category and Brand infopages

Submitted by esogut on Thu, 2010-01-21 22:03 in

Hi David,

I like to add information text for the categories and brands. we have over 80 categories so it wasnt a option for me to hardcode the text do you have a nice solution for this
thnx

Submitted by support on Fri, 2010-01-22 09:00

Hello,

One option would be to create folders, let's say:

info_category/
info_brand/

...and then in those folders, upload .html files with your additional category and brand information; using the filenames like:

info_category/CategoryName.html
info_brand/BrandName.html

Then, wherever a category / brand is in context and you wish to display the extra content you can check for the file and display the content. For example, to display the extra category information at the top of the search results for that category; look for the following code towards the end of search.php:

if (isset($searchresults))

...and then INSERT something like this immediately BEFORE that code:

if ($parts[0] == "category")
{
  $filename = "category_info/".$parts[1].".html";
  if (file_exists($filename))
  {
    require($filename);
  }
}

If you're not sure of the equivalent code for brands, or how to access the category and/or brand in context at any point just let me know...

Hope this helps!

Cheers,
David.

Submitted by esogut on Fri, 2010-01-22 09:31

Hi David isnt there a option to this through the database. i want to make also a edit page to make it easy so that other people also good work on it. and doesnt need to understand html.

Submitted by support on Fri, 2010-01-22 09:47

Hi,

A database solution can be developed, bear with me and I'll look into it for you. Do you have/use phpMyAdmin for database administration?

Cheers,
David.

Submitted by esogut on Fri, 2010-01-22 14:47

yep...

Submitted by support on Fri, 2010-01-22 15:03

Hi,

That's great - setting up will be easier. There's quite a bit involved in creating a whole new admin section to manage your custom category / brand pages so please bear with me and I'll post some code for you to do this...

Cheers,
David.

Submitted by esogut on Fri, 2010-01-22 16:05

Thnx David

Submitted by support on Mon, 2010-01-25 15:10

Hi,

I've just put together a couple of category and brand info scripts, based on the category mapping scripts. Rather than post the code, i've uploaded the files here.

Unzip, and upload the files to your /admin/ folder.

Then, once only, browse to /admin/dbmod.php

To add links to the new tools to your admin menu, look for the following code on line 30 of includes/admin_menu.php:

  print "</small>";

...and REPLACE with:

  print "<a href='category_info.php'>Category Info</a>&nbsp;&nbsp;";
  print "<a href='brand_info.php'>Brand Info</a>&nbsp;&nbsp;";
  print "</small>";

Just like category mapping; you will be able to add new category / brand info pages, and click "Edit" to manage the content. To use; anywhere that a category is in context; such as the above example regarding search results; code similar to the following can be used:

if ($parts[0] == "category")
{
  $sql = "SELECT info FROM `".$config_databaseTablePrefix."category_info`
           WHERE name = '".database_safe($parts[1])."'";
  if (database_querySelect($sql,$rows))
  {
    print "<p>".$rows[0]["info"]."</p>";
  }
}

As before, if you're not sure where / what variable names to use to capture the category or brand in context, just let me know where you'd like to display the info and i'll show you what code to use...

Hope this helps!

Cheers,
David.

Submitted by scorpionwsm on Wed, 2010-02-17 10:27

Hi
Is there an easy way to add this as a meta description in search.php?

Thanks

Submitted by support on Wed, 2010-02-17 13:52

Hi,

Sure - look for where the title is set in search.php, around about line 50:

    $header["title"] = htmlentities($q,ENT_QUOTES,$config_charset);

...and at that point, you could add similar to the following:

    if ($parts[0]=="category")
    {
      $header["meta"]["description"] = "Category search results for ".$parts[1];
    }

Hope this helps!

Cheers,
David.

Submitted by scorpionwsm on Wed, 2010-02-17 15:38

Cheers David that works perfectly,

Instead of having just the Category name would it be possible to include the text from the info field instead?

Thanks in advance.

Submitted by support on Wed, 2010-02-17 15:43

Hi,

Sure - the code would be along the lines of:

    if ($parts[0]=="category")
    {
       $sql = "SELECT info FROM `".$config_databaseTablePrefix."category_info`
           WHERE name = '".database_safe($parts[1])."'";
       if (database_querySelect($sql,$rows))
       {
         $header["meta"]["description"] = $rows[0]["info"];
       }
       else
       {
         $header["meta"]["description"] = "Category search results for ".$parts[1];
       }
    }

Cheers,
David.

Submitted by scorpionwsm on Wed, 2010-02-17 16:34

Sorry to be a pain David but when I use that code the Description displays perfectly but there are no products displayed on any of the category pages as can be seen on my test server {link saved} .

It also displays quite a few Undefined index: errors on my localhost.

I have uploaded a copy of my search.php for you at {link saved}

Thanks again

Submitted by support on Wed, 2010-02-17 16:43

Hi,

Sorry about that - the code is overwriting the $sql variable that is already in scope - to fix this, in each of your sections to set meta tags, instead of $sql use $sql2, for example:

    if ($parts[0]=="category")
    {
       $sql2 = "SELECT info FROM `".$config_databaseTablePrefix."category_info`
           WHERE name = '".database_safe($parts[1])."'";
       if (database_querySelect($sql2,$rows))
       {
         $header["meta"]["description"] = $rows[0]["info"];
       }
       else
       {
         $header["meta"]["description"] = "Category search results for ".$parts[1];
       }
    }

That should be all it is...

Cheers,
David.

Submitted by scorpionwsm on Wed, 2010-02-17 16:46

Brilliant David that works perfectly now.

Thanks

Submitted by kiddaclo on Mon, 2010-04-12 10:14

Hi David,

Thanks for this mod it's just what I needed!

I'm using this mod for my brand pages would there be any way to only show the brand description on the first page of results? So when you use the pagination it's no longer there?

Cheers,
Chris.

Submitted by support on Mon, 2010-04-12 10:19

Hi Chris,

Sure - for brand info text I assume that you're using

    if ($parts[0]=="brand")

...so you can simply replace that with:

    if (($parts[0]=="brand") && ($page==1))

Cheers,
David.

Submitted by kiddaclo on Mon, 2010-04-12 19:06

David that's perfect!

Cheers,
Chris.

Submitted by cascadeclimbers on Tue, 2010-06-15 23:21

Hi David,

I might have this questions answered by the time you get to this, but can the above easily be modified to work for the merchant pages as well? My guess is yes. Also, I'm assuming you can enter html into the info pages fields without problems.

Cheers, Jon
$> cd /pub
$> more beer

Submitted by cascadeclimbers on Wed, 2010-06-16 03:19

Just wanted to follow up and say that I got the merchant code working no problem.

$> cd /pub
$> more beer

Submitted by tonypearce on Tue, 2012-02-28 14:25

Hi,

Would this work for the newest version, looks good.

Cheers
Tony

Submitted by support on Tue, 2012-02-28 14:38

Hi Tony,

Sure - all the above still relevant!

Cheers,
David.
--
PriceTapestry.com

Submitted by bat on Sat, 2012-09-22 18:35

Hi David
I've got this working for my brands and categories using the info_brand and info_category folders in my PT installation, with the descriptions, etc in the html files.

However, I also have my search.php file modified so that it comes up with a generic title and description and just uses the brand/category name within.

I still want to enable the search.php meta, but if I have made a .html page in the info_brand and info_category folder for that particular brand/category, I wish that to overwrite what the search.php dictates.

I noticed you wrote some code a few posts above but that was dependent on a DB mod. I think I need the same thing but for my folders mod, if that's possible please?

Submitted by support on Mon, 2012-09-24 08:39

Hi,

Sure you can do that from files rather than db. If the current text file per category or brand is a description; and you want to use that as the meta description rather than your generic version; let's say you have the following existing code:

  $header["meta"]["description"] = "Search results for ".htmlentities($q);

(or similar)

Then replace with something like this;

  if (($parts[0]=="category") || ($parts[0]=="brand"))
  {
    $filename = $parts[0]."_info/".$parts[1].".html";
    if (file_exists($filename))
    {
      $header["meta"]["description"] = file_get_contents($filename);
    }
  }
  if (!isset($header["meta"]["description"]))
  {
    $header["meta"]["description"] = "Search results for ".htmlentities($q);
  }

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by bat on Mon, 2012-09-24 09:07

Thanks David, that's top banana!

Submitted by bat on Thu, 2013-03-21 19:39

Hi David
The below code doesn't seem to be showing Page X at the end of the meta description if it's using the category_desc/xxx.html description. It's also showing up in red in the Page Source code in Mozilla. Any help please as to where I've gone wrong?

  if (($parts[0]=="category"))
  {
    $filename = $parts[0]."_title/".$parts[1].".html";
    if (file_exists($filename))
    {
      $header["title"] = file_get_contents($filename);
    }
  }
  if (!isset($header["title"]))
  {
$header["title"] = "Search results for ".$parts[1];
}
if ($parts[0]=="category")
    {
$filename = $parts[0]."_desc/".$parts[1].".html";
    if (file_exists($filename))
    {
      $header["meta"]["description"] = file_get_contents($filename);
    }
  }
  if (!isset($header["meta"]["description"]))
  {
      $header["meta"]["description"] = "Find the best price for " .$parts[1] .". Only on XXX.com";
if ($page > 1)
  {
    $header["meta"]["description"] .= " Page ".$page;
  }
   }

Submitted by support on Thu, 2013-03-21 21:21

Hi bat,

Regarding "Page n" not being appended, I think it's just the code for that is slightly out of place, since it is within the final "if no description" IF statement - have a go with:

if (($parts[0]=="category"))
{
  $filename = $parts[0]."_title/".$parts[1].".html";
  if (file_exists($filename))
  {
    $header["title"] = file_get_contents($filename);
  }
}
if (!isset($header["title"]))
{
  $header["title"] = "Search results for ".$parts[1];
}
if ($parts[0]=="category")
{
  $filename = $parts[0]."_desc/".$parts[1].".html";
  if (file_exists($filename))
  {
    $header["meta"]["description"] = file_get_contents($filename);
  }
}
if (!isset($header["meta"]["description"]))
{
  $header["meta"]["description"] = "Find the best price for " .$parts[1] .". Only on XXX.com";
}
if ($page > 1)
{
  $header["meta"]["description"] .= " Page ".$page;
}

Regarding markup validation, I can't see anything obviously wrong in the code, so have a check in the included description files themselves. Remember that meta tag content shouldn't include HTML markup at all. If you're not sure, if you'd like to post a page that is showing a validation error (red text in FireFox View > Source) - i'll remove the link before publishing your reply - I'll check it out for you...

Cheers,
David.
--
PriceTapestry.com

Submitted by bat on Thu, 2013-03-21 22:15

Super David, it works a treat. Thank you very much.
As for the red text, I realised it was because I'd use apostrophes in my description files. So I've avoided using them and the red text no longer appears.

Submitted by support on Thu, 2013-03-21 22:54

No probs! - Whilst HTML itself is out of place in meta tags, if you want to safely include apostrophes in order to ensure grammatical correctness (never a bad thing in these days of site quality consideration by search engines), then where you have this line:

  $header["meta"]["description"] = file_get_contents($filename);

...REPLACE with:

  $header["meta"]["description"] = htmlspecialchars(file_get_contents($filename));

...and normal punctuation can then be included as required...

Cheers,
David.
--
PriceTapestry.com

Submitted by bat on Sat, 2013-03-23 10:43

Thanks David. I've changed it to that. You're right. Always better to have that included than not. :)

Submitted by macland on Wed, 2016-09-14 08:53

Does this still work in the latest version?

I can't find the admin_menu.php anywhere?

Thank you in advance

Submitted by support on Wed, 2016-09-14 09:38

Hello macland and welcome to the forum!

The scripts are from a much earlier distribution, and brand mapping is now incorporated into the script so this can be implemented as a straight forward modification - I will prepare the changes on my test server and follow up with a modification description in this thread...

Cheers,
David.
--
PriceTapestry.com

Submitted by support on Wed, 2016-09-14 11:17

Hi macland,

Here are modification instructions for a simple content management system for display of custom description / info above page 1 of search results, integrated with the Brand / Category / Category Hierarchy Mapping functionality.

Firstly, create and apply the following dbmod.php script which will add a new `description` field to the mapping tables in the database;

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

Edit admin/brands_configure.php and look for the following code at line 56:

    $sql = "UPDATE `".$config_databaseTablePrefix."brands` SET alternates = '".database_safe($alternates)."', description='".database_safe($description)."' WHERE id='".database_safe($id)."'";

...and REPLACE with:

    $description = trim($_POST["description"]);
    $sql = "UPDATE `".$config_databaseTablePrefix."brands` SET alternates = '".database_safe($alternates)."', description='".database_safe($description)."' WHERE id='".database_safe($id)."'";

And then the following code at line 79:

  widget_textArea("Alternatives","alternates",FALSE,$brand["alternates"],200,12);

...and REPLACE with:

  widget_textArea("Alternatives","alternates",FALSE,$brand["alternates"],200,12);
  widget_textArea("Description","description",FALSE,$brand["description"],200,12);

Edit admin/categories_configure.php and look for the following code at line 56:

    $sql = "UPDATE `".$config_databaseTablePrefix."categories` SET alternates = '".database_safe($alternates)."', description='".database_safe($description)."' WHERE id='".database_safe($id)."'";

...and REPLACE with:

    $description = trim($_POST["description"]);
    $sql = "UPDATE `".$config_databaseTablePrefix."categories` SET alternates = '".database_safe($alternates)."', description='".database_safe($description)."' WHERE id='".database_safe($id)."'";

And then the following code at line 79:

  widget_textArea("Alternatives","alternates",FALSE,$category["alternates"],200,12);

...and REPLACE with:

  widget_textArea("Alternatives","alternates",FALSE,$category["alternates"],200,12);
  widget_textArea("Description","description",FALSE,$category["description"],200,12);

Edit admin/categories_hierarchy_configure.php and look for the following code at line 68:

    $sql = "UPDATE `".$config_databaseTablePrefix."categories_hierarchy` SET alternates = '".database_safe($alternates)."', description='".database_safe($description)."' WHERE id='".database_safe($id)."'";

...and REPLACE with:

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

And then the following code at line 91:

  widget_textArea("Alternatives","alternates",FALSE,$category["alternates"],200,12);

...and REPLACE with:

  widget_textArea("Alternatives","alternates",FALSE,$category["alternates"],200,12);
  widget_textArea("Description","description",FALSE,$category["description"],200,12);

And finally, add the following new code to the top of html/searchresults.php:

<?php
  
if ($page == 1)
  {
    
$sql "";
    switch(
$parts[0])
    {
      case 
"brand":
        
$sql "SELECT description FROM `".$config_databaseTablePrefix."brands` WHERE name='".database_safe($parts[1])."' AND description <> ''";
        break;
      case 
"category":
        if (
$config_useCategoryHierarchy)
        {
          
$sql "SELECT description FROM `".$config_databaseTablePrefix."categories_hierarchy` WHERE id='".database_safe($nodeInfo["id"])."' AND description <> ''";
        }
        else
        {
          
$sql "SELECT description FROM `".$config_databaseTablePrefix."categories` WHERE name='".database_safe($parts[1])."' AND description <> ''";
        }
        break;
    }
    if (
$sql && database_querySelect($sql,$rows))
    {
      print 
"<div class='row'><div class='small-12 columns'><p>".$rows[0]["description"]."</p></div></div>";
    }
  }
?>

Descriptions can be added for Brands / Categories without necessarily needing to use the Alternatives functionality of Brand / Category Mapping - simply create a new Brand or Category Mapping entry using the brand or category name exactly as it currently appears in the database and the description will be picked up. For Category Hierarchy Mapping, if using Reverse Mapping, having completed the process, click Configure alongside the sub-category that you wish to enter a description for and edit as required.

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by macland on Fri, 2016-09-23 11:05

It works perfectly, thank you.

Only this is that descriptions are not show for product hierarchy if the category has sub-categories.
I think it would be great if my categories could have something like this

* List of subcategories
* Description of the category
* Products mapped to the category, if 0 products mapped then show products of subcategories

But I don't know if that is to difficult.
For the last part I tried to insert the code found in http://www.pricetapestry.com/node/6001 but it's still not showing any products

Submitted by support on Fri, 2016-09-23 11:42

Hi,

I just wanted to check, ordinarily, the search results page would only be reached from a leaf node of the category hierarchy (via the dynamically populating drop-down menu) so I wondered if you are referring to the /category/ page, which still works when using Category Hierarchy Mapping, e.g.

http://www.webpricecheck.co.uk/category/Domestic-Appliances/

This page by default shows the sub-categories of "Domestic Appliances", so would you like the description, and also search results for this level and below to be shown here?

Cheers,
David.
--
PriceTapestry.com

Submitted by macland on Fri, 2016-09-23 12:52

Yes exactly the one I'm talking about and yeah showing the sub-categories like in the example but instead of a blank page for the rest then having the description and then any products mapped into this category or if empty, then products mappen into the subcategory

Submitted by support on Fri, 2016-09-23 14:18

Hi,

This comes together quite nicely with the above modifications for category description already in place!

Firstly, you mentioned node/6001 which describes creating a searchcode.php file. For completeness, the steps to create this file are as follows:

1) Open search.php in your text editor

2) Use your text editor's Save As.. function to save the file as searchcode.php

3) Look for the following code at line 2:

  require_once("includes/common.php");

...and DELETE that line.

4) Locate the following code at (now) line 520:

  require("html/header.php");

...and DELETE that line and until the end of the file, leaving just closing PHP tag at the end:

?>

5) Save, and upload searchcode.php to the top level folder of your Price Tapestry installation.

With that in place, edit categories.php and look for the following code at line 101:

  if (isset($atoz)) require("html/atoz.php");

...and REPLACE with:

  if (isset($atoz)) require("html/atoz.php");
  $sql = "SELECT description FROM `".$config_databaseTablePrefix."categories_hierarchy` WHERE id='".$nodeInfo["id"]."' AND description <> ''";
  if (database_querySelect($sql,$rows))
  {
    print "<div class='row'><div class='small-12 columns'><p>".$rows[0]["description"]."</p></div></div>";
  }
  $_GET["q"] = "category:".$nodeInfo["path"];
  require("searchcode.php");
  if (isset($searchresults)) require("html/searchresults.php");

Cheers,
David.
--
PriceTapestry.com

Submitted by macland on Mon, 2016-09-26 11:59

And of cause it works like a charm :-) Thank you very much :-)

Submitted by Bakalinge on Tue, 2016-11-01 15:46

Hello David,

How are you doing, it's a while we haven't talked :)

Just need your help with this mod please. I went a little bit further with this mod, and added more variables for categories and brands :
- meta_title
- meta_description

Working perfectly in back-end, but I realised that I can't use $catagory[meta_title] in search.php (Notice : Undefined variable). Same problem with $category[meta_description] , $brand[meta_title] etc...

Can you explain how I can use this variables to get Meta Title and Description to show in categories and brand pages ?

Thank you !

Submitted by support on Tue, 2016-11-01 16:20

Hi,

Sure - in search.php look for where the title is set at line 503:

    $header["title"] = $q;

...and REPLACE with:

    switch($parts[0])
    {
      case "category":
        $sql = "SELECT meta_title,meta_description FROM `".$config_databaseTablePrefix."categories` WHERE name='".database_safe($parts[1])."'";
        if (database_querySelect($sql,$rows))
        {
          $header["title"] = $rows[0]["meta_title"];
          $header["meta"]["description"] = $rows[0]["meta_description"];
        }
        break;
      case "brand":
        $sql = "SELECT meta_title,meta_description 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"];
        }
        break;
      default:
        $header["title"] = $q;
        break;
    }

Code is already in place to append " | Page n" for $header["title"] for pages > 1 (to avoid duplicate title SEO issues) - if you wish to apply similar for meta/description, look for the following code beginning at line 539:

    if ($page > 1)
    {
      $header["title"] .= " | ".translate("Page")." ".$page;
    }

...and REPLACE with:

    if ($page > 1)
    {
      $header["title"] .= " | ".translate("Page")." ".$page;
      if (isset($header["meta"]["description"]))
      {
        $header["meta"]["description"] .= " | ".translate("Page")." ".$page;
      }
    }

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by Bakalinge on Tue, 2016-11-01 17:22

Thanks David,

I get the following error for categories :

{code saved}

As far as I understand this message, it misses a field "brand" in "brands" table and a "category" field in "categories" table, right ?

(PS : it's a fresh install of PT 15/09 A), I didn't update from previous version, I only imported manually categories and brands via sql)

Thanks

Submitted by support on Tue, 2016-11-01 18:12

Sorry about that...

WHERE field referenced in both cases should have been `name` not category/brand - corrected above...

Cheers,
David.
--
PriceTapestry.com

Submitted by Bakalinge on Tue, 2016-11-01 22:29

Thank you !

Submitted by ChrisNBC on Wed, 2016-12-07 14:31

Hi David,

I’d like to implement the above mod on an 14/06A install (which has backported Category Hierarchy functionality). Would I be correct in thinking I should implement the changes detailed in the post dated “Mon, 2010-01-25 15:10” not the later one. I can figure out the menu changes but is there anything else in the way of differences that I should be looking out for as I guess you wrote the mod for a pre 14/06A install?

Thanks in advance.

Best regards
Chris

Submitted by support on Wed, 2016-12-07 15:01

Hi Chris,

As your back-ported Category Hierarchy functionality will have the same categories_hierarchy table in place, use the changes related to Category (Hierarchy) Info from here and for Brand Info from the original post (as Brand Mapping is not present in 14/06A)...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by Retro135 on Mon, 2016-12-12 22:16

Have this all in place and 95% working. The only issues remaining:

1. Descriptions only appear on the category hierarchy level where there are products, but aren't being picked up on higher levels. Examples (last URL is where I have product page w/description):
{link saved}
Insertion code:

  {
    $sql = "";
    switch($parts[0])
    {
      case "merchant":
      $sql = "SELECT info FROM `".$config_databaseTablePrefix."merchant_info` WHERE name = '".database_safe($parts[1])."'";
      if (database_querySelect($sql,$rows))
      {
        print "<div class='row'><div class='mt15 small-12 columns'><p class='lead'>".$rows[0]["info"]."</p></div></div>";
      }
      break;
      case "brand":
        $sql = "SELECT brandinfo FROM `".$config_databaseTablePrefix."brands` WHERE name='".database_safe($parts[1])."' AND brandinfo<> ''";
    if ($sql && database_querySelect($sql,$rows))
    {
print "<div class='row'><div class='mt15 small-12 columns'><p class='lead'>".$rows[0]["brandinfo"]."</p></div></div>";
    }
      break;
      case "category":
        if ($config_useCategoryHierarchy)
        {
          $sql = "SELECT description FROM `".$config_databaseTablePrefix."categories_hierarchy` WHERE id='".database_safe($nodeInfo["id"])."' AND description <> ''";
        }
     }
    if ($sql && database_querySelect($sql,$rows))
    {
  print "<div class='row'><div class='mt15 small-12 columns'><p class='lead'>".$rows[0]["description"]."</p></div></div>";
    }
  }
    if ($sql && database_querySelect($sql,$rows))
    {
      print "<div class='row'><div class='small-12 columns'><p>".$rows[0]["description"]."</p></div></div>";

MySQL shows the text correctly stored for all category levels, I don't see any duplicate IDs. Where did I go wrong?
----------

2. In the first 2 URLs, the breadcrumbs and meta say "Category A-Z" and not the name of the category as the 3rd URL. How can this be fixed?

I tried the code below, but didn't work "...in search.php look for where the title is set at line 503":
$header["title"] = $q;

I have this instead:
$header["title"] = str_replace(array(":","merchant","category","brand","/"),array("","Merchant: ","Category: ","Brand: "," / "),$q);

Submitted by support on Tue, 2016-12-13 09:17

Hello Renee,

To include a description higher up the category code would need to be added to categories.php. To do this, look for the following code around line 101:

  if (isset($atoz)) require("html/atoz.php");

...and REPLACE with:

  $sql = "SELECT description FROM `".$config_databaseTablePrefix."categories_hierarchy` WHERE id='".database_safe($nodeInfo["id"])."' AND description <> ''";
  if (database_querySelect($sql,$rows))
  {
    print "<div class='row'><div class='mt15 small-12 columns'><p class='lead'>".$rows[0]["description"]."</p></div></div>";
  }
  if (isset($atoz)) require("html/atoz.php");

Regarding breadcrumbs, I had a look back at the last categories.php that I have from you by email and the $banner["breadcrumbs"] code all appears to be in place so I'm not sure why that is not displaying as expected - if you could email the latest version from your installation (after making the above mod) and also html/banner.php I'll check that out for you...

Cheers,
David.
--
PriceTapestry.com

Submitted by Retro135 on Tue, 2016-12-13 14:11

Works a charm, thank you so much David!

Submitted by bat on Mon, 2017-02-27 00:27

Hi David,
I applied the above mod for brands/categories/category hierachy for 15/09A which works a treat but I've noticed since applying it, the brand page and search results page seem to take a little while to load...
{link saved}

Could this have anything to do with the mod? (It's the only thing I've changed)
Also on my installation, my original code at line 56 was

$sql = "UPDATE `".$config_databaseTablePrefix."categories`
  SET alternates = '".database_safe($alternates)."'
  WHERE id='".database_safe($id)."'";

not

$sql = "UPDATE `".$config_databaseTablePrefix."categories`
  SET alternates = '".database_safe($alternates)."', description='".database_safe($description)."'
  WHERE id='".database_safe($id)."'";

Despite this, I replaced it with

$description = trim($_POST["description"]);
<code>
$sql = "UPDATE `".$config_databaseTablePrefix."categories`
  SET alternates = '".database_safe($alternates)."', description='".database_safe($description)."'
  WHERE id='".database_safe($id)."'";

Is that ok?

Submitted by support on Mon, 2017-02-27 08:28

Hi,

If the categories table is large it may be worth putting an index on the `name` column - run the following dbmod.php script in the top level folder of the Price Tapestry installation to apply the change:

<?php
  set_time_limit
(0);
  require(
"includes/common.php");
  
$config_databaseDebugMode TRUE;
  
$sql "CREATE INDEX name
            ON `"
.$config_databaseTablePrefix."categories` (name)";
  
database_queryModify($sql,$result);
  print 
"Done.";
?>

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by sirmanu on Tue, 2017-10-17 21:35

Hi David.
I found this (comment 24639) looking for an easy way to add my custom descriptions to voucher codes.
How can I apply this simple CMS for vouchers codes?
I mean, when you search for:

www.example.com/search.php?q=voucher:merchant:code appears my own description into the top.

Submitted by support on Wed, 2017-10-18 08:53

Hi,

Sure - to add similar for voucher:merchant:code first run the following dbmod.php script to add the new `info` column to the voucher codes table;

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

Edit admin/voucher_codes_edit.php and look for the following code at line 157:

                      valid_to = '%s'

...and REPLACE with:

                      valid_to = '%s',
                      info = '%s'

And then the following code at line 170:

                      database_safe($_POST["valid_to"])

...and REPLACE with:

                      database_safe($_POST["valid_to"]),
                      database_safe($_POST["info"])

And then the following code at line 426:

      widget_textArea("Info","info",FALSE,$_POST["info"],200,12);

...and REPLACE with:

      widget_textBox("Description (for discount type \"Other\")","discount_text",FALSE,(isset($_POST["discount_text"]) ? $_POST["discount_text"] : ""),"",12);
      widget_textArea("Info","info",FALSE,$_POST["info"],200,12);

This will add an "Info" text box to the voucher codes edit page where you can enter your custom text (note how this is a different purpose to the description field, which is specifically for a very short description of an offer that is not a monetary value discount).

Finally, to show above search results, add the following code to the top of html/searchresults.php:

<?php
  
if ($parts[0]=="voucher")
  {
    
$sql "SELECT info FROM `".$config_databaseTablePrefix."vouchers` WHERE merchant='".database_safe($parts[1])."' AND code='".database_safe($parts[2])."' AND info <> ''";
    if (
database_querySelect($sql,$rows))
    {
      print 
"<div class='row'><div class='small-12 columns'><p>".$rows[0]["info"]."</p></div></div>";
    }
  }
?>

Cheers,
David.
--
PriceTapestry.com

Submitted by IG on Tue, 2018-10-23 19:15

Hi David

Are the above files for download still relevant for the latest version?

Kind regards,
IG

Submitted by support on Thu, 2018-10-25 08:44

Hello IG,

They won't be but I can re-work them - just to confirm, did you want to use the admin method of adding custom text to appear above search results for categories and brands as opposed to creating .html files in info directories?

Are you using feed categories of Category Hierarchy Mapping?

Cheers,
David.
--
PriceTapestry.com

Submitted by IG on Thu, 2018-10-25 10:10

Hi David

Yes, I wanted to use the admin method as I believe it will make it easier in the long run to add and manage custom text to appear above search results for categories and brands. However, if you tell me otherwise, I am fine with creating .html files instead. Please advise.

I am currently not using feed categories of Category Hierarchy Mapping.

Kind regards,
IG

Submitted by support on Thu, 2018-10-25 11:27

Hello IG,

For the admin method - and integrating the description functionality with Brand / Category / Category Hierarchy mapping rather than creating whole new admin scripts - the modification in this comment above are all current for the latest distribution.

Note that in all cases, you can create a mapping just to use the description functionality - the alternatives etc. can be left empty if actual mapping is not required...

Cheers,
David.
--
PriceTapestry.com

Submitted by IG on Thu, 2018-10-25 14:25

Hi David,

Thanks for your advise. I will give it a try.

Is there also an elegant solution for additional merchant information?

Kind regards,
Ivo

Submitted by support on Fri, 2018-10-26 07:36

Hello Ivo,

Sure - as there shouldn't be any overlap between merchant and brand names, you can simply create Brand Mapping entries for merchant names with the required description, and then in the modification above where you have added;

      case "brand":

...REPLACE with:

      case "brand":
      case "merchant":

Cheers,
David.
--
PriceTapestry.com

Submitted by IG on Tue, 2018-11-06 10:53

Dear David

I followed your instructions above

For the admin method - and integrating the description functionality with Brand / Category / Category Hierarchy mapping rather than creating whole new admin scripts - the modification in this comment above are all current for the latest distribution.

and it works perfectly for categories and brands.

However, as I did not use

case "brand":

anywhere, I don't know where I need to add

case "merchant":

so, I can use the Brand Mapping for the merchant descriptions.

Kind regards,
IG

Submitted by support on Tue, 2018-11-06 11:06

Hello Ivo,

From the modifications described in this comment case "brand": should be towards the top of html/searchresults.php however if you're using something slightly different, if you could post the mods to that file that are working fine for brand description I'll advise how to modify for merchant also...

Cheers,
David.
--
PriceTapestry.com

Submitted by IG on Tue, 2018-11-06 13:55

All clear and working. Thank you David.

Submitted by shaunmac on Mon, 2023-03-27 22:28

does this still work with the latest version? I download and installed it but i'm getting an error "PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function widget_textBox(), 2 passed in {code saved}category_info.php on line 75 and at least 4 expected in {code saved}widget.php:83

Submitted by support on Tue, 2023-03-28 08:31

Hi,

For the latest distribution edit category_info.php and look for the following code beginning at line 73:

  print "Name:<br />";
  widget_textBox("name",(isset($_POST["name"])?widget_safe(widget_posted($_POST["name"])):""));

...and REPLACE with:

  widget_textBox("Name","name",FALSE,(isset($_POST["name"])?widget_safe(widget_posted($_POST["name"])):""));

Cheers,
David.
--
PriceTapestry.com

Submitted by shaunmac on Tue, 2023-03-28 11:30

Thank you for the reply. I did the above and it allowed for the prompt box in category info to appear but when I go to add a category it gives me a page cannot be found. Also would I need to do the same for brand info since its doing the same? Also this is the new error message I get. PHP Fatal error: Uncaught Error: Call to undefined function widget_posted() in {code saved}category_info.php:12

Submitted by support on Tue, 2023-03-28 11:57

Hi,

I've patched the download for compatibility with latest distributions - should work fine now for both brand and category info editing...

Cheers,
David.
--
PriceTapestry.com

Submitted by shaunmac on Tue, 2023-03-28 14:33

Outstanding it works perfect now.

Thank you for all the help.
Shaun