You are here:  » Category Hierarchy and 404


Category Hierarchy and 404

Submitted by sirmanu on Fri, 2020-01-03 00:21 in

Hi David.

As I have previously mentioned in other post, I am heavily using Category Hierarchy.

But I have noticed I minor "bug" that I need to fix. I don't know if this problem is just me or for the current version.

Let me explain it to you with an example.

example.com/electronic/smartwatches => valid URL with products

The problem is that if someone shares the URL, for instance, example.com/electronic/smartwattchesssss, this url still works with status code 200 (it should be soft 404) because tapestry_categoryHierarchyNodeInfo takes products from electronic category.

Is it possible to make some change to this functionality?

Thank you very much!

Submitted by support on Fri, 2020-01-03 09:33

Hi,

Sure - first edit includes/tapestry.php and look for the following code at line 447:

      database_querySelect($sql,$rows);

...and REPLACE with:

      if (!database_querySelect($sql,$rows)) return FALSE;

Then edit categories.php and look for the following code at line 12:

    $nodeInfo = tapestry_categoryHierarchyNodeInfo(str_replace("-"," ",$path));

...and REPLACE with:

    $nodeInfo = tapestry_categoryHierarchyNodeInfo(str_replace("-"," ",$path));
    if ($nodeInfo==FALSE)
    {
      require("404.php");
      exit();
    }

Finally, create the new file 404.php or as required;

<?php
  $header
["title"] = "404 Not Found";
  
header("HTTP/1.0 404 Not Found");
  require(
"html/header.php");
  require(
"html/menu.php");
  require(
"html/searchform.php");
  print 
"<div class='row'>";
  print 
"<div class='small-12 columns'>";
  print 
"<h1>404 Not Found</h1>";
  print 
"</div>";
  print 
"</div>";
  require(
"html/footer.php");
?>

Cheers,
David.
--
PriceTapestry.com

Submitted by sirmanu on Fri, 2020-01-03 13:35

Thank you David, easier than expected. It works perfectly!