You are here:  » Brand Logos


Brand Logos

Submitted by Mik3 on Sat, 2009-10-03 10:14 in

David,

Would you be able to provide example code for a brands.php page to display a logo in place of the brand name?

Thanks
Mike

Submitted by support on Sun, 2009-10-04 15:35

Hi Mike,

Sure, on line 16 of brands.php you will find this code:

$item["name"] = $product["brand"];

...so to use brand logos, REPLACE that with:

$brandLogo = "logos/".$product["brand"].".gif";
if (file_exists($brandLogo))
{
  $item["name"] = "<img src='".$config_baseHREF.$brandLogo."' border='1' />";
}
else
{
  $item["name"] = $product["brand"];
}

This will look for brand logo files in .gif format in the /logos/ folder located in the same directory as brands.php. Create the logo files with exactly the same filename as the name appears (including spaces) ending in .gif.

Cheers,
David.

Submitted by paddyman on Thu, 2009-12-31 21:59

Hi David,

Have tried the above and getting the following output.

<
    * '>

Any ideas,

Adrian

Submitted by support on Fri, 2010-01-01 14:17

Hi Adrian,

Not really sure what's happening there but if you could email me your modified brands.php i'll check it out for you...

Cheers,
David.

Submitted by tisbris on Mon, 2010-12-13 21:23

Hi David

Tried to implement this brand logo, but I also got some small issues...

The logo is displayed, but the FirstLetter ex. 'B' is removed and replaced with '<' also the listing of logos is off... this is the html source code.

<table width='100%'><tr><td valign='top' width='25%'><h4>A</h4><p><a href='search.php?q=brand:A2Z:'>A2Z</a></p><p><a href='search.php?q=brand:Alligator:'>Alligator</a></p><p><a href='search.php?q=brand:American+Classic:'>American Classic</a></p><p><a href='search.php?q=brand:Avid:'>Avid</a></p></td><td valign='top' width='25%'><h4><</h4><p><a href='search.php?q=brand:Bontrager:'><img border='0' src='/pt/logosbrand/Bontrager.gif' /></a></p><p><a href='search.php?q=brand:Campagnolo:'><img border='0' src='/pt/logosbrand/Campagnolo.gif' /></a></p><p><a href='search.php?q=brand:Cannondale:'><img border='0' src='/pt/logosbrand/Cannondale.gif' /></a></p></td><td valign='top' width='25%'><h4>C</h4><p><a href='search.php?q=brand:Cinelli:'>Cinelli</a></p><p><a href='search.php?q=brand:Connect:'>Connect</a></p><p><a href='search.php?q=brand:Crank+Brothers:'>Crank Brothers</a></p><p><a href='search.php?q=brand:Crankbrothers:'>Crankbrothers</a></p></td><td valign='top' width='25%'><h4>D</h4><p><a href='search.php?q=brand:Deda:'>Deda</a></p><p><a href='search.php?q=brand:DT+Swiss:'>DT Swiss</a></p></td></tr>
brand.php:
// $item["name"] = $product["brand"];
// http://www.pricetapestry.com/node/3037
$brandLogo = "logosbrand/".$product["brand"].".gif";
if (file_exists($brandLogo))
{
$item["name"] = "<img border='0' src='".$config_baseHREF.$brandLogo."' />";
}
else
{
$item["name"] = $product["brand"];
}
also how to implement this into the external.php:
        break;
      case "brand":
        $sql = "SELECT DISTINCT(brand) AS brand FROM `".$config_databaseTablePrefix."products` WHERE brand <> '' ORDER BY brand";
        break;
    }
    if ($sql)
    {
      if (database_querySelect($sql,$rows))
      {
        $items = array();
        $currentLetter = "";
        foreach($rows as $row)
        {
          $item = array();
          $item["name"] = $row[$r];
          $item["href"] = $internal_baseHREF."q=".$r.":".urlencode($row[$r]).":";
          $items[] = $item;
        }
        atoz($items);
      }
      else
      {
        print "<p>There are no items to display.</p>";
      }
    }
  }

