Forums / Templates, Stylesheets, Page Layout / Is this possible ? Two or more product listing layouts (one per category)?

Is this possible ? Two or more product listing layouts (one per category)?

Views: 8,064

Results 1 to 20 of 52
6 Feb 2009, 5:42 AM
#1
risant avatar

risant

New Zenner

Join Date:
Jul 2008
Posts:
18
Plugin Contributions:
0

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.

6 Feb 2009, 6:36 AM
#2
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

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.

6 Feb 2009, 5:13 PM
#3
risant avatar

risant

New Zenner

Join Date:
Jul 2008
Posts:
18
Plugin Contributions:
0

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.

6 Feb 2009, 5:39 PM
#4
bunyip avatar

bunyip

Totally Zenned

Join Date:
Sep 2004
Location:
Western Massachusetts
Posts:
2,361
Plugin Contributions:
1

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

if (PRODUCT_LISTING_LAYOUT_STYLE == 'rows')

tests to be

if (PRODUCT_LISTING_LAYOUT_STYLE == 'rows' OR (int)$current_category_id == XXX)

and each of the

if (PRODUCT_LISTING_LAYOUT_STYLE == 'columns')

tests to be

if (PRODUCT_LISTING_LAYOUT_STYLE == 'columns' AND (int)$current_category_id != XXX)

Neville
An assumption is what you arrive at when you get tired of thinking...

8 Feb 2009, 3:52 AM
#5
risant avatar

risant

New Zenner

Join Date:
Jul 2008
Posts:
18
Plugin Contributions:
0

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.

8 Feb 2009, 4:02 AM
#6
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

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:

$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));

I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

20 Mar 2009, 5:04 PM
#7
yakbuttertea avatar

yakbuttertea

New Zenner

Join Date:
Feb 2009
Posts:
31
Plugin Contributions:
0

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

20 Mar 2009, 5:16 PM
#8
yakbuttertea avatar

yakbuttertea

New Zenner

Join Date:
Feb 2009
Posts:
31
Plugin Contributions:
0

Re: Is this possible ? Two or more product listing layouts (one per category)?

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

20 Mar 2009, 5:21 PM
#9
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

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.

20 Mar 2009, 6:06 PM
#10
yakbuttertea avatar

yakbuttertea

New Zenner

Join Date:
Feb 2009
Posts:
31
Plugin Contributions:
0

Re: Is this possible ? Two or more product listing layouts (one per category)?

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

25 Mar 2009, 5:52 PM
#11
yakbuttertea avatar

yakbuttertea

New Zenner

Join Date:
Feb 2009
Posts:
31
Plugin Contributions:
0

Re: Is this possible ? Two or more product listing layouts (one per category)?

@gjh42:
Thank you for your reply, I didn't see it before.

So this code goes in the products_listing.php file in the module directory.

Then you create a file named products_listing_c_'category_id'.php for each category.

Am I correct?

25 Mar 2009, 6:35 PM
#12
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Is this possible ? Two or more product listing layouts (one per category)?

The selection code can't go in the file that it is selecting. I would have to research to find the file that calls product_listing.php (or its alternate).
At any rate, you really don't need to do the extra work if you just want to switch between the "columns" and "rows" layout styles. That is best handled with bunyip's examples.

It sounds like you somehow messed up the edits; best to go back and get those right than to try to fix it with significantly more complex editing.

10 Jun 2010, 11:55 PM
#13
danielle avatar

danielle

Totally Zenned

Join Date:
Oct 2004
Posts:
973
Plugin Contributions:
0

Re: Is this possible ? Two or more product listing layouts (one per category)?

yellow1912:

This is what I did, worked like a charm if you want to select the product listing module you want to use:

$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));


What file would you put this code in?

Thanks!

Danielle

27 Jul 2011, 3:02 PM
#14
idc1 avatar

idc1

Zen Follower

Join Date:
Jul 2011
Posts:
139
Plugin Contributions:
0

Re: Is this possible ? Two or more product listing layouts (one per category)?

Hopefully I can revive this thread. Bunyip's solution seems straight forward and may be the quick fix, but I would prefer to implement the long term solution. Can anyone offer help regarding yellow1912 solution.

  1. will this work for ZC 1.3.9h or is there a better solution
  2. where does the code go
  3. once I implement the code do I just add a layout column in my categories table and populate with "row", "grid", "xx", "xy", and so on or would the assignment need to be the actual .php file name for each layout.

ZC 1.5.5
Add ons: - Column/Grid 1.3.8 - Dual pricing 1.7 - ImageHandler3

28 Jul 2011, 2:33 AM
#15
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Is this possible ? Two or more product listing layouts (one per category)?

If you want two layouts, a row and a grid style, bunyip's code is the best way to do it. It is simple and elegant and doesn't take extra code in the codebase.

If you want (say) two kinds of grid layout, or three different layouts, yellow1912's solution will allow total flexibility as long as you are willing to write all the code for your desired layouts.
It works by testing for the existence of a file matching the current category id, so there is nothing to do in database tables; just make custom listing module files for each custom category and the code will find and use them where appropriate. The standard listing file will be used for any category that doesn't have a custom one.

8 Aug 2011, 5:10 PM
#16
idc1 avatar

idc1

Zen Follower

Join Date:
Jul 2011
Posts:
139
Plugin Contributions:
0

