You are here:  » Unique category description


Unique category description

Submitted by wesse249 on Wed, 2016-06-22 06:36 in

Hello David,

I have a website with 10 categories. Is it possible to add for every seperate category a unique description?

Thank you.

Submitted by support on Wed, 2016-06-22 08:57

Hello Wesse,

Sure - the easiest way to is make a folder "categoryinfo" and in that folder, create .html files with the exact category name e.g.

categoryinfo/Category One.html
categoryinfo/Category Two.html

Then, to display the information above search results, at the very top of html/searchresults.php, or wherever required, use something like:

<?php
  
if ($parts[0]=="category")
  {
    
$filename "categoryinfo/".$parts[1].".html";
    if (
file_exists($filename))
    {
      print 
"<div class='row'>";
      print 
"<div class='small-12 columns'>";
      require(
$filename);
      print 
"</div>";
      print 
"</div>";
    }
  }
?>

(the row / columns HTML in the above is as per the Responsive HTML template, if using)

If you only want the description HTML to be included on page 1 in order to avoid duplicate content, use the following IF condition on the first line of the code;

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

Cheers,
David.
--
PriceTapestry.com

Submitted by DubaiCrazy on Tue, 2017-04-04 12:15

This doesnt work for me when I use the following:

categoryinfo/Category-One.html

Has anyone got this to work?

Thanks, Chris

Submitted by support on Tue, 2017-04-04 12:20

Hi Chris,

The filename should not contain hyphens - have a go with;

categoryinfo/Category One.html

However, if you would prefer to use hyphens in the filename then where you have the following code from the above modification;

    $filename = "categoryinfo/".$parts[1].".html";

...REPLACE with:

    $filename = "categoryinfo/".tapestry_hyphenate($parts[1]).".html";

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by DubaiCrazy on Tue, 2017-04-04 12:27

As always - you are a star. Thanks!