Forums / Setting Up Categories, Products, Attributes / Is it possible to have two different Prod Listing Layouts?

Is it possible to have two different Prod Listing Layouts?

Locked
Results 1 to 17 of 17
This thread is locked. New replies are disabled.
09 Oct 2006, 16:31
#1
rwoody avatar

rwoody

Totally Zenned

Join Date:
Aug 2004
Posts:
476
Plugin Contributions:
0

Is it possible to have two different Prod Listing Layouts?

I would like to have to different product listing layouts based on category. The grid for all but one category. Could that be done by using Product type? I know that product type generally only effects the product detail, but I was wondering if this was possible using different file nameing conventions as is done with .css and if so could someone guide me just a bit.
09 Oct 2006, 16:33
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Posts:
62,757
Plugin Contributions:
1

Re: Is it possible to have two different Prod Listing Layouts?

This could be managed with a case statement or if statement based on $current_category_id
09 Oct 2006, 17:38
#3
rwoody avatar

rwoody

Totally Zenned

Join Date:
Aug 2004
Posts:
476
Plugin Contributions:
0

Re: Is it possible to have two different Prod Listing Layouts?

Hmmm... which file are you referencing to make the change...

In reading further in the forums... I noted a similiar question and the answer was the modules/pages/some_name/main_tpl_vars - I was wondering if this was possible using that method? Of course I still don't quite get how to set up the naming conventions there so the system would know to use those two files for that category... - it would seem that since changing to the column layout only required the two files and you set those up using the custom template naming convention that "if I could get my brain around the naming convention here" for this one category it would be possible to refer the layout back to the standard. Working till 4am makes the brain foggy... and I just can't seem to get my brain around this and I know this should be simple...LOL
09 Oct 2006, 18:20
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Posts:
62,757
Plugin Contributions:
1

Re: Is it possible to have two different Prod Listing Layouts?

/includes/templates/template_default/templates/tpl_index_product_list.php

calls the file:
/includes/templates/template_default/templates/tpl_modules_product_listing.php

This then calls the file:
[PHP] include(DIR_WS_MODULES . zen_get_module_directory(FILENAME_PRODUCT_LISTING));
[/PHP]

which is the file:
/includes/modules/product_listing.php
09 Oct 2006, 18:24
#5
rwoody avatar

rwoody

Totally Zenned

Join Date:
Aug 2004
Posts:
476
Plugin Contributions:
0

Re: Is it possible to have two different Prod Listing Layouts?

Thanks.. let me play with that and see how I do. I'll try writing a case statement and see if it works... If I get stuck I'll post my code. This could be very helpful for future sites also!!
09 Oct 2006, 23:54
#6
rwoody avatar

rwoody

Totally Zenned

Join Date:
Aug 2004
Posts:
476
Plugin Contributions:
0

Re: Is it possible to have two different Prod Listing Layouts?

Ok... I'm stuck...LOL - I can't seem to get past the parse errors to even see if it will do what I want... bad day at Bed Rock - any help here would be really appreciated.

I modified tpl_modules_product_listing - to the following:


PHP code:

include(DIR_WS_MODULES . zen_get_module_directory(FILENAME_PRODUCT_LISTING));
?>
<div id="productListing">
<?php
// only show when there is something to submit and enabled
if ($show_top_submit_button == true) {
?>
<div class="buttonRow forward"><?php echo zen_image_submit(BUTTON_IMAGE_ADD_PRODUCTS_TO_CART, BUTTON_ADD_PRODUCTS_TO_CART_ALT, 'id="submit1" name="submit1"'); ?></div>
<br class="clearBoth" />
<?php
} // show top submit
?>

<?php if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) {
?>
<div id="productsListingTopNumber" class="navSplitPagesResult back"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></div>
<div id="productsListingListingTopLinks" class="navSplitPagesLinks forward"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, zen_get_all_get_params(array('page', 'info', 'x', 'y', 'main_page'))); ?></div>
<br class="clearBoth" />
<?php
}
?>