Re: Is this possible ? Two or more product listing layouts (one per category)?

Bunyip's code worked fine for me when doing a single category, but I need to do around 100 categories.

I think yellow1912 is the way to go, but that will have to wait until my programming knowledge improves. Oh well, back to Bunyips code.

I have tried several variations of "OR" "||" etc with undesirable outcomes. It almost looks as if the result are both row & column/grid format in one. I'm using ZC1.3.9 with column grid addon and sorry the site is not live. The last code I used, which I think is the proper way, was

if (PRODUCT_LISTING_LAYOUT_STYLE == 'rows' OR (int) $current_category_id == 2260 || (int) $current_category_id == 104150)

and

if (PRODUCT_LISTING_LAYOUT_STYLE == 'columns' AND (int) $current_category_id !== 2260 || (int) $current_category_id !== "104150")

My questions are:
1)What am I missing?
2)Is there a shorter way to do the or statement because I have about 100 categories to do this for?
3)Or with this many categories should I beg and plead for help to implement yellow1912 version?

Thanks

ZC 1.5.5
Add ons: - Column/Grid 1.3.8 - Dual pricing 1.7 - ImageHandler3

11 Aug 2011, 3:52 PM
#17
idc1 avatar

idc1

Zen Follower

Join Date:
Jul 2011
Posts:
139
Plugin Contributions:
0

Re: Is this possible ? Two or more product listing layouts (one per category)?

Anyone? Did I not provide enough info? I'm sure it's the simple fact that I didn't code the statement correctly due to my lack of programming knowledge.

Thanks

ZC 1.5.5
Add ons: - Column/Grid 1.3.8 - Dual pricing 1.7 - ImageHandler3

12 Aug 2011, 7:29 PM
#18
idc1 avatar

idc1

Zen Follower

Join Date:
Jul 2011
Posts:
139
Plugin Contributions:
0

Re: Is this possible ? Two or more product listing layouts (one per category)?

Update:
Part of the initial problem was that I had the category 104150 in qoutes :oops:

I've revised the code for product_listing.php to these lines
if (PRODUCT_LISTING_LAYOUT_STYLE == 'columns' AND (int) $current_category_id !== 2260 || PRODUCT_LISTING_LAYOUT_STYLE == 'columns' AND (int) $current_category_id !== 104150) {

if (PRODUCT_LISTING_LAYOUT_STYLE == 'rows' OR (int) $current_category_id == 2260 || PRODUCT_LISTING_LAYOUT_STYLE == 'rows' OR (int) $current_category_id == 104150)

and I've revised the code for tpl_modules_product_listing.php to this line
if (PRODUCT_LISTING_LAYOUT_STYLE == 'columns' AND (int) $current_category_id !== 2260 || PRODUCT_LISTING_LAYOUT_STYLE == 'columns' AND (int) $current_category_id !== 104150) {

When applying to only category 2260 (everything past the || deleted) it worked fine. Once I added the information past the || it worked fine for category 104150 but seemed to mess up category 2260. Category 2260 looked as though it was displaying both in row & grid format.

  1. Any idea how I can fix this
  2. This will be like a lot of code to paste if I have 100 categories to apply this two. Any other shortcuts out there?

Thanks

ZC 1.5.5
Add ons: - Column/Grid 1.3.8 - Dual pricing 1.7 - ImageHandler3

18 Aug 2011, 12:37 PM
#19
stsung avatar

stsung

New Zenner

Join Date:
Aug 2011
Posts:
21
Plugin Contributions:
0

Re: Is this possible ? Two or more product listing layouts (one per category)?

I tried the simple method...but I don't know what went wrong. I can't seem to find a problem. I use the column grid mod and I have the newest version of Zencart. It seems to work fine even though the mod is not meant for the version.

I changed both php files. the first one.
there is either (two instances)

 
  if (PRODUCT_LISTING_LAYOUT_STYLE == 'rows') OR $current_category_id == ^2$)

or (3 instances)

if (PRODUCT_LISTING_LAYOUT_STYLE == 'columns') AND $current_category_id != ^2$)
    

in the other file there's just this.

 if (PRODUCT_LISTING_LAYOUT_STYLE == 'columns') AND $current_category_id != ^2$) {
  require($template->get_template_dir('tpl_columnar_display.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_columnar_display.php');
} else {// (PRODUCT_LISTING_LAYOUT_STYLE == 'rows')
  require($template->get_template_dir('tpl_tabular_display.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_tabular_display.php');
}

is something wrong with this? it shows me a blank listing...

what I need is actually to have all subcategories of category id 2 to have the listing.

(http://outcast.cz)

the shop I'm working on now...
http://outcast.cz/

18 Aug 2011, 1:00 PM
#20
idc1 avatar

idc1

Zen Follower

Join Date:
Jul 2011
Posts:
139
Plugin Contributions:
0

Re: Is this possible ? Two or more product listing layouts (one per category)?

stsung, I'm not knowledgeable as to if ^2$ should imply all subcategories (would be interesting to know as I'm still trying to fix my issue), but have you tried to set your category to = 9

This might be a good test to see if it works. I bet you probably have the same issue as me in that you need to apply this to multiple categories. Sorry I can't help any more than the above suggestion.

ZC 1.5.5
Add ons: - Column/Grid 1.3.8 - Dual pricing 1.7 - ImageHandler3