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.
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
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."%'> </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.
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?
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."%'> </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
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
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.