Hi
I am using the cat a-z mod, it works great , however since the products have increased the list on the letters page has now become very long. Is there any way that this list could be more presentable to the vistor.
Thanks
Brent
Hi David
sorry, i did not explain it very well, its the list when you get to the indivdual letter for the category, I have listed a url below that I am using as a test, although the list is not very long at present when all the categories are listed there can be well over a 100 in the popular letters, ideally i would like to have then listed fo there are 4 or 5 categories per line.
http://www.4utoday.co.uk/shopping-mall-north/category/F/
thanks
brent
Hi Brent,
Assuming that you're using the category letter mods from this thread:
http://www.pricetapestry.com/node/266
...you would need to modify html/atoz.php in a different way, in order to layout the items in columns rather than the letters. Try this as a replacement:
<?php
$columns = 4;
$columnWidth = intval(100/$columns);
$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 "</tr>";
print "</table>";
print "<h4>".$firstLetter."</h4>";
print "<table width='100%'>";
print "<tr>";
}
$currentLetter = $firstLetter;
}
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>";
?>
I notice that your sample URL isn't working - so if this doesn't help, if you could let me know where to see your existing output, and also what code you are using to display the individual letter results and i'll work out how to put the columns in for you. If it's easier to email the files you've modified to do this to me, feed free - reply to your reg code or forum registration email is the easiest way to get me...
Cheers,
David.
Hi david
That worked great, makes the presentation much better.
Brent
Hi David
Have just implemented this mod in 2 column format, which really tidies up the list.
Problem is - the letters in the h4 headers all work except the first one in the list (i.e. A)
this is the code I'm using:
<?php
$columns = 2;
$columnWidth = intval(100/$columns);
$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 "</tr>";
print "</table>";
print "<h4>".$firstLetter."</h4>";
print "<table width='100%'>";
print "<tr>";
}
$currentLetter = $firstLetter;
}
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>";
?>
Any ideas on what's missing?
best regards
Kelly
Hi Kelly,
This section:
if ($currentLetter)
{
print "</tr>";
print "</table>";
print "<h4>".$firstLetter."</h4>";
print "<table width='100%'>";
print "<tr>";
}
...is testing $currentLetter to decide whether or not to close the table; but but is only starting the new table within the same IF statement; which is why the first letter is never displayed. I think that section should be as follows:
if ($currentLetter)
{
print "</tr>";
print "</table>";
}
print "<h4>".$firstLetter."</h4>";
print "<table width='100%'>";
print "<tr>";
That should do the trick!
Cheers,
David.
Hi David
I am looking to expand the categories.php page.
I have created a new field into DB called category2, which I am using as the main category and the existing category field as a subcategory. (I know - i'm a backwards girl - but everything is working ok and I didn't want to rock the boat!!)
Is it possible to have the a-z of categories display the Main category then all of the subcategories within that main category?
I have created a new page called catatoz.php and have dabbled, as I managed to get a similar thing working on one of my non-pt sites by using a nested repeat region, but your code is too complex for me!! Can you lend me a hand?
regards
kelly
Hi Kelly,
Sure - if you want to send me your existing categories.php and html/atoz.php i'll quickly add this for you - but will probably involve moving the HTML code into the main script rather than using the existing html/atoz.php.
Can you confirm that by using category2 as the main category; you also need to convert the script to create the master index based on category2 with the sub-category names linked to search.php as normal (using category:xxxxxx)?
Cheers,
David.
Hi David
I would like to have columns in my category page. Bu my html/atoz.php does not have that line on line 3.
How would I change this.
Thank You
Dean
Hi Brent,
Yes, you can control the number of columns. On line 3 of html/atoz.php simply change:
$columns = 1;
..as required!
Cheers,
David.