You are here:  » Re-organise Brands

Support Forum



Re-organise Brands

Submitted by urmyworld on Tue, 2009-12-08 13:22 in

Hello David,

In my website, I would like to re-format the way that brands are displayed.

Currently, by selecting "brands" from the search method menu, "brands" are displayed by numerical then alphabetical sort.

The current display features brands by a vertical column relative to it's numerical/alphabetical group.

Is it possible to change this to displaying the numerical/alphabetical group being horizontal as it is now, but to also have the actual "brands" within this being displayed in a horizontal manner also.

To further explain,

Could the actual "brands" be displayed in a "table" so that maybe 4 or 5 columns wide, by as many rows as required for the numeric/alphabetical listings.

Submitted by support on Tue, 2009-12-08 15:36

Hi David,

Sure - the number of columns can be controlled in html/atoz.php on line 3:

  $columns = 1;

...simply change the value of $columns as required.

However, this file is used for the merchant and category indexes also; so if you only want have more than one column for the brand index then you could REPLACE the above line with:

  if (strpos($_SERVER["PHP_SELF"],"brands.php")!==FALSE)
  {
    $columns = 4; // or whatever column number you want for brand index
  }
  else
  {
    $columns = 1;
  }

Hope this helps!

Cheers,
David.

Submitted by urmyworld on Thu, 2009-12-24 01:46

Hello David,

Your solution above is halfway there to what I would like.

Now I have the one column display alphabetically, but would like the actual brands / categories / merchants to be in 4 or 5 columns within each group, for example

A (BRANDS)
A AA AAAA AAAAA
AAAAAAA AAAAAA AAAAAAAA AAAAAAAAAAA

B (BRANDS)
B BB BBB BBBB
BBBBB BBBBBBB

I hope you understand

best regards

David S S

Submitted by support on Fri, 2009-12-25 19:40

Hi David,

Sure - try this as a complete replacement for html/atoz.php

<div class='atoz'>
<?php
  $columns = 4;
  $columnWidth = intval(100/$columns);
  $currentLetter = "";
  $currentColumn = 0;
  foreach($atoz["items"] as $item)
  {
    $firstLetter = strtoupper(substr($item["name"],0,1));
    if ($firstLetter !== $currentLetter)
    {
      if ($currentLetter !== "")
      {
        while ($currentColumn < $columns)
        {
          print "<td valign='top' width='".$columnWidth."%'>&nbsp;</td>";
          $currentColumn++;
        }
        $currentColumn = 0;
        print "</tr>";
        print "</table>";
      }
      print "<h4>".$firstLetter."</h4>";
      $currentLetter = $firstLetter;
      print "<table width='100%'>";
      print "<tr>";
    }
    print "<td valign='top' width='".$columnWidth."%'><a href='".$item["href"]."'>".$item["name"]."</a></td>";
    $currentColumn++;
    if ($currentColumn == $columns)
    {
      print "</tr>";
      print "<tr>";
      $currentColumn = 0;
    }
  }
  print "</td>";
  print "</tr>";
  print "</table>";
?>
</div>

This will apply to all A to Z displays (merchant,category and brand) - if you only want this style of display add the same modification as described above to set $columns depending on the script filename...

Hope this helps!

Cheers,
David.

Submitted by bat on Fri, 2011-07-29 19:00

I'm interested in the code in the above post. What code would it be for the latest version 12/10B so it would show up the brand logos as I've tried the above code but none of the logos appeared, just text?

Submitted by support on Sat, 2011-07-30 07:02

Hi Bat,

Here's a version of the above with logo support as per html/atoz.php from 12/10A+

<div class='atoz'>
<?php
  $columns = 4;
  $columnWidth = intval(100/$columns);
  $currentLetter = "";
  $currentColumn = 0;
  foreach($atoz["items"] as $item)
  {
    $firstLetter = strtoupper(substr($item["name"],0,1));
    if ($firstLetter !== $currentLetter)
    {
      if ($currentLetter !== "")
      {
        while ($currentColumn < $columns)
        {
          print "<td valign='top' width='".$columnWidth."%'>&nbsp;</td>";
          $currentColumn++;
        }
        $currentColumn = 0;
        print "</tr>";
        print "</table>";
      }
      print "<h4>".$firstLetter."</h4>";
      $currentLetter = $firstLetter;
      print "<table width='100%'>";
      print "<tr>";
    }
    print "<td valign='top' width='".$columnWidth."%'><a href='".$item["href"]."'>";
    if (isset($item["logo"]))
    {
      print "<img src='".$item["logo"]."' border='0' />";
    }
    else
    {
      print $item["name"];
    }
    print "</a></td>";
    $currentColumn++;
    if ($currentColumn == $columns)
    {
      print "</tr>";
      print "<tr>";
      $currentColumn = 0;
    }
  }
  print "</td>";
  print "</tr>";
  print "</table>";
?>
</div>

Cheers,
David.
--
PriceTapestry.com

Submitted by shaunmac on Sat, 2012-12-08 00:52

How would i implement this in wordpress?

Submitted by support on Sat, 2012-12-08 15:46

Hi Shaun,

Even easier in the plugin - i'd first have a go using fixed width floated left blocks for each item, with a clear both before template. From wp-admin > Settings > PriceTapestry.org, scroll down to the HTML section and as the A to Z / Before, which is as follows by default:

<h3>%LETTER%</h3>
<ul>

...REPLACE with:

<h3 style='clear:both'>%LETTER%</h3>

And as the A to Z / Each template, which by default is as follows:

<li><a href='%ITEM_URL%'>%ITEM%</a></li>

...REPLACE with:

<div style='width:25%;float:left;'><a href='%ITEM_URL%'>%ITEM%</a></div>

That should give 4 columns of items under each letter heading; if that's too many or there is space for more in your layout adjust the percentage width accordingly...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com