You are here:  » Category frontpage


Category frontpage

Submitted by wesse249 on Mon, 2015-08-24 18:54 in

Hello David,

I created a holiday compare version.

I change the category field into Country. I have a total of 20 countries

At this moment you see on my frontpage all merchants. I'd like to show the categories on this page.

I'd like also to programm it mannually because i want to add the country flag with the countryname under the flag in a table like this:

Countryflag1 | Countryflag2 | Countryflag3 | Countryflag4 | Countryflag5
Countryname1 | Countryname2 | Countryname3 | Countryname4 | Countryname5
------------------------------------------------------------------------
Countryflag6 | Countryflag7 | Countryflag8 | Countryflag9 | Countryflag10
Countryname6 | Countryname7 | Countryname8 | Countryname9 | Countryname10

This is my frontpagecode at this moment:

<?php
  $atoz
["items"] = array();
  
$sql "SELECT DISTINCT(merchant) FROM `".$config_databaseTablePrefix."products` ORDER BY merchant";
  if (
database_querySelect($sql,$rows))
  {
    foreach(
$rows as $product)
    {
      
$item = array();
      
$item["name"] = $product["merchant"];
      if (
file_exists("logos/".$product["merchant"]))
      {
        
$item["logo"] = $config_baseHREF."logos/".str_replace(" ","%20",$product["merchant"]);
      }
      if (
$config_useRewrite)
      {
        
$item["href"] = tapestry_indexHREF("merchant",$product["merchant"]);
      }
      else
      {
        
$item["href"] = "search.php?q=merchant:".urlencode($product["merchant"]).":";
      }
      
$atoz["items"][] = $item;
    }
  }
  require(
"html/atoz.php");
?>

Thanks Jan Roel

Submitted by support on Tue, 2015-08-25 07:58

Hello Jan,

You should be able to use pretty much identical code, using the `category` field instead of `merchant`, and, flag images as logos, so they just need to be stored in the /logos/ folder with a file name exactly matching the country name, then have a go with;

<?php
  $atoz
["items"] = array();
  
$sql "SELECT DISTINCT(category) FROM `".$config_databaseTablePrefix."products` ORDER BY category";
  if (
database_querySelect($sql,$rows))
  {
    foreach(
$rows as $product)
    {
      
$item = array();
      
$item["name"] = $product["category"];
      if (
file_exists("logos/".$product["category"]))
      {
        
$item["logo"] = $config_baseHREF."logos/".str_replace(" ","%20",$product["category"]);
      }
      if (
$config_useRewrite)
      {
        
$item["href"] = tapestry_indexHREF("category",$product["category"]);
      }
      else
      {
        
$item["href"] = "search.php?q=category:".urlencode($product["category"]).":";
      }
      
$atoz["items"][] = $item;
    }
  }
  require(
"html/atoz.php");
?>

Cheers,
David.
--
PriceTapestry.com