thx
Brian

Submitted by support on Tue, 2010-12-14 09:32

Hi Brian,

What you'll need to do, in brands.php, in place of the replacement described above, use:

$brandLogo = "logos/".$product["brand"].".gif";
if (file_exists($brandLogo))
{
  $item["name"] = $product["brand"];
  $item["logo"] = "<img src='".$config_baseHREF.$brandLogo."' border='1' />";
}
else
{
  $item["name"] = $product["brand"];
}

Then, in html/atoz.php look for the following code at line 43:

    print "<p><a href='".$item["href"]."'>".$item["name"]."</a></p>";

...and REPLACE that with:

    if ($item["logo"])
    {
      print "<p><a href='".$item["href"]."'><img border='0' src='".$item["logo"]."' /></a></p>";
    }
    else
    {
      print "<p><a href='".$item["href"]."'>".$item["name"]."</a></p>";
    }

Cheers,
David.
--
PriceTapestry.com

Submitted by Bigmac on Tue, 2011-04-19 06:06

Hi David,

I have implemented the modification detailed here but now my merchants page shows /subfolder/logos/merchantlogo but no merchant logo.

Strange thing is the products page still displays the merchants logos!

Cheers,

Hamish

Submitted by support on Tue, 2011-04-19 08:09

Hi Hamish,

Sorry about that - the modification described above wasn't quite correct; this line:

      print "<p><a href='".$item["href"]."'>".$item["logo"]."</a></p>";

...should have been:

      print "<p><a href='".$item["href"]."'><img border='0' src='".$item["logo"]."' /></a></p>";

Corrected above...

Cheers,
David.
--
PriceTapestry.com

Submitted by Bigmac on Tue, 2011-04-19 09:03

Hi David,

Thanks for the swift reply.

Does 12/10A work differently as I now have my merchant logos back but my Brand logos have now gone.

Also, am I right in thinking I can add alt and title text to the image? I have tried adding title=".$product["brand"]." to brands.php but it only displays the first word of the brand.

Thanks again.

Hamish

Submitted by support on Tue, 2011-04-19 10:17

Hi Hamish,

12/10A doesn't have brand logo support built in but you can add it easily, assuming the same folder (/logos/) in brands.php look for the following code at line 16:

        $item["name"] = $product["brand"];

...and REPLACE with;

        $item["name"] = $product["brand"];
        if (file_exists("logos/".$product["brand"]))
        {
          $item["logo"] = $config_baseHREF."logos/".$product["brand"];
        }

For your alt and title tags, rather than $product["brand"], within html/atoz.php the logo HTML is generated at line 49:

print "<img src='".$item["logo"]."' border='0' />";

...REPLACE that with:

print "<img src='".$item["logo"]."' border='0' alt='".htmlentities($item["name"],ENT_QUOTES,$config_charset)."' title='".htmlentities($item["name"],ENT_QUOTES,$config_charset)."' />";

Cheers,
David.
--
PriceTapestry.com

Submitted by Antony on Thu, 2020-04-23 09:21

Hi David,

Hope you are well,

i've been trying to swap "Brand Names" for "Brand Logos" on brand/php by following this node and 4954 but cant really get around it, how would you go by achieving this on the latest PT version?

Thanks,

Ant

Submitted by support on Thu, 2020-04-23 10:30

Hello Ant,

Upload your brand logos to the /logos/ folder (same location as Merchant logos) using the filename:

brand_Brand Name.img

(where .img is the same extension used for merchant logos as set by $config_logoExtension in config.advanced.php)

Then edit brands.php and look for the following code at line 16:

        $item["name"] = $product["brand"];

...and REPLACE with:

        $item["name"] = $product["brand"];
        if (file_exists("logos/brand_".$product["brand"].$config_logoExtension))
        {
          $item["logo"] = $config_baseHREF."logos/brand_".str_replace(" ","%20",$product["brand"]).$config_logoExtension;
        }

Cheers,
David.
--
PriceTapestry.com

Submitted by Antony on Thu, 2020-04-23 10:59

Sorted! Thanks David