©2006-2017 IAAI Software

Contact Us Privacy Policy

Unique Category Descriptions

Submitted by cclayton on Fri, 2017-09-29 10:05.

Hi David,

I have tried using (https://www.pricetapestry.com/node/6026) to get Unique Category Descriptions working for this, but it doesnt seem to work. Should it work the same with Wordpress as the standalone?

I am wanting to create some unique category content on the page.

Thanks as always, Chris

Submitted by support on Fri, 2017-09-29 11:59.

Hello Chris,

The changes from node/6026 won't have any effect within the plugin but it's straight forward to implement however as you're using Category Hierarchy, the easiest way to do this would be to create the unique content files using the ID of the node in the category hierarchy.

To see the node ID, from Category Hierarchy Mapping click Configure next to the node that you wish to create the content for and you will see the ID in the URL e.g.

.../categories_hierarchy_configure.php?id=2

...so the node ID is 2. In this case, create the file (as per node/6026) as follows

categoryinfo/2.html

(relative to the Price Tapestry installation folder e.g. /pt/)

With that in place, edit the plugin file pto_search.php and look for the following code at line 414:

      $html .= pto_search_banner();

...and REPLACE with:

      $html .= pto_search_banner();
      global $pto_nodeInfo;
      global $pto_config_externalPath;
      if (isset($pto_nodeInfo))
      {
        $filename = $pto_config_externalPath."categoryinfo/".$pto_nodeInfo["id"].".html";
        if (file_exists($filename))
        {
          $html .= file_get_contents($filename);
        }
      }

As per node/6026 the above would display the unique content on page 2, 3 etc. for the category. If you would prefer to display on page 1 only (considering possible duplicate content issue) then in place of this line:

      if (isset($pto_nodeInfo))

...use:

      if (isset($pto_nodeInfo) && ($pto_page == 1))

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by cclayton on Fri, 2017-09-29 15:04.

As always thats great David, what do I need to do to get the title and description meta tags also added for the category. I have used the same methodology as suggested above but I guess there is an additional piece of code i need to update the header?

Submitted by support on Fri, 2017-09-29 16:44.

Hi Chris,

Due to the sequence of events in page generation within WordPress the title and meta description are output before the main search results content however all context is present so I just wanted to check, did you want to

a) Generate title / meta description based on the category path with fixed text before / after the category path

~or~

b) Completely custom title and meta description per node? For example using files:

categoryinfo/2_title.txt
categoryinfo/2_description.txt

Cheers,
David.
--
PriceTapestry.com

Submitted by cclayton on Mon, 2017-10-02 11:07.

Hi David,

I wanted option (b) a custom title and meta description. I have setup a folder called

categorymeta/2.html

Within that file I have the following:

<?php
$header 
["meta"]["description"] = "My description for meta";
$header ["title"] ="My title for the page";
?>

Hope that makes sense, thanks!

Chris

Submitted by support on Mon, 2017-10-02 12:47.

No problem!

Rather than the .php file as used by node/6026 for standalone, for the plugin the code for the page title and meta tag are in separate functions so the text files would be easier, so using the same /pt/categoryinfo/ directory create as required for example;

categoryinfo/2_title.txt
categoryinfo/2_description.txt

Then edit the plugin file pto.php and look for the following code at line 638:

        $title = htmlentities($pto_q,ENT_QUOTES,get_option("blog_charset"));

...and REPLACE with:

        $title = htmlentities($pto_q,ENT_QUOTES,get_option("blog_charset"));
        global $pto_nodeInfo;
        global $pto_config_externalPath;
        if (isset($pto_nodeInfo))
        {
          $filename = $pto_config_externalPath."categoryinfo/".$pto_nodeInfo["id"]."_title.html";
          if (file_exists($filename))
          {
            $title = file_get_contents($filename);
          }
        }

And then the following code at (now) line 694:

  switch($pto_module)

...and REPLACE with:

  global $pto_page;
  global $pto_nodeInfo;
  global $pto_config_externalPath;
  if (isset($pto_nodeInfo))
  {
    $filename = $pto_config_externalPath."categoryinfo/".$pto_nodeInfo["id"]."_description.html";
    print "<meta name='description' content='".file_get_contents($filename)."' />\n";
  }
  switch($pto_module)

Additional processing of the title will append page / sort to avoid duplicate titles.

As with the on-page description the above will show the meta description on all pages but if you wish to limit to page 1 then in place of this line:

 if (isset($pto_nodeInfo))

...use:

 if (isset($pto_nodeInfo) && ($pto_page==1))

Cheers,
David.
--
PriceTapestry.com