-
Displaying all products and new products listing in column/grid
I was in search for displaying all products listing and new products listing in column/grid layout instead of the default row layout.. I searched in this forum a lot.. could not found any appropriate solution to this problem.. a suggestion was to change/modify the code.. Hence, I have done it.
PS: Currently i am using 4 columns per row. If you want to change the column option per row then you have to modify the following line in the code above:
PHP Code:
if(($row_counter-1)%4 == 0)
change the number 4 to your desired row number. :smile: This is a bit hard coding, but i will definitely try to find a better solution. :yes:
zen cart is not allowing me to post so long text/chars.. so i am posting the code in reply to this post :D
"The text that you have entered is too long (23785 characters). Please shorten it to 23000 characters long."
-
Re: Solution: Displaying all products and new products listing in column/grid
For all products listing, you have to modify the following file:
includes/templates/YOUR_TEMPLATE/templates/tpl_modules_products_all_listing.php
if your template is using default folder then it would be:
includes/templates/template_default/templates/tpl_modules_products_all_listing.php
The modified code is as below: (I have copied the whole file code.. it's up to you to compare this modified one and the old one :cool:)
PHP Code:
<?php
/**
* Module Template
*
* Loaded automatically by index.php?main_page=products_all.<br />
* Displays listing of All Products
*
* @package templateSystem
* @copyright Copyright 2003-2006 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: tpl_modules_products_all_listing.php 4629 2006-09-28 15:29:18Z ajeh $
*/
?>
<table border="0" width="100%" cellspacing="2" cellpadding="2">
<tr>
<td colspan="3"><hr /></td>
</tr>
<tr class="<?php echo ((int)($row_counter/2)==($row_counter/2)) ? 'productListing-even' : 'productListing-odd'; ?>">
<?php
$group_id = zen_get_configuration_key_value('PRODUCT_ALL_LIST_GROUP_ID');
if ($products_all_split->number_of_rows > 0) {
$products_all = $db->Execute($products_all_split->sql_query);
$row_counter = 0;
while (!$products_all->EOF) {
$row_counter++;
if (PRODUCT_ALL_LIST_IMAGE != '0') {
if ($products_all->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) {
$display_products_image = str_repeat('<br clear="all" />', substr(PRODUCT_ALL_LIST_IMAGE, 3, 1));
} else {
$display_products_image = '<a href="' . zen_href_link(zen_get_info_page($products_all->fields['products_id']), 'products_id=' . $products_all->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $products_all->fields['products_image'], $products_all->fields['products_name'], IMAGE_PRODUCT_ALL_LISTING_WIDTH, IMAGE_PRODUCT_ALL_LISTING_HEIGHT) . '</a>' . str_repeat('<br clear="all" />', substr(PRODUCT_ALL_LIST_IMAGE, 3, 1));
}
} else {
$display_products_image = '';
}
if (PRODUCT_ALL_LIST_NAME != '0') {
$display_products_name = '<a href="' . zen_href_link(zen_get_info_page($products_all->fields['products_id']), 'products_id=' . $products_all->fields['products_id']) . '"><strong>' . $products_all->fields['products_name'] . '</strong></a>' . str_repeat('<br clear="all" />', substr(PRODUCT_ALL_LIST_NAME, 3, 1));
} else {
$display_products_name = '';
}
if (PRODUCT_ALL_LIST_MODEL != '0' and zen_get_show_product_switch($products_all->fields['products_id'], 'model')) {
$display_products_model = TEXT_PRODUCTS_MODEL . $products_all->fields['products_model'] . str_repeat('<br clear="all" />', substr(PRODUCT_ALL_LIST_MODEL, 3, 1));
} else {
$display_products_model = '';
}
if (PRODUCT_ALL_LIST_WEIGHT != '0' and zen_get_show_product_switch($products_all->fields['products_id'], 'weight')) {
$display_products_weight = TEXT_PRODUCTS_WEIGHT . $products_all->fields['products_weight'] . TEXT_SHIPPING_WEIGHT . str_repeat('<br clear="all" />', substr(PRODUCT_ALL_LIST_WEIGHT, 3, 1));
} else {
$display_products_weight = '';
}
if (PRODUCT_ALL_LIST_QUANTITY != '0' and zen_get_show_product_switch($products_all->fields['products_id'], 'quantity')) {
if ($products_all->fields['products_quantity'] <= 0) {
$display_products_quantity = TEXT_OUT_OF_STOCK . str_repeat('<br clear="all" />', substr(PRODUCT_ALL_LIST_QUANTITY, 3, 1));
} else {
$display_products_quantity = TEXT_PRODUCTS_QUANTITY . $products_all->fields['products_quantity'] . str_repeat('<br clear="all" />', substr(PRODUCT_ALL_LIST_QUANTITY, 3, 1));
}
} else {
$display_products_quantity = '';
}
if (PRODUCT_ALL_LIST_DATE_ADDED != '0' and zen_get_show_product_switch($products_all->fields['products_id'], 'date_added')) {
$display_products_date_added = TEXT_DATE_ADDED . ' ' . zen_date_long($products_all->fields['products_date_added']) . str_repeat('<br clear="all" />', substr(PRODUCT_ALL_LIST_DATE_ADDED, 3, 1));
} else {
$display_products_date_added = '';
}
if (PRODUCT_ALL_LIST_MANUFACTURER != '0' and zen_get_show_product_switch($products_all->fields['products_id'], 'manufacturer')) {
$display_products_manufacturers_name = ($products_all->fields['manufacturers_name'] != '' ? TEXT_MANUFACTURER . ' ' . $products_all->fields['manufacturers_name'] . str_repeat('<br clear="all" />', substr(PRODUCT_ALL_LIST_MANUFACTURER, 3, 1)) : '');
} else {
$display_products_manufacturers_name = '';
}
if ((PRODUCT_ALL_LIST_PRICE != '0' and zen_get_products_allow_add_to_cart($products_all->fields['products_id']) == 'Y') and zen_check_show_prices() == true) {
$products_price = zen_get_products_display_price($products_all->fields['products_id']);
$display_products_price = TEXT_PRICE . ' ' . $products_price . str_repeat('<br clear="all" />', substr(PRODUCT_ALL_LIST_PRICE, 3, 1)) . (zen_get_show_product_switch($products_all->fields['products_id'], 'ALWAYS_FREE_SHIPPING_IMAGE_SWITCH') ? (zen_get_product_is_always_free_shipping($products_all->fields['products_id']) ? TEXT_PRODUCT_FREE_SHIPPING_ICON . '<br />' : '') : '');
} else {
$display_products_price = '';
}
// more info in place of buy now
if (PRODUCT_ALL_BUY_NOW != '0' and zen_get_products_allow_add_to_cart($products_all->fields['products_id']) == 'Y') {
if (zen_has_product_attributes($products_all->fields['products_id'])) {
$link = '<a href="' . zen_href_link(zen_get_info_page($products_all->fields['products_id']), 'products_id=' . $products_all->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
} else {
// $link= '<a href="' . zen_href_link(FILENAME_PRODUCTS_ALL, zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $products_all->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT) . '</a>';
if (PRODUCT_ALL_LISTING_MULTIPLE_ADD_TO_CART > 0 && $products_all->fields['products_qty_box_status'] != 0) {
// $how_many++;
$link = TEXT_PRODUCT_ALL_LISTING_MULTIPLE_ADD_TO_CART . "<input type=\"text\" name=\"products_id[" . $products_all->fields['products_id'] . "]\" value=\"0\" size=\"4\" />";
} else {
$link = '<a href="' . zen_href_link(FILENAME_PRODUCTS_ALL, zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $products_all->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_BUY_NOW, BUTTON_BUY_NOW_ALT) . '</a> ';
}
}
$the_button = $link;
$products_link = '<a href="' . zen_href_link(zen_get_info_page($products_all->fields['products_id']), 'products_id=' . $products_all->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
$display_products_button = zen_get_buy_now_button($products_all->fields['products_id'], $the_button, $products_link) . '<br />' . zen_get_products_quantity_min_units_display($products_all->fields['products_id']) . str_repeat('<br clear="all" />', substr(PRODUCT_ALL_BUY_NOW, 3, 1));
} else {
$link = '<a href="' . zen_href_link(zen_get_info_page($products_all->fields['products_id']), 'products_id=' . $products_all->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
$the_button = $link;
$products_link = '<a href="' . zen_href_link(zen_get_info_page($products_all->fields['products_id']), 'products_id=' . $products_all->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
$display_products_button = zen_get_buy_now_button($products_all->fields['products_id'], $the_button, $products_link) . '<br />' . zen_get_products_quantity_min_units_display($products_all->fields['products_id']) . str_repeat('<br clear="all" />', substr(PRODUCT_ALL_BUY_NOW, 3, 1));
}
if (PRODUCT_ALL_LIST_DESCRIPTION != '0') {
$disp_text = zen_get_products_description($products_all->fields['products_id']);
$disp_text = zen_clean_html($disp_text);
$display_products_description = stripslashes(zen_trunc_string($disp_text, 150, '<a href="' . zen_href_link(zen_get_info_page($products_all->fields['products_id']), 'products_id=' . $products_all->fields['products_id']) . '"> ' . MORE_INFO_TEXT . '</a>'));
} else {
$display_products_description = '';
}
?>
<?php
if(($row_counter-1)%4 == 0)
{
?>
<tr>
<?php
}
?>
<td width="<?php echo IMAGE_PRODUCT_ALL_LISTING_WIDTH + 10; ?>" valign="top" class="main" align="center">
<?php
$disp_sort_order = $db->Execute("select configuration_key, configuration_value from " . TABLE_CONFIGURATION . " where configuration_group_id='" . $group_id . "' and (configuration_value >= 1000 and configuration_value <= 1999) order by LPAD(configuration_value,11,0)");
while (!$disp_sort_order->EOF) {
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_ALL_LIST_IMAGE') {
echo $display_products_image;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_ALL_BUY_NOW') {
echo $display_products_button;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_ALL_LIST_NAME') {
echo $display_products_name;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_ALL_LIST_PRICE') {
echo $display_products_price;
}
$disp_sort_order->MoveNext();
}
$disp_sort_order = $db->Execute("select configuration_key, configuration_value from " . TABLE_CONFIGURATION . " where configuration_group_id='" . $group_id . "' and (configuration_value >= 2000 and configuration_value <= 2999) order by LPAD(configuration_value,11,0)");
while (!$disp_sort_order->EOF) {
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_ALL_LIST_IMAGE') {
echo $display_products_image;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_ALL_BUY_NOW') {
echo $display_products_button;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_ALL_LIST_NAME') {
echo $display_products_name;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_ALL_LIST_PRICE') {
echo $display_products_price;
}
$disp_sort_order->MoveNext();
}
?>
</td>
<?php
$products_all->MoveNext();
}
} else {
?>
<tr>
<td class="main" colspan="2"><?php echo TEXT_NO_ALL_PRODUCTS; ?></td>
</tr>
<?php
}
?>
</tr>
</table>
-
Re: Solution: Displaying all products and new products listing in column/grid
For new products listing, you have to modify the following file:
includes/templates/YOUR_TEMPLATE/templates/tpl_modules_products_new_listing.php
if your template is using default folder then it would be:
includes/templates/template_default/templates/tpl_modules_products_new_listing.php
The modified code is as below: (I have copied the whole file code.. it's up to you to compare this modified one and the old one :cool:)
PHP Code:
<?php
/**
* Module Template
*
* Loaded automatically by index.php?main_page=products_new.<br />
* Displays listing of New Products
*
* @package templateSystem
* @copyright Copyright 2003-2005 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: tpl_modules_products_new_listing.php 4629 2006-09-28 15:29:18Z ajeh $
*/
?>
<table border="0" width="100%" cellspacing="2" cellpadding="2">
<tr>
<td colspan="3"><hr /></td>
</tr>
<tr>
<?php
$group_id = zen_get_configuration_key_value('PRODUCT_NEW_LIST_GROUP_ID');
if ($products_new_split->number_of_rows > 0) {
$products_new = $db->Execute($products_new_split->sql_query);
$row_counter = 0;
while (!$products_new->EOF) {
$row_counter++;
if (PRODUCT_NEW_LIST_IMAGE != '0') {
if ($products_new->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) {
$display_products_image = str_repeat('<br clear="all" />', substr(PRODUCT_NEW_LIST_IMAGE, 3, 1));
} else {
$display_products_image = '<a href="' . zen_href_link(zen_get_info_page($products_new->fields['products_id']), 'products_id=' . $products_new->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $products_new->fields['products_image'], $products_new->fields['products_name'], IMAGE_PRODUCT_NEW_LISTING_WIDTH, IMAGE_PRODUCT_NEW_LISTING_HEIGHT) . '</a>' . str_repeat('<br clear="all" />', substr(PRODUCT_NEW_LIST_IMAGE, 3, 1));
}
} else {
$display_products_image = '';
}
if (PRODUCT_NEW_LIST_NAME != '0') {
$display_products_name = '<a href="' . zen_href_link(zen_get_info_page($products_new->fields['products_id']), 'products_id=' . $products_new->fields['products_id']) . '"><strong>' . $products_new->fields['products_name'] . '</strong></a>' . str_repeat('<br clear="all" />', substr(PRODUCT_NEW_LIST_NAME, 3, 1));
} else {
$display_products_name = '';
}
if (PRODUCT_NEW_LIST_MODEL != '0' and zen_get_show_product_switch($products_new->fields['products_id'], 'model')) {
$display_products_model = TEXT_PRODUCTS_MODEL . $products_new->fields['products_model'] . str_repeat('<br clear="all" />', substr(PRODUCT_NEW_LIST_MODEL, 3, 1));
} else {
$display_products_model = '';
}
if (PRODUCT_NEW_LIST_WEIGHT != '0' and zen_get_show_product_switch($products_new->fields['products_id'], 'weight')) {
$display_products_weight = '<br />' . TEXT_PRODUCTS_WEIGHT . $products_new->fields['products_weight'] . TEXT_SHIPPING_WEIGHT . str_repeat('<br clear="all" />', substr(PRODUCT_NEW_LIST_WEIGHT, 3, 1));
} else {
$display_products_weight = '';
}
if (PRODUCT_NEW_LIST_QUANTITY != '0' and zen_get_show_product_switch($products_new->fields['products_id'], 'quantity')) {
if ($products_new->fields['products_quantity'] <= 0) {
$display_products_quantity = TEXT_OUT_OF_STOCK . str_repeat('<br clear="all" />', substr(PRODUCT_NEW_LIST_QUANTITY, 3, 1));
} else {
$display_products_quantity = TEXT_PRODUCTS_QUANTITY . $products_new->fields['products_quantity'] . str_repeat('<br clear="all" />', substr(PRODUCT_NEW_LIST_QUANTITY, 3, 1));
}
} else {
$display_products_quantity = '';
}
if (PRODUCT_NEW_LIST_DATE_ADDED != '0' and zen_get_show_product_switch($products_new->fields['products_id'], 'date_added')) {
$display_products_date_added = TEXT_DATE_ADDED . ' ' . zen_date_long($products_new->fields['products_date_added']) . str_repeat('<br clear="all" />', substr(PRODUCT_NEW_LIST_DATE_ADDED, 3, 1));
} else {
$display_products_date_added = '';
}
if (PRODUCT_NEW_LIST_MANUFACTURER != '0' and zen_get_show_product_switch($products_new->fields['products_id'], 'manufacturer')) {
$display_products_manufacturers_name = ($products_new->fields['manufacturers_name'] != '' ? TEXT_MANUFACTURER . ' ' . $products_new->fields['manufacturers_name'] . str_repeat('<br clear="all" />', substr(PRODUCT_NEW_LIST_MANUFACTURER, 3, 1)) : '');
} else {
$display_products_manufacturers_name = '';
}
if ((PRODUCT_NEW_LIST_PRICE != '0' and zen_get_products_allow_add_to_cart($products_new->fields['products_id']) == 'Y') and zen_check_show_prices() == true) {
$products_price = zen_get_products_display_price($products_new->fields['products_id']);
$display_products_price = TEXT_PRICE . ' ' . $products_price . str_repeat('<br clear="all" />', substr(PRODUCT_NEW_LIST_PRICE, 3, 1)) . (zen_get_show_product_switch($products_new->fields['products_id'], 'ALWAYS_FREE_SHIPPING_IMAGE_SWITCH') ? (zen_get_product_is_always_free_shipping($products_new->fields['products_id']) ? TEXT_PRODUCT_FREE_SHIPPING_ICON . '<br />' : '') : '');
} else {
$display_products_price = '';
}
// more info in place of buy now
if (PRODUCT_NEW_BUY_NOW != '0' and zen_get_products_allow_add_to_cart($products_new->fields['products_id']) == 'Y') {
if (zen_has_product_attributes($products_new->fields['products_id'])) {
$link = '<a href="' . zen_href_link(zen_get_info_page($products_new->fields['products_id']), 'products_id=' . $products_new->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
} else {
// $link= '<a href="' . zen_href_link(FILENAME_PRODUCTS_NEW, zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $products_new->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT) . '</a>';
if (PRODUCT_NEW_LISTING_MULTIPLE_ADD_TO_CART > 0 && $products_new->fields['products_qty_box_status'] != 0) {
// $how_many++;
$link = TEXT_PRODUCT_NEW_LISTING_MULTIPLE_ADD_TO_CART . "<input type=\"text\" name=\"products_id[" . $products_new->fields['products_id'] . "]\" value=\"0\" size=\"4\" />";
} else {
$link = '<a href="' . zen_href_link(FILENAME_PRODUCTS_NEW, zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $products_new->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_BUY_NOW, BUTTON_BUY_NOW_ALT) . '</a> ';
}
}
$the_button = $link;
$products_link = '<a href="' . zen_href_link(zen_get_info_page($products_new->fields['products_id']), 'products_id=' . $products_new->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
$display_products_button = zen_get_buy_now_button($products_new->fields['products_id'], $the_button, $products_link) . '<br />' . zen_get_products_quantity_min_units_display($products_new->fields['products_id']) . str_repeat('<br clear="all" />', substr(PRODUCT_NEW_BUY_NOW, 3, 1));
} else {
$link = '<a href="' . zen_href_link(zen_get_info_page($products_new->fields['products_id']), 'products_id=' . $products_new->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
$the_button = $link;
$products_link = '<a href="' . zen_href_link(zen_get_info_page($products_new->fields['products_id']), 'products_id=' . $products_new->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
$display_products_button = zen_get_buy_now_button($products_new->fields['products_id'], $the_button, $products_link) . '<br />' . zen_get_products_quantity_min_units_display($products_new->fields['products_id']) . str_repeat('<br clear="all" />', substr(PRODUCT_NEW_BUY_NOW, 3, 1));
}
if (PRODUCT_NEW_LIST_DESCRIPTION != '0') {
$disp_text = zen_get_products_description($products_new->fields['products_id']);
$disp_text = zen_clean_html($disp_text);
$display_products_description = stripslashes(zen_trunc_string($disp_text, 150, '<a href="' . zen_href_link(zen_get_info_page($products_new->fields['products_id']), 'products_id=' . $products_new->fields['products_id']) . '"> ' . MORE_INFO_TEXT . '</a>'));
} else {
$display_products_description = '';
}
?>
<?php
if(($row_counter-1)%4 == 0)
{
?>
<tr>
<?php
}
?>
<td width="<?php echo IMAGE_PRODUCT_NEW_LISTING_WIDTH + 10; ?>" valign="top" class="main" align="center">
<?php
$disp_sort_order = $db->Execute("select configuration_key, configuration_value from " . TABLE_CONFIGURATION . " where configuration_group_id='" . $group_id . "' and (configuration_value >= 1000 and configuration_value <= 1999) order by LPAD(configuration_value,11,0)");
while (!$disp_sort_order->EOF) {
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_NEW_LIST_IMAGE') {
echo $display_products_image;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_NEW_LIST_NAME') {
echo $display_products_name;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_NEW_LIST_PRICE') {
echo $display_products_price;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_NEW_BUY_NOW') {
echo $display_products_button;
}
$disp_sort_order->MoveNext();
}
$disp_sort_order = $db->Execute("select configuration_key, configuration_value from " . TABLE_CONFIGURATION . " where configuration_group_id='" . $group_id . "' and (configuration_value >= 2000 and configuration_value <= 2999) order by LPAD(configuration_value,11,0)");
while (!$disp_sort_order->EOF) {
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_NEW_LIST_IMAGE') {
echo $display_products_image;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_NEW_LIST_NAME') {
echo $display_products_name;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_NEW_LIST_PRICE') {
echo $display_products_price;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_NEW_BUY_NOW') {
echo $display_products_button;
}
$disp_sort_order->MoveNext();
}
?>
</td>
<?php
$products_new->MoveNext();
}
} else {
?>
<tr>
<td class="main" colspan="2"><?php echo TEXT_NO_NEW_PRODUCTS; ?></td>
</tr>
<?php
}
?>
</tr>
</table>
PS: You can make a backup of your files and copy these files to your zen cart folder. Have a try. Implement it. Hope you will find the solution.
:cool: Happy phping! Happy zening!
-
Re: Solution: Displaying all products and new products listing in column/grid
The logic implemented in the above code is as below:
PHP Code:
<html>
<body>
<table border=1>
<tr>
<?php
$k=0;
while ($k<9)
{
$k++;
?>
<?php
if(($k-1)%3 == 0) // starting a new row after 3 columns
{
?>
<tr>
<?php
} // end of if
?>
<td>
<?php
echo " $k "; // printing the number in each column cell
?>
</td>
<?php
} // end of while
?>
</tr>
</table>
</body>
</html>
-
Re: Solution: Displaying all products and new products listing in column/grid
Wonderful!! A great contibution, surely will help many folks including me.
-
Re: Solution: Displaying all products and new products listing in column/grid
AWESOME AWESOME AWESOME!!!!
You du man:clap:
-
Re: Solution: Displaying all products and new products listing in column/grid
-
Re: Solution: Displaying all products and new products listing in column/grid
-
Re: Solution: Displaying all products and new products listing in column/grid
I like this solution because you don't have to modifiy the database and it's just modifying the override files.
I'm wondering if this code is still good for version 1.3.8a ?
-
Re: Solution: Displaying all products and new products listing in column/grid
I am not good with php, but your coding worked great on those two pages. Can you post the proper coding for the featured products page as well? And how do I get the category pages to show up in columnar format?
-
Re: Solution: Displaying all products and new products listing in column/grid
The category/subcategory listing should already show in a grid (defaults to 3 per row). If they only display one per row, you have probably made a stylesheet change that had wider effect than you intended (eliminating a float: left;).
Post a link to see your site live so we can advise correctly.
-
Re: Solution: Displaying all products and new products listing in column/grid
I do hate posting in a thread that was originally created in 2007, but I don’t see the use of creating another thread.
So basically, what I would like is if someone can post the code for how to change the featured products page. I'm not lazy. I have tried! But I must obviously be missing something if nothing is appearing on the page.
Once again, I'm really sorry!
HTML Code:
<?php
/**
* Module Template
*
* Loaded automatically by index.php?main_page=featured_products.<br />
* Displays listing of Featured Products
*
* @package templateSystem
* @copyright Copyright 2003-2007 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: tpl_modules_products_featured_listing.php 6096 2007-04-01 00:43:21Z ajeh $
*/
?>
<table border="0" width="100%" cellspacing="2" cellpadding="2">
<tr>
<td colspan="3"><hr /></td>
</tr>
<?php
$group_id = zen_get_configuration_key_value('PRODUCT_FEATURED_LIST_GROUP_ID');
if ($featured_products_split->number_of_rows > 0) {
$featured_products = $db->Execute($featured_products_split->sql_query);
$row_counter = 0;
while (!$featured_products->EOF) {
$row_counter++;
if (PRODUCT_FEATURED_LIST_IMAGE != '0') {
if ($featured_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) {
$display_products_image = str_repeat('<br clear="all" />', substr(PRODUCT_FEATURED_LIST_IMAGE, 3, 1));
} else {
$display_products_image = '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'products_id=' . $featured_products->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $featured_products->fields['products_image'], $featured_products->fields['products_name'], IMAGE_FEATURED_PRODUCTS_LISTING_WIDTH, IMAGE_FEATURED_PRODUCTS_LISTING_HEIGHT) . '</a>' . str_repeat('<br clear="all" />', substr(PRODUCT_FEATURED_LIST_IMAGE, 3, 1));
}
} else {
$display_products_image = '';
}
if (PRODUCT_FEATURED_LIST_NAME != '0') {
$display_products_name = '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'products_id=' . $featured_products->fields['products_id']) . '"><strong>' . $featured_products->fields['products_name'] . '</strong></a>' . str_repeat('<br clear="all" />', substr(PRODUCT_FEATURED_LIST_NAME, 3, 1));
} else {
$display_products_name = '';
}
if (PRODUCT_FEATURED_LIST_MODEL != '0' and zen_get_show_product_switch($featured_products->fields['products_id'], 'model')) {
$display_products_model = TEXT_PRODUCTS_MODEL . $featured_products->fields['products_model'] . str_repeat('<br clear="all" />', substr(PRODUCT_FEATURED_LIST_MODEL, 3, 1));
} else {
$display_products_model = '';
}
if (PRODUCT_FEATURED_LIST_WEIGHT != '0' and zen_get_show_product_switch($featured_products->fields['products_id'], 'weight')) {
$display_products_weight = TEXT_PRODUCTS_WEIGHT . $featured_products->fields['products_weight'] . TEXT_SHIPPING_WEIGHT . str_repeat('<br clear="all" />', substr(PRODUCT_FEATURED_LIST_WEIGHT, 3, 1));
} else {
$display_products_weight = '';
}
if (PRODUCT_FEATURED_LIST_QUANTITY != '0' and zen_get_show_product_switch($featured_products->fields['products_id'], 'quantity')) {
if ($featured_products->fields['products_quantity'] <= 0) {
$display_products_quantity = TEXT_OUT_OF_STOCK . str_repeat('<br clear="all" />', substr(PRODUCT_FEATURED_LIST_QUANTITY, 3, 1));
} else {
$display_products_quantity = TEXT_PRODUCTS_QUANTITY . $featured_products->fields['products_quantity'] . str_repeat('<br clear="all" />', substr(PRODUCT_FEATURED_LIST_QUANTITY, 3, 1));
}
} else {
$display_products_quantity = '';
}
if (PRODUCT_FEATURED_LIST_DATE_ADDED != '0' and zen_get_show_product_switch($featured_products->fields['products_id'], 'date_added')) {
$display_products_date_added = TEXT_DATE_ADDED . ' ' . zen_date_long($featured_products->fields['products_date_added']) . str_repeat('<br clear="all" />', substr(PRODUCT_FEATURED_LIST_DATE_ADDED, 3, 1));
} else {
$display_products_date_added = '';
}
if (PRODUCT_FEATURED_LIST_MANUFACTURER != '0' and zen_get_show_product_switch($featured_products->fields['products_id'], 'manufacturer')) {
$display_products_manufacturers_name = ($featured_products->fields['manufacturers_name'] != '' ? TEXT_MANUFACTURER . ' ' . $featured_products->fields['manufacturers_name'] . str_repeat('<br clear="all" />', substr(PRODUCT_FEATURED_LIST_MANUFACTURER, 3, 1)) : '');
} else {
$display_products_manufacturers_name = '';
}
if ((PRODUCT_FEATURED_LIST_PRICE != '0' and zen_get_products_allow_add_to_cart($featured_products->fields['products_id']) == 'Y') and zen_check_show_prices() == true) {
$products_price = zen_get_products_display_price($featured_products->fields['products_id']);
$display_products_price = TEXT_PRICE . ' ' . $products_price . str_repeat('<br clear="all" />', substr(PRODUCT_FEATURED_LIST_PRICE, 3, 1)) . (zen_get_show_product_switch($featured_products->fields['products_id'], 'ALWAYS_FREE_SHIPPING_IMAGE_SWITCH') ? (zen_get_product_is_always_free_shipping($featured_products->fields['products_id']) ? TEXT_PRODUCT_FREE_SHIPPING_ICON . '<br />' : '') : '');
} else {
$display_products_price = '';
}
// more info in place of buy now
if (PRODUCT_FEATURED_BUY_NOW != '0' and zen_get_products_allow_add_to_cart($featured_products->fields['products_id']) == 'Y') {
if (zen_has_product_attributes($featured_products->fields['products_id'])) {
$link = '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'products_id=' . $featured_products->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
} else {
// $link= '<a href="' . zen_href_link(FILENAME_FEATURED_PRODUCTS, zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $featured_products->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT) . '</a>';
if (PRODUCT_FEATURED_LISTING_MULTIPLE_ADD_TO_CART > 0 && $featured_products->fields['products_qty_box_status'] != 0) {
// $how_many++;
$link = TEXT_PRODUCT_FEATURED_LISTING_MULTIPLE_ADD_TO_CART . "<input type=\"text\" name=\"products_id[" . $featured_products->fields['products_id'] . "]\" value=\"0\" size=\"4\" />";
} else {
$link = '<a href="' . zen_href_link(FILENAME_FEATURED_PRODUCTS, zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $featured_products->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_BUY_NOW, BUTTON_BUY_NOW_ALT) . '</a> ';
}
}
$the_button = $link;
$products_link = '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'products_id=' . $featured_products->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
$display_products_button = zen_get_buy_now_button($featured_products->fields['products_id'], $the_button, $products_link) . '<br />' . zen_get_products_quantity_min_units_display($featured_products->fields['products_id']) . str_repeat('<br clear="all" />', substr(PRODUCT_FEATURED_BUY_NOW, 3, 1));
} else {
$link = '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'products_id=' . $featured_products->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
$the_button = $link;
$products_link = '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'products_id=' . $featured_products->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
$display_products_button = zen_get_buy_now_button($featured_products->fields['products_id'], $the_button, $products_link) . '<br />' . zen_get_products_quantity_min_units_display($featured_products->fields['products_id']) . str_repeat('<br clear="all" />', substr(PRODUCT_FEATURED_BUY_NOW, 3, 1));
}
if (PRODUCT_FEATURED_LIST_DESCRIPTION != '0') {
$disp_text = zen_get_products_description($featured_products->fields['products_id']);
$disp_text = zen_clean_html($disp_text);
$display_products_description = stripslashes(zen_trunc_string($disp_text, 150, '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), ‘products_id=' . $featured_products->fields['products_id']) . '"> ' . MORE_INFO_TEXT . '</a>'));
} else {
$display_products_description = '';
}
?>
<?php
if(($row_counter-1)%4 == 0)
{
?>
<tr>
<?php
}
?>
<td width="<?php echo IMAGE_FEATURED_PRODUCTS_LISTING_WIDTH + 10; ?>" valign="top" class="main" align="center">
<?php
$disp_sort_order = $db->Execute("select configuration_key, configuration_value from " . TABLE_CONFIGURATION . " where configuration_group_id='" . $group_id . "' and (configuration_value >= 1000 and configuration_value <= 1999) order by LPAD(configuration_value,11,0)");
while (!$disp_sort_order->EOF) {
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_FEATURED_LIST_IMAGE') {
echo $display_products_image;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_FEATURED_BUY_NOW') {
echo $display_products_button;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_FEATURED_LIST_NAME') {
echo $display_products_name;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_FEATURED_LIST_PRICE') {
echo $display_products_price;
}
$disp_sort_order->MoveNext();
}
$disp_sort_order = $db->Execute("select configuration_key, configuration_value from " . TABLE_CONFIGURATION . " where configuration_group_id='" . $group_id . "' and (configuration_value >= 2000 and configuration_value <= 2999) order by LPAD(configuration_value,11,0)");
while (!$disp_sort_order->EOF) {
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_FEATURED_LIST_IMAGE') {
echo $display_products_image;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_FEATURED_BUY_NOW') {
echo $display_products_button;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_FEATURED_LIST_NAME') {
echo $display_products_name;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_FEATURED_LIST_PRICE') {
echo $display_products_price;
}
$disp_sort_order->MoveNext();
}
?>
</td>
</tr>
<?php
$featured_products->MoveNext();
}
} else {
?>
<tr>
<td class="main" colspan="2"><?php echo TEXT_NO_FEATURED_PRODUCTS; ?></td>
</tr>
<?php
}
?>
</table>
-
Re: Solution: Displaying all products and new products listing in column/grid
In addition to this (sorry for adding more)
but I was curious if someone could tell me how I can change the order the different product details are displayed in. I would like the name of the product to show first, then the image, then the cost and finally the add. Also, how would I remove max:50?
I'm attaching a image to explain what I am talking about. I'm sorry but I cannot attach a link because I'm currently using xampp.
Sorry (yet again) for my complete lack of knowledge!
~ Gosh, I said sorry a billion time in this post!
http://i150.photobucket.com/albums/s...D-S-A/Help.png
-
Re: Solution: Displaying all products and new products listing in column/grid
A little harmless bump :smile:
-
Re: Solution: Displaying all products and new products listing in column/grid
I like this solution, I was going to try on my custom template. before I do that I do have a question, My "All Products" and "New Products" are now " New Designs" and "View All Designs", will these code work for new names? are there any locations that I need to modify to match my namings?
Thanks
-
Re: Solution: Displaying all products and new products listing in column/grid
If you have done the renaming correctly by editing a define file, it will make no difference to the code function.
Note that this mod will not show the description at all, whether you have set it to display or not. You can fix this by adding a line in the middle of the main new code section. This code is poorly adapted as is, with unnecessary duplication, but if you want to display the description in a place of your choosing, the duplication becomes necessary.
Original mod:
PHP Code:
//...
if (PRODUCT_ALL_LIST_DESCRIPTION != '0') {
$disp_text = zen_get_products_description($products_all->fields['products_id']);
$disp_text = zen_clean_html($disp_text);
$display_products_description = stripslashes(zen_trunc_string($disp_text, 150, '<a href="' . zen_href_link(zen_get_info_page($products_all->fields['products_id']), 'products_id=' . $products_all->fields['products_id']) . '"> ' . MORE_INFO_TEXT . '</a>'));
} else {
$display_products_description = '';
}
?>
<?php
if(($row_counter-1)%4 == 0)
{
?>
<tr>
<?php
}
?>
<td width="<?php echo IMAGE_PRODUCT_ALL_LISTING_WIDTH + 10; ?>" valign="top" class="main" align="center">
<?php
$disp_sort_order = $db->Execute("select configuration_key, configuration_value from " . TABLE_CONFIGURATION . " where configuration_group_id='" . $group_id . "' and (configuration_value >= 1000 and configuration_value <= 1999) order by LPAD(configuration_value,11,0)");
while (!$disp_sort_order->EOF) {
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_ALL_LIST_IMAGE') {
echo $display_products_image;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_ALL_BUY_NOW') {
echo $display_products_button;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_ALL_LIST_NAME') {
echo $display_products_name;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_ALL_LIST_PRICE') {
echo $display_products_price;
}
$disp_sort_order->MoveNext();
}
$disp_sort_order = $db->Execute("select configuration_key, configuration_value from " . TABLE_CONFIGURATION . " where configuration_group_id='" . $group_id . "' and (configuration_value >= 2000 and configuration_value <= 2999) order by LPAD(configuration_value,11,0)");
while (!$disp_sort_order->EOF) {
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_ALL_LIST_IMAGE') {
echo $display_products_image;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_ALL_BUY_NOW') {
echo $display_products_button;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_ALL_LIST_NAME') {
echo $display_products_name;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_ALL_LIST_PRICE') {
echo $display_products_price;
}
$disp_sort_order->MoveNext();
}
?>
</td>
<?php
$products_all->MoveNext();
}
} else {
?>
<tr>
<td class="main" colspan="2"><?php echo TEXT_NO_ALL_PRODUCTS; ?></td>
</tr>
<?php
}
?>
</tr>
</table>
Add a line
echo $display_products_description . '<br />';
Remove the hard-coded styling from the table cell, as this is better controlled in the stylesheet.
width="<?php echo IMAGE_PRODUCT_ALL_LISTING_WIDTH + 10; ?>" valign="top" ... align="center"
The more I look at this the more logic errors I find...
The row logic is set to make rows of four products
if(($row_counter-1)%4 == 0)
but the old row is never closed when the new one is started.
The first row is given the odd/even classname, but subsequent rows have no classname (the odd/even logic is out of the loop).
The odd/even logic is based on two alternating products, and will not work correctly for other numbers even if it is moved to a useful location. Of course, the whole thing is not applicable to this layout and needs to be rethought.
I have done a basic functional version of row naming.
Slightly improved version:
PHP Code:
<?php
/**
* Module Template
*
* Loaded automatically by index.php?main_page=products_all.<br />
* Displays listing of All Products
*
* @package templateSystem
* @copyright Copyright 2003-2006 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: tpl_modules_products_all_listing.php 4629 2006-09-28 15:29:18Z ajeh $
*/
?>
<table border="0" width="100%" cellspacing="2" cellpadding="2">
<tr>
<td colspan="3"><hr /></td>
</tr>
<?php
$group_id = zen_get_configuration_key_value('PRODUCT_ALL_LIST_GROUP_ID');
if ($products_all_split->number_of_rows > 0) {
$products_all = $db->Execute($products_all_split->sql_query);
$row_counter = 1;
$col_counter = 0;
while (!$products_all->EOF) {
if (PRODUCT_ALL_LIST_IMAGE != '0') {
//lots of code...
if (PRODUCT_ALL_LIST_DESCRIPTION != '0') {
$disp_text = zen_get_products_description($products_all->fields['products_id']);
$disp_text = zen_clean_html($disp_text);
$display_products_description = stripslashes(zen_trunc_string($disp_text, 150, '<a href="' . zen_href_link(zen_get_info_page($products_all->fields['products_id']), 'products_id=' . $products_all->fields['products_id']) . '"> ' . MORE_INFO_TEXT . '</a>'));
} else {
$display_products_description = '';
}
?>
<?php
if($col_counter == 3) { //start a new row - change "3" to products per row desired
$col_counter = -1;//reset column
if($row_counter > 1) {
echo '</tr>'; //close the previous <tr> for all but the first row
}
$row_counter++;//increment row
echo '<tr class="productListing-row">';
}
$col_counter++;//increment column
?>
<td class="main">
<?php
$disp_sort_order = $db->Execute("select configuration_key, configuration_value from " . TABLE_CONFIGURATION . " where configuration_group_id='" . $group_id . "' and (configuration_value >= 1000 and configuration_value <= 1999) order by LPAD(configuration_value,11,0)");
while (!$disp_sort_order->EOF) {
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_ALL_LIST_IMAGE') {
echo $display_products_image;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_ALL_BUY_NOW') {
echo $display_products_button;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_ALL_LIST_NAME') {
echo $display_products_name;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_ALL_LIST_PRICE') {
echo $display_products_price;
}
$disp_sort_order->MoveNext();
}
echo $display_products_description . '<br />'; //add product description if enabled
$disp_sort_order = $db->Execute("select configuration_key, configuration_value from " . TABLE_CONFIGURATION . " where configuration_group_id='" . $group_id . "' and (configuration_value >= 2000 and configuration_value <= 2999) order by LPAD(configuration_value,11,0)");
while (!$disp_sort_order->EOF) {
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_ALL_LIST_IMAGE') {
echo $display_products_image;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_ALL_BUY_NOW') {
echo $display_products_button;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_ALL_LIST_NAME') {
echo $display_products_name;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_ALL_LIST_PRICE') {
echo $display_products_price;
}
$disp_sort_order->MoveNext();
}
?>
</td>
<?php
$products_all->MoveNext();
}
} else {
?>
<tr>
<td class="main" colspan="2"><?php echo TEXT_NO_ALL_PRODUCTS; ?></td>
</tr>
<?php
}
?>
</tr>
</table>
Add to your stylesheet
Code:
.productListing-row .main {
vertical-align: top;
text-align: center;
}
Note: This is not tested, so might have a typo or two. if you try it, please post with results.
-
Re: Solution: Displaying all products and new products listing in column/grid
One typo - left out the initial <tr> for the first product row:
Code:
<table border="0" width="100%" cellspacing="2" cellpadding="2">
<tr>
<td colspan="3"><hr /></td>
</tr>
<tr class="productListing-row">
Forgot to mention in the previous post:
The description can be located in this layout even though there is no admin setting for description location, by putting elements to appear above it in the "left column" ("1") and elements to appear below it in the right column ("2").
-
Re: Solution: Displaying all products and new products listing in column/grid
Did everybody just overlooked Edessa question?
How do we apply this to the featured product listing page?
Thanks :clap:
-
Re: Solution: Displaying all products and new products listing in column/grid
I was comparing the template files the ones posted in 2007 as well as the ones posted in 2010, and the files seem drastically different.
For one the version from 2007 uses a product id while the 2010 version uses a cPath. I'm not sure if this affects anything but I want to be sure. How can this be accomplished for 1.3.x
-
Re: Solution: Displaying all products and new products listing in column/grid
I followed gjh42's advice and it does partially work. I'm having two problems with it.
- Adding the info:
Code:
.productListing-row .main {
vertical-align: top;
text-align: center;
}
to my stylesheet doesn't do anything. Is there a specific part of the stylesheey I should add this code to?
- When the products in All Products and New Products were shown in rows, the information was shown in the order:
Code:
Product name
Price
Quantity box
Description
Now that they are in rows, the information is now in the order:
Code:
Quantity box
Description
Product name
Price
Looking at the code, everything seems to be in the right order. Does anyone have any suggestions on the cause of this?
-
Re: Solution: Displaying all products and new products listing in column/grid
What are your display orders set to for each element of the listing? (e.g. Price: 1203)
-
Re: Solution: Displaying all products and new products listing in column/grid
The numbers for both sets of listings are the same and haven't been changed since I installed Zen Cart.
Display Product Image - 1102
Display Product Quantity - 1202
Display Product Buy Now Button - 1300
Display Product Name - 2101
Display Product Model - 2201
Display Product Manufacturer Name - 2302
Display Product Price - 2402
Display Product Weight - 2502
Display Product Date Added - 2601
-
Re: Solution: Displaying all products and new products listing in column/grid
The settings you show should result in the second layout you show.
Display Product Image - 1102
Display Product Quantity - 1202
Display Product Buy Now Button - 1300
Display Product Name - 2101
Display Product Model - 2201
Display Product Manufacturer Name - 2302
Display Product Price - 2402
Display Product Weight - 2502
Display Product Date Added - 2601
Quantity box
Description
Product name
Price
120 comes before the description "between the columns", followed by 210 and 240.
I don't know why it would have displayed differently before.
-
Re: Solution: Displaying all products and new products listing in column/grid
By the way, in regard to the question about featured listing, look at the Single Listing Template mod in Free Addons.
And to get the column/grid layout, the most foolproof method is to install Column Layout Grid from Free Addons (just two files to put in your template folder, and a snippet of SQL to paste in Tools > Install SQL Patches).
-
Re: Solution: Displaying all products and new products listing in column/grid
I tried switching around some of those numbers and I got the current layout to match the original layout. Thanks for your help :smile:
-
Re: Solution: Displaying all products and new products listing in column/grid
So, I copy pasted the version for the All product listing page, and it works great, except for one problem. I want to get rid of the Qty: # in the listing. I've gone to the All listing admin and changed both "Display Product Model" and "Display Product Quantity" to 0, but it hasn't changed anything.
Anyone have any idea why this might be happening?
Thanks in advance.
-
Re: Solution: Displaying all products and new products listing in column/grid
Quote:
Originally Posted by
gaius
So, I copy pasted the version for the All product listing page, and it works great, except for one problem. I want to get rid of the Qty: # in the listing. I've gone to the All listing admin and changed both "Display Product Model" and "Display Product Quantity" to 0, but it hasn't changed anything.
Anyone have any idea why this might be happening?
Thanks in advance.
Nobody? :no:
-
Re: Solution: Displaying all products and new products listing in column/grid
you have to go to your admin then:
admin>catalog->product types -> general (or whatever type) -> edit layout
-
Re: Solution: Displaying all products and new products listing in column/grid
this as been many things i have been wanting to do to my main page and not had much look till now, this as been the easiest thing i have done THANK YOU
:clap:
-
Re: Displaying all products and new products listing in column/grid
Amazing! Flawless implementation! I never would have figured this out without your mod. Thank you!
-
Re: Solution: Displaying all products and new products listing in column/grid
Amazing! Flawless implementation! I never would have figured this out without your mod. Thank you!
-
Re: Solution: Displaying all products and new products listing in column/grid
Quote:
Originally Posted by
solidrock
I am not good with php, but your coding worked great on those two pages. Can you post the proper coding for the featured products page as well? And how do I get the category pages to show up in columnar format?
Hello, Somehow I figured out the coding for the featured products page which shows multiple columns( in my case, 4) in a row. Everything is based on ChapAgain's idea.:D
The following is my coding and I tested on my site which works fine.
PHP Code:
<?php
/**
* Module Template
*
* Loaded automatically by index.php?main_page=featured_products.<br />
* Displays listing of Featured Products
*
* @package templateSystem
* @copyright Copyright 2003-2005 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: tpl_modules_products_featured_listing.php 6096 2007-04-01 00:43:21Z ajeh $
*/
?>
<table border="0" width="100%" cellspacing="2" cellpadding="2">
<tr>
<td colspan="3"><hr /></td>
</tr>
<tr>
<?php
$group_id = zen_get_configuration_key_value('PRODUCT_FEATURED_LIST_GROUP_ID');
if ($featured_products_split->number_of_rows > 0) {
$featured_products = $db->Execute($featured_products_split->sql_query);
$row_counter = 0;
while (!$featured_products->EOF) {
$row_counter++;
if (PRODUCT_FEATURED_LIST_IMAGE != '0') {
if ($featured_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) {
$display_products_image = str_repeat('<br clear="all" />', substr(PRODUCT_FEATURED_LIST_IMAGE, 3, 1));
} else {
$display_products_image = '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'products_id=' . $featured_products->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $featured_products->fields['products_image'], $featured_products->fields['products_name'], IMAGE_FEATURED_PRODUCTS_LISTING_WIDTH, IMAGE_FEATURED_PRODUCTS_LISTING_HEIGHT) . '</a>' . str_repeat('<br clear="all" />', substr(PRODUCT_FEATURED_LIST_IMAGE, 3, 1));
}
} else {
$display_products_image = '';
}
if (PRODUCT_FEATURED_LIST_NAME != '0') {
$display_products_name = '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'products_id=' . $featured_products->fields['products_id']) . '"><strong>' . $featured_products->fields['products_name'] . '</strong></a>' . str_repeat('<br clear="all" />', substr(PRODUCT_FEATURED_LIST_NAME, 3, 1));
} else {
$display_products_name = '';
}
if (PRODUCT_FEATURED_LIST_MODEL != '0' and zen_get_show_product_switch($featured_products->fields['products_id'], 'model')) {
$display_products_model = TEXT_PRODUCTS_MODEL . $featured_products->fields['products_model'] . str_repeat('<br clear="all" />', substr(PRODUCT_FEATURED_LIST_MODEL, 3, 1));
} else {
$display_products_model = '';
}
if (PRODUCT_FEATURED_LIST_WEIGHT != '0' and zen_get_show_product_switch($featured_products->fields['products_id'], 'weight')) {
$display_products_weight = '<br />' . TEXT_PRODUCTS_WEIGHT . $featured_products->fields['products_weight'] . TEXT_SHIPPING_WEIGHT . str_repeat('<br clear="all" />', substr(PRODUCT_FEATURED_LIST_WEIGHT, 3, 1));
} else {
$display_products_weight = '';
}
if (PRODUCT_FEATURED_LIST_QUANTITY != '0' and zen_get_show_product_switch($featured_products->fields['products_id'], 'quantity')) {
if ($featured_products->fields['products_quantity'] <= 0) {
$display_products_quantity = TEXT_OUT_OF_STOCK . str_repeat('<br clear="all" />', substr(PRODUCT_FEATURED_LIST_QUANTITY, 3, 1));
} else {
$display_products_quantity = TEXT_PRODUCTS_QUANTITY . $featured_products->fields['products_quantity'] . str_repeat('<br clear="all" />', substr(PRODUCT_FEATURED_LIST_QUANTITY, 3, 1));
}
} else {
$display_products_quantity = '';
}
if (PRODUCT_FEATURED_LIST_DATE_ADDED != '0' and zen_get_show_product_switch($featured_products->fields['products_id'], 'date_added')) {
$display_products_date_added = TEXT_DATE_ADDED . ' ' . zen_date_long($featured_products->fields['products_date_added']) . str_repeat('<br clear="all" />', substr(PRODUCT_FEATURED_LIST_DATE_ADDED, 3, 1));
} else {
$display_products_date_added = '';
}
if (PRODUCT_FEATURED_LIST_MANUFACTURER != '0' and zen_get_show_product_switch($featured_products->fields['products_id'], 'manufacturer')) {
$display_products_manufacturers_name = ($featured_products->fields['manufacturers_name'] != '' ? TEXT_MANUFACTURER . ' ' . $featured_products->fields['manufacturers_name'] . str_repeat('<br clear="all" />', substr(PRODUCT_FEATURED_LIST_MANUFACTURER, 3, 1)) : '');
} else {
$display_products_manufacturers_name = '';
}
if ((PRODUCT_FEATURED_LIST_PRICE != '0' and zen_get_products_allow_add_to_cart($featured_products->fields['products_id']) == 'Y') and zen_check_show_prices() == true) {
$products_price = zen_get_products_display_price($featured_products->fields['products_id']);
$display_products_price = TEXT_PRICE . ' ' . $products_price . str_repeat('<br clear="all" />', substr(PRODUCT_FEATURED_LIST_PRICE, 3, 1)) . (zen_get_show_product_switch($featured_products->fields['products_id'], 'ALWAYS_FREE_SHIPPING_IMAGE_SWITCH') ? (zen_get_product_is_always_free_shipping($featured_products->fields['products_id']) ? TEXT_PRODUCT_FREE_SHIPPING_ICON . '<br />' : '') : '');
} else {
$display_products_price = '';
}
// more info in place of buy now
if (PRODUCT_FEATURED_BUY_NOW != '0' and zen_get_products_allow_add_to_cart($featured_products->fields['products_id']) == 'Y') {
if (zen_has_product_attributes($featured_products->fields['products_id'])) {
$link = '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'products_id=' . $featured_products->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
} else {
// $link= '<a href="' . zen_href_link(FILENAME_FEATURED_PRODUCTS, zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $featured_products->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT) . '</a>';
if (PRODUCT_FEATURED_LISTING_MULTIPLE_ADD_TO_CART > 0 && $featured_products->fields['products_qty_box_status'] != 0) {
// $how_many++;
$link = TEXT_PRODUCT_FEATURED_LISTING_MULTIPLE_ADD_TO_CART . "<input type=\"text\" name=\"products_id[" . $featured_products->fields['products_id'] . "]\" value=\"0\" size=\"4\" />";
} else {
$link = '<a href="' . zen_href_link(FILENAME_FEATURED_PRODUCTS, zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $featured_products->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_BUY_NOW, BUTTON_BUY_NOW_ALT) . '</a> ';
}
}
$the_button = $link;
$products_link = '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'products_id=' . $featured_products->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
$display_products_button = zen_get_buy_now_button($featured_products->fields['products_id'], $the_button, $products_link) . '<br />' . zen_get_products_quantity_min_units_display($featured_products->fields['products_id']) . str_repeat('<br clear="all" />', substr(PRODUCT_FEATURED_BUY_NOW, 3, 1));
} else {
$link = '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'products_id=' . $featured_products->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
$the_button = $link;
$products_link = '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'products_id=' . $featured_products->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
$display_products_button = zen_get_buy_now_button($featured_products->fields['products_id'], $the_button, $products_link) . '<br />' . zen_get_products_quantity_min_units_display($featured_products->fields['products_id']) . str_repeat('<br clear="all" />', substr(PRODUCT_FEATURED_BUY_NOW, 3, 1));
}
if (PRODUCT_FEATURED_LIST_DESCRIPTION != '0') {
$disp_text = zen_get_products_description($featured_products->fields['products_id']);
$disp_text = zen_clean_html($disp_text);
$display_products_description = stripslashes(zen_trunc_string($disp_text, 150, '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'products_id=' . $featured_products->fields['products_id']) . '"> ' . MORE_INFO_TEXT . '</a>'));
} else {
$display_products_description = '';
}
?>
<?php
if(($row_counter-1)%4 == 0)
{
?>
<tr>
<?php
}
?>
<td width="<?php echo IMAGE_FEATURED_PRODUCTS_LISTING_WIDTH + 10; ?>" valign="top" class="main" align="center">
<?php
$disp_sort_order = $db->Execute("select configuration_key, configuration_value from " . TABLE_CONFIGURATION . " where configuration_group_id='" . $group_id . "' and (configuration_value >= 1000 and configuration_value <= 1999) order by LPAD(configuration_value,11,0)");
while (!$disp_sort_order->EOF) {
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_FEATURED_LIST_IMAGE') {
echo $display_products_image;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_FEATURED_LIST_NAME') {
echo $display_products_name;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_FEATURED_LIST_PRICE') {
echo $display_products_price;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_FEATURED_BUY_NOW') {
echo $display_products_button;
}
$disp_sort_order->MoveNext();
}
$disp_sort_order = $db->Execute("select configuration_key, configuration_value from " . TABLE_CONFIGURATION . " where configuration_group_id='" . $group_id . "' and (configuration_value >= 2000 and configuration_value <= 2999) order by LPAD(configuration_value,11,0)");
while (!$disp_sort_order->EOF) {
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_FEATURED_LIST_IMAGE') {
echo $display_products_image;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_FEATURED_LIST_NAME') {
echo $display_products_name;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_FEATURED_LIST_PRICE') {
echo $display_products_price;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_FEATURED_BUY_NOW') {
echo $display_products_button;
}
$disp_sort_order->MoveNext();
}
?>
</td>
<?php
$featured_products->MoveNext();
}
} else {
?>
<tr>
<td class="main" colspan="2"><?php echo TEXT_NO_FEATURED_PRODUCTS; ?></td>
</tr>
<?php
}
?>
</tr>
</table>
-
Re: Solution: Displaying all products and new products listing in column/grid
BTW: I forgot to incluce the file details.
The file location :/public_html/includes/templates/template_default/templates,
The file name: tpl_modules_products_featured_listing.php
If your template has its own file, then edit the file accrodingly in your template folder.
How: Just use the following code to replace all codes in that file.
Quote:
Originally Posted by
sjbglx
Hello, Somehow I figured out the coding for the featured products page which shows multiple columns( in my case, 4) in a row. Everything is based on ChapAgain's idea.:D
The following is my coding and I tested on my site which works fine.
PHP Code:
<?php
/**
* Module Template
*
* Loaded automatically by index.php?main_page=featured_products.<br />
* Displays listing of Featured Products
*
* @package templateSystem
* @copyright Copyright 2003-2005 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: tpl_modules_products_featured_listing.php 6096 2007-04-01 00:43:21Z ajeh $
*/
?>
<table border="0" width="100%" cellspacing="2" cellpadding="2">
<tr>
<td colspan="3"><hr /></td>
</tr>
<tr>
<?php
$group_id = zen_get_configuration_key_value('PRODUCT_FEATURED_LIST_GROUP_ID');
if ($featured_products_split->number_of_rows > 0) {
$featured_products = $db->Execute($featured_products_split->sql_query);
$row_counter = 0;
while (!$featured_products->EOF) {
$row_counter++;
if (PRODUCT_FEATURED_LIST_IMAGE != '0') {
if ($featured_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) {
$display_products_image = str_repeat('<br clear="all" />', substr(PRODUCT_FEATURED_LIST_IMAGE, 3, 1));
} else {
$display_products_image = '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'products_id=' . $featured_products->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $featured_products->fields['products_image'], $featured_products->fields['products_name'], IMAGE_FEATURED_PRODUCTS_LISTING_WIDTH, IMAGE_FEATURED_PRODUCTS_LISTING_HEIGHT) . '</a>' . str_repeat('<br clear="all" />', substr(PRODUCT_FEATURED_LIST_IMAGE, 3, 1));
}
} else {
$display_products_image = '';
}
if (PRODUCT_FEATURED_LIST_NAME != '0') {
$display_products_name = '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'products_id=' . $featured_products->fields['products_id']) . '"><strong>' . $featured_products->fields['products_name'] . '</strong></a>' . str_repeat('<br clear="all" />', substr(PRODUCT_FEATURED_LIST_NAME, 3, 1));
} else {
$display_products_name = '';
}
if (PRODUCT_FEATURED_LIST_MODEL != '0' and zen_get_show_product_switch($featured_products->fields['products_id'], 'model')) {
$display_products_model = TEXT_PRODUCTS_MODEL . $featured_products->fields['products_model'] . str_repeat('<br clear="all" />', substr(PRODUCT_FEATURED_LIST_MODEL, 3, 1));
} else {
$display_products_model = '';
}
if (PRODUCT_FEATURED_LIST_WEIGHT != '0' and zen_get_show_product_switch($featured_products->fields['products_id'], 'weight')) {
$display_products_weight = '<br />' . TEXT_PRODUCTS_WEIGHT . $featured_products->fields['products_weight'] . TEXT_SHIPPING_WEIGHT . str_repeat('<br clear="all" />', substr(PRODUCT_FEATURED_LIST_WEIGHT, 3, 1));
} else {
$display_products_weight = '';
}
if (PRODUCT_FEATURED_LIST_QUANTITY != '0' and zen_get_show_product_switch($featured_products->fields['products_id'], 'quantity')) {
if ($featured_products->fields['products_quantity'] <= 0) {
$display_products_quantity = TEXT_OUT_OF_STOCK . str_repeat('<br clear="all" />', substr(PRODUCT_FEATURED_LIST_QUANTITY, 3, 1));
} else {
$display_products_quantity = TEXT_PRODUCTS_QUANTITY . $featured_products->fields['products_quantity'] . str_repeat('<br clear="all" />', substr(PRODUCT_FEATURED_LIST_QUANTITY, 3, 1));
}
} else {
$display_products_quantity = '';
}
if (PRODUCT_FEATURED_LIST_DATE_ADDED != '0' and zen_get_show_product_switch($featured_products->fields['products_id'], 'date_added')) {
$display_products_date_added = TEXT_DATE_ADDED . ' ' . zen_date_long($featured_products->fields['products_date_added']) . str_repeat('<br clear="all" />', substr(PRODUCT_FEATURED_LIST_DATE_ADDED, 3, 1));
} else {
$display_products_date_added = '';
}
if (PRODUCT_FEATURED_LIST_MANUFACTURER != '0' and zen_get_show_product_switch($featured_products->fields['products_id'], 'manufacturer')) {
$display_products_manufacturers_name = ($featured_products->fields['manufacturers_name'] != '' ? TEXT_MANUFACTURER . ' ' . $featured_products->fields['manufacturers_name'] . str_repeat('<br clear="all" />', substr(PRODUCT_FEATURED_LIST_MANUFACTURER, 3, 1)) : '');
} else {
$display_products_manufacturers_name = '';
}
if ((PRODUCT_FEATURED_LIST_PRICE != '0' and zen_get_products_allow_add_to_cart($featured_products->fields['products_id']) == 'Y') and zen_check_show_prices() == true) {
$products_price = zen_get_products_display_price($featured_products->fields['products_id']);
$display_products_price = TEXT_PRICE . ' ' . $products_price . str_repeat('<br clear="all" />', substr(PRODUCT_FEATURED_LIST_PRICE, 3, 1)) . (zen_get_show_product_switch($featured_products->fields['products_id'], 'ALWAYS_FREE_SHIPPING_IMAGE_SWITCH') ? (zen_get_product_is_always_free_shipping($featured_products->fields['products_id']) ? TEXT_PRODUCT_FREE_SHIPPING_ICON . '<br />' : '') : '');
} else {
$display_products_price = '';
}
// more info in place of buy now
if (PRODUCT_FEATURED_BUY_NOW != '0' and zen_get_products_allow_add_to_cart($featured_products->fields['products_id']) == 'Y') {
if (zen_has_product_attributes($featured_products->fields['products_id'])) {
$link = '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'products_id=' . $featured_products->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
} else {
// $link= '<a href="' . zen_href_link(FILENAME_FEATURED_PRODUCTS, zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $featured_products->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT) . '</a>';
if (PRODUCT_FEATURED_LISTING_MULTIPLE_ADD_TO_CART > 0 && $featured_products->fields['products_qty_box_status'] != 0) {
// $how_many++;
$link = TEXT_PRODUCT_FEATURED_LISTING_MULTIPLE_ADD_TO_CART . "<input type=\"text\" name=\"products_id[" . $featured_products->fields['products_id'] . "]\" value=\"0\" size=\"4\" />";
} else {
$link = '<a href="' . zen_href_link(FILENAME_FEATURED_PRODUCTS, zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $featured_products->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_BUY_NOW, BUTTON_BUY_NOW_ALT) . '</a> ';
}
}
$the_button = $link;
$products_link = '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'products_id=' . $featured_products->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
$display_products_button = zen_get_buy_now_button($featured_products->fields['products_id'], $the_button, $products_link) . '<br />' . zen_get_products_quantity_min_units_display($featured_products->fields['products_id']) . str_repeat('<br clear="all" />', substr(PRODUCT_FEATURED_BUY_NOW, 3, 1));
} else {
$link = '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'products_id=' . $featured_products->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
$the_button = $link;
$products_link = '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'products_id=' . $featured_products->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
$display_products_button = zen_get_buy_now_button($featured_products->fields['products_id'], $the_button, $products_link) . '<br />' . zen_get_products_quantity_min_units_display($featured_products->fields['products_id']) . str_repeat('<br clear="all" />', substr(PRODUCT_FEATURED_BUY_NOW, 3, 1));
}
if (PRODUCT_FEATURED_LIST_DESCRIPTION != '0') {
$disp_text = zen_get_products_description($featured_products->fields['products_id']);
$disp_text = zen_clean_html($disp_text);
$display_products_description = stripslashes(zen_trunc_string($disp_text, 150, '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'products_id=' . $featured_products->fields['products_id']) . '"> ' . MORE_INFO_TEXT . '</a>'));
} else {
$display_products_description = '';
}
?>
<?php
if(($row_counter-1)%4 == 0)
{
?>
<tr>
<?php
}
?>
<td width="<?php echo IMAGE_FEATURED_PRODUCTS_LISTING_WIDTH + 10; ?>" valign="top" class="main" align="center">
<?php
$disp_sort_order = $db->Execute("select configuration_key, configuration_value from " . TABLE_CONFIGURATION . " where configuration_group_id='" . $group_id . "' and (configuration_value >= 1000 and configuration_value <= 1999) order by LPAD(configuration_value,11,0)");
while (!$disp_sort_order->EOF) {
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_FEATURED_LIST_IMAGE') {
echo $display_products_image;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_FEATURED_LIST_NAME') {
echo $display_products_name;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_FEATURED_LIST_PRICE') {
echo $display_products_price;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_FEATURED_BUY_NOW') {
echo $display_products_button;
}
$disp_sort_order->MoveNext();
}
$disp_sort_order = $db->Execute("select configuration_key, configuration_value from " . TABLE_CONFIGURATION . " where configuration_group_id='" . $group_id . "' and (configuration_value >= 2000 and configuration_value <= 2999) order by LPAD(configuration_value,11,0)");
while (!$disp_sort_order->EOF) {
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_FEATURED_LIST_IMAGE') {
echo $display_products_image;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_FEATURED_LIST_NAME') {
echo $display_products_name;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_FEATURED_LIST_PRICE') {
echo $display_products_price;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_FEATURED_BUY_NOW') {
echo $display_products_button;
}
$disp_sort_order->MoveNext();
}
?>
</td>
<?php
$featured_products->MoveNext();
}
} else {
?>
<tr>
<td class="main" colspan="2"><?php echo TEXT_NO_FEATURED_PRODUCTS; ?></td>
</tr>
<?php
}
?>
</tr>
</table>
-
Re: Solution: Displaying all products and new products listing in column/grid
Quote:
Originally Posted by
sjbglx
BTW: I forgot to incluce the file details.
The file location :/public_html/includes/templates/template_default/templates,
The file name: tpl_modules_products_featured_listing.php
If your template has its own file, then edit the file accrodingly in your template folder.
How: Just use the following code to replace all codes in that file.
Hi, just wondered whether your page passed the W3C Validator tests.
Like you I've got my page to display as I want it but it is falling down on errors related to the tr & td tags - I think.
-
Re: Solution: Displaying all products and new products listing in column/grid
At a glance, the original code is missing the <tbody> and </tbody> tags, and a </tr> tag with some selective coding it would need.
Rather than fix this antiquated table layout code, I suggest using the Single Listing Template from Free Addons, or niccol's new SNAF which is a refinement of that.
-
Re: Solution: Displaying all products and new products listing in column/grid
Quote:
Originally Posted by
gjh42
At a glance, the original code is missing the <tbody> and </tbody> tags, and a </tr> tag with some selective coding it would need.
Rather than fix this antiquated table layout code, I suggest using the Single Listing Template from Free Addons, or niccol's new SNAF which is a refinement of that.
Thanks Glenn,
I did try the single listing template add-on a while back , it would have meant redoing a lot of the formatting I perfected. I'll take a look at SNAF though.
-
Re: Solution: Displaying all products and new products listing in column/grid
How can I apply this column display layout to product listing page?
I've tried to edit the tpl_modules_product_listing.php, but I have no clue.
Thanks.
-
Re: Solution: Displaying all products and new products listing in column/grid
Hi ,
I just replace the tpl_tabular_display with tpl_columnar_display on line 37 form tpl_modules_product_listing.php ( for example )
Work for each view. :) after that you have to do some magic with css :)
-
Re: Solution: Displaying all products and new products listing in column/grid
Is not working from first time :) so is not a suitable solution .
However you can edit the columnar display and give the name my columnar display and modify some code to work it out.
-
Re: Solution: Displaying all products and new products listing in column/grid
Quote:
Originally Posted by
CaDyMaN
Is not working from first time :) so is not a suitable solution .
However you can edit the columnar display and give the name my columnar display and modify some code to work it out.
exemple
Code:
<?php
/**
* Common Template - tpl_columnar_display.php
*
* This file is used for generating tabular output where needed, based on the supplied array of table-cell contents.
*
* @package templateSystem
* @copyright Copyright 2003-2006 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: tpl_columnar_display.php 3157 2006-03-10 23:24:22Z drbyte $
*/
?>
<?php
if ($title) {
?>
<?php //echo $title; ?>
<?php
}
?>
<?php
if (is_array($list_box_contents) > 0 ) {
for($row=1;$row<sizeof($list_box_contents);$row++) {
$params = "";
//if (isset($list_box_contents[$row]['params'])) $params .= ' ' . $list_box_contents[$row]['params'];
?>
<div id="Prodcutitem">
<?php
for($col=0;$col<sizeof($list_box_contents[$row]);$col++) {
$r_params = "";
if (isset($list_box_contents[$row][$col]['params'])) $r_params .= ' ' . (string)$list_box_contents[$row][$col]['params'];
if (isset($list_box_contents[$row][$col]['text'])) {
?>
<?php echo '<div' . $r_params . '>' . $list_box_contents[$row][$col]['text'] . '</div>' . "\n"; ?>
<?php
}
}
?>
</div>
<?php
}
}
?>
-
Re: Displaying all products and new products listing in column/grid
I get the same problem but i see your treat is very old i work with 1.5.1 what can i do?
Quote:
Originally Posted by
chapagain
I was in search for displaying all products listing and new products listing in column/grid layout instead of the default row layout.. I searched in this forum a lot.. could not found any appropriate solution to this problem.. a suggestion was to change/modify the code.. Hence, I have done it.
PS: Currently i am using 4 columns per row. If you want to change the column option per row then you have to modify the following line in the code above:
PHP Code:
if(($row_counter-1)%4 == 0)
change the number 4 to your desired row number. :smile: This is a bit hard coding, but i will definitely try to find a better solution. :yes:
zen cart is not allowing me to post so long text/chars.. so i am posting the code in reply to this post :D
"The text that you have entered is too long (23785 characters). Please shorten it to 23000 characters long."
-
Re: Solution: Displaying all products and new products listing in column/grid
Quote:
Originally Posted by
sjbglx
BTW: I forgot to incluce the file details.
The file location :/public_html/includes/templates/template_default/templates,
The file name: tpl_modules_products_featured_listing.php
If your template has its own file, then edit the file accrodingly in your template folder.
How: Just use the following code to replace all codes in that file.
I used your metho on a new site I am setting up and it worked PERFECTLY!!! Thanks so much for the contribution!!! :)
-
Re: Solution: Displaying all products and new products listing in column/grid
I am having a problem and hoping someone can give a hand. For some reason my product listing is displaying in one column only. Even though I have it set to grid, it still displays only one column. I have a feeling it may be in the css, but I cannot find it. Any help would be greatly appreciated. The temporary url is: http://192.232.243.44/~southwes
Thank you!
-
Re: Solution: Displaying all products and new products listing in column/grid
Add to your stylesheet (anywhere)
Code:
.centerBoxContentsProducts {float: left;}
This is default behavior, but some style editing you did must have eliminated that, probably as a change to a rule that covers many different kinds of elements.
-
Re: Solution: Displaying all products and new products listing in column/grid
Quote:
Originally Posted by
creyesx6
I am having a problem and hoping someone can give a hand. For some reason my product listing is displaying in one column only. Even though I have it set to grid, it still displays only one column. I have a feeling it may be in the css, but I cannot find it. Any help would be greatly appreciated. The temporary url is:
http://192.232.243.44/~southwes
Thank you!
Never mind, I found the problem in CSS. It was a simple text-align: left in the wrong place.