Jamie
October 27th, 2004, 08:52 PM
In version 1.5.0, you can display sub categories below the category detail in as many columns as you like. We will be adding support in the future to do the same for categories at the top level. If you need to accomplish this before the next release (1.6?) then follow the steps below:
1. Please make sure you know how to modify template files. It is explained in the documentation: http://www.squirrelcart.com/help. Do not modify these template files directly inside the squirrelcart/themes/squirrelcart folder! That would be very very bad! :eek:
2. Add the following to the bottom of the "show_categories_header.php" template:
<table><tr>
3. Add the following to the top of "show_category_detail.php"
<td valign="top">
4. Replace the contents of "show_category_detail_seperator.php" (yes, we know "seperator" is misspelled! :rolleyes: )
<?php
// workaround to put categories in columns
// set the variable below to the number of categories you want per row
$cats_per_row = 2;
// if counter not set, start it at one
if (!$GLOBALS['cat_count']) $GLOBALS['cat_count'] = 1;
// close the category that was just shown
print '</td>';
// if the cats per row has been met, reset the counter, and close out the row
if ($GLOBALS['cat_count'] == $cats_per_row) {
$GLOBALS['cat_count'] = 1;
print "</tr><tr>";
} else {
// increment the counter
$GLOBALS['cat_count']++;
}
?>Change the number to the right of $cats_per_row to the number of columns you want.
5. Replace the contents of the "show_categories_footer.php" template with the following:
<!--
Template file: show_categories_footer
This file controls the appearance of the bottom of the Category Detail section in home.php
-->
<?php
print '</td>'; // close out the last category shown
// code to close out any left over table cells
while($GLOBALS['cat_count'] < $cats_per_row) {
print '<td></td>';
$GLOBALS['cat_count']++;
}
print '</tr></table>';
?>
THE END
-Jamie
1. Please make sure you know how to modify template files. It is explained in the documentation: http://www.squirrelcart.com/help. Do not modify these template files directly inside the squirrelcart/themes/squirrelcart folder! That would be very very bad! :eek:
2. Add the following to the bottom of the "show_categories_header.php" template:
<table><tr>
3. Add the following to the top of "show_category_detail.php"
<td valign="top">
4. Replace the contents of "show_category_detail_seperator.php" (yes, we know "seperator" is misspelled! :rolleyes: )
<?php
// workaround to put categories in columns
// set the variable below to the number of categories you want per row
$cats_per_row = 2;
// if counter not set, start it at one
if (!$GLOBALS['cat_count']) $GLOBALS['cat_count'] = 1;
// close the category that was just shown
print '</td>';
// if the cats per row has been met, reset the counter, and close out the row
if ($GLOBALS['cat_count'] == $cats_per_row) {
$GLOBALS['cat_count'] = 1;
print "</tr><tr>";
} else {
// increment the counter
$GLOBALS['cat_count']++;
}
?>Change the number to the right of $cats_per_row to the number of columns you want.
5. Replace the contents of the "show_categories_footer.php" template with the following:
<!--
Template file: show_categories_footer
This file controls the appearance of the bottom of the Category Detail section in home.php
-->
<?php
print '</td>'; // close out the last category shown
// code to close out any left over table cells
while($GLOBALS['cat_count'] < $cats_per_row) {
print '<td></td>';
$GLOBALS['cat_count']++;
}
print '</tr></table>';
?>
THE END
-Jamie