Support forum login

©2006-2014 IAAI Software

Contact Us Privacy Policy

List categories inside a category map

Submitted by Romac39 on Sat, 2012-06-09 14:26.

Hi David,

I have made a lot of category maps to bring some order to the thousands of products on my site. But now when some one clicks the category they have no way to specify a certain type of product in that category map.

How can I list the contents of a category map above the enormous list of products in lets say two or 3 columns or even just comma seperated, so that people can click a sub category to more specify the products they are looking for.
A good alternative would also be if possible to display the categories that are inside the category map under the category dropdown menu in the sidebar widget.

Per example in the category map Telecom 20 other categories (everything from mobile phones to headphones and accessories) can be found:
So how would I alow a visitor to better specify what he is looking for?

I hope you can suggest something.



Submitted by support on Sun, 2012-06-10 10:00.

Hi Robert,

I can see how this could be implemented by copying how original_name is captured prior to Product Mapping being applied. I'll document the full modification on Monday but in the mean time; if you haven't done so already if you could apply the sidebar filters patch that will be a good starting point as the code will involve copying the categoryFilter etc. components as subcategoryFilter etc..


Submitted by Romac39 on Thu, 2012-06-14 11:55.

Ok David, thanks and I'll wait till monday.


Submitted by support on Thu, 2012-06-14 13:48.

Hi Robert,

Firstly, add the subcategory field to your products table with the following dbmod.php script:

$sql "ALTER TABLE `".$config_databaseTablePrefix."products`
            ADD `subcategory` VARCHAR(255) NOT NULL"

Then in includes/admin.php look for the following comment at line 233:

    /* apply category mappings */

...and REPLACE with:

    /* apply category mappings */
    $importRecord["subcategory"] = $importRecord["category"];

...and finally in that file look for the following comment at line 266:

    /* capture original catalogue product name prior to mapping */

...and REPLACE with:

    if ($importRecord["subcategory"]==$importRecord["category"]) $importRecord["category"] = "";
    /* capture original catalogue product name prior to mapping */

Now, based on the sidebar filters version of search.php, duplicate every section of
code relating to $categoryFilter but for $subcategoryFilter. Do this by adding the following sections of code
(line numbers indicate the first line of the original categoryFilter version)...

line 16, add:

  $subcategoryFilter = ($_GET["subcategoryFilter"]?$_GET["subcategoryFilter"]:"");

line 57, add:

  if ($subcategoryFilter)
    $priceWhere .= " AND subcategory = '".database_safe($subcategoryFilter)."' ";

line 316, add:

      if ($subcategoryFilter)
        $sortHREF .= "subcategoryFilter=".urlencode($subcategoryFilter)."&amp;";

and line 410, add:

if ($subcategoryFilter)
$sort .= "&amp;subcategoryFilter=".urlencode($subcategoryFilter);

Filter code already exists in the plugin; so to add similar functionality firstly in pto.php;

line 306, add:

  array_push($vars, 'pto_subcategoryFilter');

line 52, add:

  global $pto_categoryFilter;

line 117, add:

  $pto_subcategoryFilter = (isset($pto_subcategoryFilter)?$pto_subcategoryFilter:"");

line 146, add:

  if ($pto_categoryFilter)
    $priceWhere .= " AND category = '".$wpdb->escape($pto_categoryFilter)."' ";

and line 870, add the new drop-down for subcategory:

    $sql = "SELECT DISTINCT(subcategory) FROM `".$pto_config_databaseTablePrefix."products` WHERE ".$pto_searchWhere." AND subcategory <> '' ORDER BY subcategory";
    if ($numRows = $wpdb->query($sql))
      $html_subcategories = "";
        $product = $wpdb->last_result[$i];
        $html_subcategories .= "<option ".($pto_subcategoryFilter==$product->subcategory?"selected='selected'":"")." value='".htmlentities($product->subcategory,ENT_QUOTES,get_settings("blog_charset"))."'>".$product->subcategory."</option>";
      $html = str_replace("%SUBCATEGORIES%",$html_subcategories,$html);
      $html = str_replace("%IF_SUBCATEGORIES%","",$html);
      $html = str_replace("%ENDIF_SUBCATEGORIES%","",$html);
      $html = preg_replace('/%IF_SUBCATEGORIES%(.*)%ENDIF_SUBCATEGORIES%/','',$html);

Finally, edit the Sidebar Filters widget template in wp-admin > Settings > to include:

<br />By Subcategory:
<br /><select name=\'pto_subcategoryFilter\'>
  <option value=\'\'>All</option>


Submitted by nosferatu on Sun, 2012-12-30 10:47.

I tried to make the same modification in pricetapestry without wp and I got stuck. Can you help me with this modification but without wp . Thank U

Submitted by support on Mon, 2012-12-31 08:11.

Hello nosferatu ,

The modifications described above cover standalone first, if you would like to email me your modified files. plus if you could include a copy of any error messages that result etc. I'll check it all out for you right away...