You are here:  » One category on the frontpage


One category on the frontpage

Submitted by wesse249 on Sun, 2017-11-26 21:07 in

Hello David,

I use category hierarchy where i have added three categories. I like one of the three categories on the frontpage also with the filter options and next page option when there ar more pages of that categorie at the bottom of the page. Is this possible?

Can you help?

Thanks Jan Roel

Submitted by support on Mon, 2017-11-27 10:14

Hello Jan,

What you can do is open search.php in your text editor and save it as a new file searchcode.php.

Then in the new file, DELETE the following line from line 2:

  require_once("includes/common.php");

Also DELETE the following code beginning at (now) line 532:

  require("html/header.php");
  require("html/menu.php");
  require("html/searchform.php");
  require("html/banner.php");

And finally DELETE the following code at (now) line 571:

  require("html/footer.php");

So basically, you have a file that can be included on your home page with the required query set in $_GET["q"] and will just display the search results, filters and navigation, for example:

<?php
  $_GET
["q"] = "category:Example/Category";
  require(
"searchcode.php");
?>

(omit PHP tags if already within PHP section of course)

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Mon, 2017-11-27 12:57

Hello,

Is it maybe also possible to show one specific category?

Thanks Jan Roel

Submitted by support on Mon, 2017-11-27 14:38

Hello Jan,

By default the search code will include the specified category and all sub-categories in the results. It would be tidiest to leave the category: search operator unchanged and create a new operator that only returns absolute results for the specified category, so to add a new "categoryabs" operator to the searchcode.php file look for the following code at line 100:

      case "category":

...and REPLACE with:

      case "categoryabs":
        $nodeInfo = tapestry_categoryHierarchyNodeInfo($parts[1]);
        $where = "categoryid = '".$nodeInfo["id"]."'";
        $sql = "SELECT SQL_CALC_FOUND_ROWS id,COUNT(id) AS numMerchants,MIN(price) as minPrice FROM `".$config_databaseTablePrefix."products` WHERE ".$where.$priceWhere." GROUP BY search_name";
        $orderBySelection = $orderByDefault;
        break;
      case "category":

And then in your calling code:

<?php
  $_GET
["q"] = "categoryabs:Example/Category";
  require(
"searchcode.php");
?>

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Wed, 2017-11-29 11:25

Hello David,

The last solution works. But when i go to the next page on the frontpage there are no products showed.

Can you see what the problem is?

{link saved}

Thanks Jan Roel

Submitted by support on Wed, 2017-11-29 12:44

Hello Jan,

Ah sorry I should have spotted that - subsequent pages are handled by search.php so the categoryabs: handler needs to be added to that file also - look for the following code at line 101:

      case "category":

...and REPLACE with:

      case "categoryabs":
        $nodeInfo = tapestry_categoryHierarchyNodeInfo($parts[1]);
        $where = "categoryid = '".$nodeInfo["id"]."'";
        $sql = "SELECT SQL_CALC_FOUND_ROWS id,COUNT(id) AS numMerchants,MIN(price) as minPrice FROM `".$config_databaseTablePrefix."products` WHERE ".$where.$priceWhere." GROUP BY search_name";
        $orderBySelection = $orderByDefault;
        break;
      case "category":

Cheers,
David.
--
PriceTapestry.com