You are here:  » Category A to Z Modification


Category A to Z Modification

Submitted by ssgupta on Fri, 2017-09-15 10:42 in

How can we implement this:

https://www.pricetapestry.com/node/266

in WordPress. Thanks

Submitted by support on Fri, 2017-09-15 11:48

Hi,

To apply the same modification in WordPress, edit pto_atoz.php and look for the following code at line 98:

      $sql = "SELECT DISTINCT(".$module.") FROM `".$pto_config_databaseTablePrefix."products` WHERE ".$module." <> '' ORDER BY ".$module;

...and REPLACE with:

    if ($module=="category")
    {
      $letter = (isset($_GET["letter"])?$_GET["letter"]:"");
      if ($letter)
      {
        $sql = "SELECT DISTINCT(category) FROM `".$pto_config_databaseTablePrefix."products` WHERE category LIKE '".$wpdb->escape($letter)."%' ORDER BY category";
      }
      else
      {
        $sql = "SELECT DISTINCT(UCASE(SUBSTRING(category,1,1))) as letter FROM `".$pto_config_databaseTablePrefix."products` ORDER BY category";
        if ($wpdb->query($sql))
        {
          $rows = $wpdb->last_result;
          foreach($rows as $letters)
          {
            $html .= "<p><a href='?letter=".$letters->letter."'>".$letters->letter."</a></p>";
          }
        }
        return $html;
      }
    }
    else
    {
      $sql = "SELECT DISTINCT(".$module.") FROM `".$pto_config_databaseTablePrefix."products` WHERE ".$module." <> '' ORDER BY ".$module;
    }

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by ssgupta on Sat, 2017-09-16 08:30

Works nicely. Thank you.