<?php
/**
* load the list_box_content template to display the products based on category ID - category_id == 1 - tabular display all others to be columnar
*/
switch (expression) {
case 'PRODUCT_LISTING_LAYOUT_COLUMNS':
PRODUCT_LISTING_LAYOUT_STYLE == 'columns';
require($template->get_template_dir('tpl_columnar_display.php',DIR_WS_TEMPLATE, $current_page_base,'common'). ' /tpl_columnar_display.php');
[break;]
case 'PRODUCT_LISTING_LAYOUT_ROWS':
if (category_id == '1');
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');
[break;]
}
?>
10 Oct 2006, 01:16
#7
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Posts:
62,757
Plugin Contributions:
1

Re: Is it possible to have two different Prod Listing Layouts?

I am not saying the code is right ... this is what is wrong with the code you posted:

Change to:
[PHP]
switch (expression) {
case 'PRODUCT_LISTING_LAYOUT_COLUMNS':
PRODUCT_LISTING_LAYOUT_STYLE == 'columns';
require($template->get_template_dir('tpl_columnar_display.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_columnar_display.php');
break;
case 'PRODUCT_LISTING_LAYOUT_ROWS':
if (category_id == '1') {
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');
break;
}
}

[/PHP]
10 Oct 2006, 01:54
#8
rwoody avatar

rwoody

Totally Zenned

Join Date:
Aug 2004
Posts:
476
Plugin Contributions:
0

Re: Is it possible to have two different Prod Listing Layouts?

Thanks for getting back to me... I had played around with it and figured out my bad coding, but as you stated... it's not correct... I really wasn't thinking this through completely.

Each layout has two files - modules/product_listing and tpl_modules_products_listing.php as you mentioned - so just pointing to just the template isn't going to get the job done

So I'm back to the drawing board on how to get it to point to both files to pull back in the rows..... for the one category.

I know I'm making this harder than it is, but I'll keep playing with it, unless someone wants to save me here...LOL

Thanks Ajeh as usual for your ray of light in the dark tunnel... at least I know it's not the train. : ' )
10 Oct 2006, 01:59
#9
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Posts:
62,757
Plugin Contributions:
1

Re: Is it possible to have two different Prod Listing Layouts?

Isn't there already a switch to go back and forth between column and row with that add-on?

Couldn't you locate that switch ... and make your adjustment there to more or less flip it how you want it to be vs the default?
10 Oct 2006, 02:09
#10
rwoody avatar

rwoody

Totally Zenned

Join Date:
Aug 2004
Posts:
476
Plugin Contributions:
0

Re: Is it possible to have two different Prod Listing Layouts?

That's where I pulled this case from -

the code before my changes on tpl_modules_product_listing - the version for columns is as follows

PHP:

<?php
/**
* load the list_box_content template to display the products
*/
if (PRODUCT_LISTING_LAYOUT_STYLE == 'columns') {
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');
}
?>


I tried first writing code that merely un commented the "else" statement with a condition of - if category_id =='1' - and all it merely did was disabled the product listing and gave me a blank page when I went to that category... I really thought I had stumbled onto the perfect answer... but no joy - maybe I didn't approach this correctly -
10 Oct 2006, 03:29
#11
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Posts:
62,757
Plugin Contributions:
1

Re: Is it possible to have two different Prod Listing Layouts?

If you wanted categories_id 1 to be rows and all others columns and you were set to columns and change the IF to read:

