You are here:  » Conventional A-Z Listing

Support Forum



Conventional A-Z Listing

Submitted by tammy on Wed, 2009-03-18 14:05 in

Is there any way to modify the brand listing tosomething like this

A
brand_A1 brand_A2 brand_A3
brand_A4 brand_A5 brand_A6

B
brand_B1 brand_B2 brand_B3
brand_B4

C
brand_C1 brand_C2

Thanks in advance

Submitted by support on Wed, 2009-03-18 16:03

Hi Tammy,

Sure - here as an alternative version of html/atoz.php (which is called by brands.php, merchants.php and categories.php) that will product the layout you describe. Change the number of columns and column width on lines 3 and 5. If you only require this layout for the brands, save the code below as something like html/atozbrands.php, and then edit brands.php and replace atoz.php with atozbrands.php towards the end of the script (line 42).

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

Hope this helps!

Cheers,
David.

Submitted by tammy on Wed, 2009-03-18 17:08

Thanks so much. That's exactly what I have worked on for days. :)