You are here:  » Categories: add description in page category and meta title

Active Forum Topics


Categories: add description in page category and meta title

Submitted by magnaromagna on Thu, 2021-01-07 21:37 in

Hi,
I added tips mentionned here, and I created on /pt/categoryinfo the files
1_title.html
1_description.html

I'm able to see meta description, but meta title not changes. Missing something?

And main question:
- how can I have "description" printed inside the page (for example after H1)

Thank you!

Submitted by support on Fri, 2021-01-08 09:58

Hi,

Could you confirm the changes that you made (to pto.php?) for meta title that aren't working and I'll check that out further with you...

To add a category description above the search results for page 1, in the same /pt/categoryinfo/ directory you created, add the file:

1_pagedescription.html

(where "1" is the Category Name including spaces)

Then edit pto_search.php and look for the following code at line 531:

  $html .= $pto_html_search_before;

...and REPLACE with:

  global $pto_q;
  global $pto_page;
  global $pto_config_externalPath;
  $parts = explode(":",$pto_q);
  if (($parts[0]=="category") && (isset($parts[1])) && ($pto_page==1))
  {
    $filename = $pto_config_externalPath."categoryinfo/".$parts[1]."_pagedescription.html";
    if (file_exists($filename))
    {
      $html .= file_get_contents($filename);
    }
  }
  $html .= $pto_html_search_before;

Cheers,
David.
--
PriceTapestry.com

Submitted by magnaromagna on Fri, 2021-01-08 10:45

Hi David,
on pto.php I modified as following:

{code saved}

and

{code saved}

and on pto_search.php I modified as following:

{code saved}

and

{code saved}

In /pt/categoryinfo I added (hierarchy id was 80)
80_title.html
80_description.html
name category with spaces_pagedescription.html
Name Category with spaces_pagedescription.html

I confirm you I'm seeing only meta description, no changes on title nor adding pagedescription.

Thank you again

Submitted by support on Fri, 2021-01-08 11:29

Hi,

Ah I see what's happened - it looks like there was already a modification in place to remove category:, merchant: etc. from the title; so to combine this with the custom title mod, in pto.php where you now have:

        $parts = explode(":",$pto_q);
        if (isset($parts[1]))
        {
          $title = htmlentities($parts[1],ENT_QUOTES,get_option("blog_charset"));
          $title_override = TRUE;
        }
        else
        {
          // $title = htmlentities($pto_q,ENT_QUOTES,get_option("blog_charset"));
          // https://www.pricetapestry.org/node/548
          $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);
          }
        }
        }

...REPLACE with:

        $parts = explode(":",$pto_q);
        if (isset($parts[1]))
        {
          $title = htmlentities($parts[1],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);
            }
          }
        }
        else
        {
          $title = htmlentities($pto_q,ENT_QUOTES,get_option("blog_charset"));
        }
        $title_override = TRUE;

Regarding pto_search.php, (I hadn't realised using Category Hierarchy sorry) the code you already had in place looks like it should be all you need to do this, pulling in /pt/categoryinfo/1.html :

    if (pto_common_isContainer())
    {
     // $html .= pto_search_banner();
     // https://www.pricetapestry.org/node/548
     $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);
        }
      }
    }

Can you confirm it's just the above that you need now, but is not currently working?

Cheers,
David.
--
PriceTapestry.com

Submitted by magnaromagna on Fri, 2021-01-08 13:40

Perfect, now I can see title, description meta and page description.

Just last question if possible: I see page description under the search form (and before the option to filter search). Is it possible to move it under the h1 title page?

Thanks again!

Submitted by support on Fri, 2021-01-08 15:42

Hi,

Sure - the code needs to be moved out of pto_search.php and would need to be a modification in pto.php (and does not require the pto_common_isContainer() check).

So having removed the modification from pto_search.php edit pto.php and look for the following code at line 840:

      $html .= pto_search_form();

...and REPLACE with;

      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);
        }
      }
      $html .= pto_search_form();

Cheers,
David.
--
PriceTapestry.com

Submitted by magnaromagna on Sat, 2021-01-23 08:40

Hi,
I noticed that description work fine for categories but not for sub-categories. Similar to issue fixed here: https://www.pricetapestry.org/node/661

It seems the hack not works for categories that have sub-categories.

Can you help?

Thanks!

Submitted by support on Mon, 2021-01-25 08:13

Hi,

Sure - the same code can be used before the atoz output, to do this edit pto.php and look for the following code at line 855:

        $html .= pto_atoz();

...and REPLACE with:

        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);
          }
        }
        $html .= pto_atoz();

Cheers,
David.
--
PriceTapestry.com

Submitted by magnaromagna on Mon, 2021-01-25 15:02

Perfect, thanks.