[PHP]
<?php
/**
* load the list_box_content template to display the products
*/
if ($current_category_id != 1 && PRODUCT_LISTING_LAYOUT_STYLE == 'columns') {
require($template->get_template_dir('tpl_columnar_display.php',DIR_W S_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');
}
?>
[/PHP]
10 Oct 2006, 04:15
#12
rwoody avatar

rwoody

Totally Zenned

Join Date:
Aug 2004
Posts:
476
Plugin Contributions:
0

Re: Is it possible to have two different Prod Listing Layouts?

No joy unfortunately - I've been working locally and as I got mods working uploaded to the build area, but I went ahead and loaded this one so you could see -

On the online site the category in questions is '6' so I changed that in the code of course - but as you can see - if you click here http://69.50.202.136/index.php?main_page=index&cPath=6_12 we're still in columns - now I just had a thought as I pasted the url - The primary category is 6 with 5 subcategories - should that make a difference as the products are all actually in the subcategories? - As I'm writing this I changed the cat_id to 12 (one of the subcategories) and i did notice that it was now properly interpreting the .css style for the columns (which it was not before), but the candles still appear in columns.

Not sure where to go from here....

Thank you so much for trying to help me here. This has dead stopped me from going ahead and getting this done for her. she's really had a hard time with her site, as she lost it completely about two months ago, to no fault of her own.
10 Oct 2006, 06:22
#13
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Posts:
62,757
Plugin Contributions:
1

Re: Is it possible to have two different Prod Listing Layouts?

Do you have Categories and Products mixed in Categories?

Categories hold Categories or they hold Products ... they do not hold both at the same time as thing will not function correctly ...

Your Category 6 appears to hold both Products and Categories ...

Separate them properly like they should be, then test ...

Note: $current_category_id is the immediate categories_id for the Products in the products_listing ...
10 Oct 2006, 12:54
#14
rwoody avatar

rwoody

Totally Zenned

Join Date:
Aug 2004
Posts:
476
Plugin Contributions:
0

Re: Is it possible to have two different Prod Listing Layouts?

In regards to the category/product structure - it is correct - Top Category is Candle - which is ID 6 (no products there) Sub Categories - Jar Candles Small cat id = 12 - Jar Candles Medium cat id = 13- Jar Candles Large cat id = 14 - Votives cat id = 24 and Melts cat id 25. All the products are sitting directly in these Sub-Categories.

All products lying in the subcategories under the Top Category of Candle to be in a row layout. All other categories on the site are to be in Columns.

So my questions goes back to under the code you've helped with where the category id listed is to be in rows, will that effect it's direct subcategories also, since that is in fact where the products lie? Based on what I'm seeing the short answer is "no". If that is the case is there a way of writing the category id to be 6_wildcard (the wildcard - whatever symbol that required to represent the subcategories) that will be correctly read by the system? I've included a screen shot of the admin.

Thanks again for assisting with this. If I cannot do this, I'm going to look at the short descriptions mod as the descriptions in this layout are entirely too long for this type of layout as she wishes columns to be 4 across and this will just not work well. It's far too crowded. I'm assuming the short description mod provides for a shorter description for product listing and an expanded version for product detail, is that correct?

Thaks again
11 Oct 2006, 08:04
#15
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Posts:
21,876
Plugin Contributions:
6

Re: Is it possible to have two different Prod Listing Layouts?

As I alluded to in your other thread, the ereg function can do this wildcard pattern matching.

To match a top cat alone, use "^6$" - the ^ means beginning of string and $ means end of string, thus matching 6 and nothing else.
To match any subcat of 6, use "^6_" - this means starting with 6_ followed by anything or nothing, which will match all subcats etc. but not the top cat.
To match both cases, use "(^6$|^6_)" - this means matching either the first or second pattern separated by |.

I'm not sure what the format is for $current_category_id - whether it matches $cPath for subcats or what... this wants Ajeh's expertise.
13 Oct 2006, 21:34
#16
andy1234 avatar

andy1234

Zen Follower

Join Date:
Oct 2006
Posts:
148
Plugin Contributions:
0

Re: Is it possible to have two different Prod Listing Layouts?

Hi,

I am working on the same problem - need two diffefent prod listing templates to be switched. Have you managed to do this?
Thanks
A
14 Oct 2006, 04:24
#17
rwoody avatar

rwoody

Totally Zenned

Join Date:
Aug 2004
Posts:
476
Plugin Contributions:
0

Re: Is it possible to have two different Prod Listing Layouts?

Yes it is possible and I finally got it done. I'm running out right now, but as soon as I can, I'll pull what I did (took awhile to figure it out) and give you some info. Off the top of my head - edited the tpl_modules_products_listing.php and the modules/products_listing.php and had to add a function... I think... can't remember right now... but that will give you a place to start. Got some help on this as I was not getting the changes to pull through and really frustrated, but it does now.