You are here:  » Random products on the frontpage


Random products on the frontpage

Submitted by wesse249 on Mon, 2018-04-30 10:16 in

Hello David,

Is it possible to show random 12 differtent products from the database on the homepage {link saved} instead of featured products which have to be manual selected?

Is it possible to show the categoryname of a category on the categorypage instead of the defaultname shopping (in my language winkelen)? This als for brand and merchant. {link saved}

And is it also possible when i'm on a category, merchant, brand or productpage that you see also this title in the meta data?

In the normal pricetapestry code i have this in products.php for creating my own meta:

$header["title"] = "".$q."";
$desc = $product["products"][0]["description"];
$desc = strip_tags($desc);
$desc = tapestry_substr($desc,150);
$header["meta"]["description"] = "".$q." - ".$desc.".";
$header["meta"]["keywords"] = "".$q."";

And for the category this one:

Thank you.

Jan Roel

Submitted by support on Tue, 2018-05-01 07:50

Hello Jan,

For 12 random products on the home page, edit the plugin file pto_featured.php and look for the following code at line 43:

    $sql = "SELECT * FROM `".$pto_config_databaseTablePrefix."featured` WHERE name NOT LIKE '%/%' ORDER BY sequence";

...and REPLACE with:

    $sql = "SELECT name,1 AS sequence FROM `".$pto_config_databaseTablePrefix."products` ORDER BY RAND() LIMIT 12";

To have the category (or merchant / brand) show in the page title, 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:

        $parts = explode(":",$pto_q);
        if (isset($parts[1]))
        {
          $title = htmlentities(str_replace(array("merchant","category","brand",":"),"",$parts[1]),ENT_QUOTES,get_option("blog_charset"));
          $title_override = TRUE;
        }
        else
        {
          $title = htmlentities($pto_q,ENT_QUOTES,get_option("blog_charset"));
        }

As with the main title element, page (if not 1) and sort (if not relevance) will be appended to avoid duplicate titles.

To make the product page meta description and keywords the same as your standalone Price Tapestry mods, edit pto.php and look for the following code beginning at line 744:

      $description = trim($description);

...and REPLACE with:

      $description = trim($description);
      if ($pto_module=="product")
      {
        $desc = $pto_productResults[0]->description;
        $desc = strip_tags($desc);
        $desc = pto_common_substr($desc,150);
        $description = $pto_productResults[0]->name." - ".$desc;
        $keywords = $pto_productResults[0]->name;
      }

It looks like you missed out from your post the code you are using for category meta tags, can you post that and I'll show you how to do the same in the plugin...

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Tue, 2018-05-01 08:02

Hello David,

Thank you very much. You mean these lines i think:

if (isset($parts[1]))
{
switch($parts[0])
{
case "merchant":
$header["meta"]["description"] = "".$parts[1]." koopt u via ".$config_title." het adres voor ".$parts[1]." aanbiedingen";
break;
case "category":
$header["meta"]["description"] = "".$parts[1]." koopt u via ".$config_title." het adres voor ".$parts[1]." aanbiedingen";
break;
case "brand":
$header["meta"]["description"] = "".$parts[1]." koopt u via ".$config_title." het adres voor ".$parts[1]." aanbiedingen";
break;
}
}

Another question. Did you ever hear of the following problem: when i make of the shopping page of pricetapestry a static page in wordpress then the link to the categories, merchant and brand not working anymore. Do you maybe have a solution for this?

Greetings Jan Roel

Submitted by support on Tue, 2018-05-01 09:23

Hello Jan,

To do the same for the pluign, edit pto.php and look for the following code at line 761:

  $pto_headDone = TRUE;

...and REPLACE with:

  global $pto_q;
  if ($pto_q)
  {
    $parts = explode(":",$pto_q);
    if (isset($parts[1]))
    {
      $name = get_bloginfo("name");
      switch($parts[0])
      {
        case "merchant":
          $desc = "".$parts[1]." koopt u via ".$name." het adres voor ".$parts[1]." aanbiedingen";
          break;
        case "category":
          $desc = "".$parts[1]." koopt u via ".$name." het adres voor ".$parts[1]." aanbiedingen";
          break;
        case "brand":
          $desc = "".$parts[1]." koopt u via ".$name." het adres voor ".$parts[1]." aanbiedingen";
          break;
      }
      print "<meta name='description' content='".htmlentities($desc,ENT_QUOTES,get_option("blog_charset"))."' />\n";
    }
  }
  $pto_headDone = TRUE;

Because of how the rewrite is handled the container permalink page cannot be assigned as the static home page however it's no problem simply to make another page to use as the home page and include the [pto] shortcode on that page also...

Cheers,
David.
--
PriceTapestry.com