Is this possible ? Two or more product listing layouts (one per category)?
I installed the excellent mod -column_layout_grid_v_1_3_8- and this work very good for me. Thanks fo the awesome job.
Now i have a question. I have a new category, and for that category i want to use a different layout style for the product listing.
For the whole shop >> the colums option (products in 3 columns per row) and for my new category i want each product in its own row. How can i achieve this ?
I noticed that the mod overrides just two files in zencart's system.
Is there a way to use a specific tpl_modules_product_listing.php for my new category ?
Anybody has any idea?
Apologies if this is answered in a previous thread. I've been searching for a while and can't find it.
Re: Is this possible ? Two or more product listing layouts (one per category)?
It would take some customizing of product_listing.php, and probably tpl_modules_product_listing.php, but it would not be difficult.
There are a number of tests like
if (PRODUCT_LISTING_LAYOUT_STYLE == 'rows') {
and
if (PRODUCT_LISTING_LAYOUT_STYLE == 'columns') {
and you could add a test for $_GET['cPath'] equaling the category you want different, to use the rows instead of columns code.
Re: Is this possible ? Two or more product listing layouts (one per category)?
thank you gjh42 for your reply and help.
i will try this tomorrow.
i found also another thread with the same problem :
http://www.zen-cart.com/forum/showthread.php?t=48433.
Unfortunately the answer is not complete, but the thread is informative and helpfull.
Re: Is this possible ? Two or more product listing layouts (one per category)?
There are a number of places in the product_listing.php module for the column mod where the code tests for whether the layout should be in rows or columns.
Assuming you have the overall cart set to display columns, and the product category that you want to use rows for has a category_id of XXX, you could change each of the
Code:
if (PRODUCT_LISTING_LAYOUT_STYLE == 'rows')
tests to be
Code:
if (PRODUCT_LISTING_LAYOUT_STYLE == 'rows' OR (int)$current_category_id == XXX)
and each of the
Code:
if (PRODUCT_LISTING_LAYOUT_STYLE == 'columns')
tests to be
Code:
if (PRODUCT_LISTING_LAYOUT_STYLE == 'columns' AND (int)$current_category_id != XXX)
Re: Is this possible ? Two or more product listing layouts (one per category)?
Yeah, it's possibe and it's easy. Thanks for your help gih42 and bunyip.:clap::clap:
For the really dummies like me, follow the advices given by bunyip precisely, it's all you have to do.
You have just to make these changes in two files, tpl_modules_product_listing (your template folder) and product_listing (module folder).
In tpl_modules_product_listing you will find
else {// (PRODUCT_LISTING_LAYOUT_STYLE == 'rows')
Since this is commented, don't care about them and leave this untouched.
And of course, you must have the mod -column_layout_grid_v_1_3_8- installded.
Re: Is this possible ? Two or more product listing layouts (one per category)?
This is what I did, worked like a charm if you want to select the product listing module you want to use:
PHP Code:
$listing_module_loaded = false;
if(!$is_index_listing && $_GET['main_page'] == 'index' && !empty($cPath)){
$category_array = explode('_', $cPath);
$category_array = array_reverse($category_array);
foreach ($category_array as $c){
$listing_module_file = DIR_WS_MODULES . zen_get_module_directory("product_listing_c_$c.php");
if(file_exists($listing_module_file)){
include($listing_module_file);
$listing_module_loaded = true;
break;
}
}
}
if(!$listing_module_loaded)
include(DIR_WS_MODULES . zen_get_module_directory(FILENAME_PRODUCT_LISTING));
Re: Is this possible ? Two or more product listing layouts (one per category)?
It doesn't work for me I installed the contrib to have it in tabular/grid display, made the changes to products_listing.php and tpl_module_products_listing.php but :
1- now in the category that should be displayed by row, I have only on product showing up instead of 542.
2- My table header with the description of the fields disappeared...
You can check at practitioners.springwind.com
Please, help?
yellow1912: how and where do you implement your code?
:frusty:
Thanks a bunch
Re: Is this possible ? Two or more product listing layouts (one per category)?
Quote:
Originally Posted by
yakbuttertea
It doesn't work for me I installed the contrib to have it in tabular/grid display, made the changes to products_listing.php and tpl_module_products_listing.php but :
1- now in the category that should be displayed by row, I have only on product showing up instead of 542.
2- My table header with the description of the fields disappeared...
You can check at practitioners.springwind.com
Please, help?
yellow1912: how and where do you implement your code?
:frusty:
Thanks a bunch
Fixed the 1- point, I forgot to modify an if()
2- still not showing
and still interested in yellow1912 solution
Thanks
Re: Is this possible ? Two or more product listing layouts (one per category)?
Yellow1912's code would work to select among a number of different product_listing files depending on the category. It requires making a new file with the layout code you want for each different case. It is the ultimate in flexibility, but overkill for switching between rows and columns in the Column Grid mod.
Re: Is this possible ? Two or more product listing layouts (one per category)?
Quote:
Originally Posted by
yakbuttertea
Fixed the 1- point, I forgot to modify an if()
2- still not showing
and still interested in yellow1912 solution
Thanks
Sorry for all this messages,
Fixed 2- as well
Thanks