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 41 to 52 of 52
26 Mar 2012, 3:26 PM
#41
gjh42 avatar

gjh42

Black Belt

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

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

Assuming you will have style set to "columns", you would just add more if() or }elseif(){ lines: ```php
if (PRODUCT_LISTING_LAYOUT_STYLE == 'columns') {
if ($current_category_id == 544) {
require($template->get_template_dir('tpl_columnar_display2.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_columnar_display2.php');
} elseif ($current_category_id == 567) {
require($template->get_template_dir('tpl_columnar_display3.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_columnar_display3.php');
} elseif ($current_category_id == 246 or $current_category_id == 321) {
require($template->get_template_dir('tpl_columnar_display4.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_columnar_display4.php');
} elseif (in_array($current_category_id, explode(',', '12,24,56,69')) {
require($template->get_template_dir('tpl_columnar_display5.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_columnar_display5.php');
} else {
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')

26 Mar 2012, 3:34 PM
#42
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 plan to have a lot of variations on tpl_columnar_display#.php, you might find it clearer to set a variable to '1', '2', '3', etc. and have one require at the end of the set:```php
if (PRODUCT_LISTING_LAYOUT_STYLE == 'columns') {
$style_no = '';//reset to base condition
if ($current_category_id == 544) {
$style_no = '2';//set custom style no
} elseif ($current_category_id == 567) {
$style_no = '3';//set custom style no
} elseif ($current_category_id == 246 or $current_category_id == 321) {
$style_no = '4';//set custom style no
} elseif (in_array($current_category_id, explode(',', '12,24,56,69')) {
$style_no = '5';//set custom style no
}
//call appropriate style
require($template->get_template_dir('tpl_columnar_display' . $style_no . '.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_columnar_display' . $style_no . '.php');
} else {// (PRODUCT_LISTING_LAYOUT_STYLE == 'rows')

26 Mar 2012, 3:41 PM
#43
dgent avatar

dgent

Totally Zenned

Join Date:
Nov 2009
Location:
UK
Posts:
1,117
Plugin Contributions:
0

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

This is excellent Glen many thanks. What Im planning to do with this is my str_replace trick, so I can make new categories with existing linked products, but modify the product titles for better SEO.

10 Nov 2013, 10:04 PM
#44
danielosko avatar

danielosko

Zen Follower

Join Date:
Dec 2008
Location:
Hanover Township PA, USA
Posts:
122
Plugin Contributions:
0

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

Hello All,
Has anyone been able to make Bunyip's code work with Zencart 1.50 using Flexible Product Listing Version 1.0?
If so, is the product_listing.php the only file that needs to be modified?

My includes/modules/classic/product_listing.php has the following code
if ($product_listing_layout_style == 'rows' in FOUR places as follows:

Location 1)
// Begin Row Layout Header
if ($product_listing_layout_style == 'rows' or PRODUCT_LISTING_GRID_SORT) { // For Column Layout (Grid Layout) add on module

Location 2)
case 'PRODUCT_LIST_IMAGE':
if ($product_listing_layout_style == 'rows') { //skip if grid

Location 3)
if ($product_listing_layout_style == 'rows') { // Used in Column Layout (Grid Layout) Add on module

Location 4)
$product_contents[] = $lc_text; // Used For Column Layout (Grid Layout) Option
if ($product_listing_layout_style == 'rows') {

My includes/modules/classic/product_listing.php has the following code
if ($product_listing_layout_style == 'columns' in THREE places as follows:

Location 1)
if ($product_listing_layout_style == 'columns') { //grid sort option

Location 2)
// Used for Column Layout (Grid Layout) add on module
$column = 0;
if ($product_listing_layout_style == 'columns') {

Location 3)
// Following code will be executed only if Column Layout (Grid Layout) option is chosen
if ($product_listing_layout_style == 'columns') {

I have REPLACED
if ($product_listing_layout_style == 'rows'
WITH
if ($product_listing_layout_style == 'rows' OR (int)$cPath == 101000

and I have REPLACED
if ($product_listing_layout_style == 'columns'
WITH
if ($product_listing_layout_style == 'columns' AND (int)$cPath == 101000

RESULT: ALL Product Listing Pages are "Blank".
(101000 is a top category which has multiple categories under it)

Any thoughts or ideas? This would be a fantastic addition!
Thanks all,
Danny

Daniel Osko

11 Nov 2013, 3:22 AM
#45
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)?

You really have over 100,000 categories? That's an exceptional category id, 101000.
What do you have $product_listing_layout_style set to? Does it make a difference in the result?

11 Nov 2013, 12:08 PM
#46
danielosko avatar

danielosko

Zen Follower

Join Date:
Dec 2008
Location:
Hanover Township PA, USA
Posts:
122
Plugin Contributions:
0

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

Hi Glen,
I actually have over 650 categories and sub-categories. Each category ID is separated by a numeric factor of 100 so that future categories can be added without effecting the presently used category ID’s.

My $product_listing_layout_style is set as follows:
if (!defined('PRODUCT_LISTING_LAYOUT_STYLE')) define('PRODUCT_LISTING_LAYOUT_STYLE',(isset($_GET['view']) ? $_GET['view'] : 'rows'));
if (!defined('PRODUCT_LISTING_COLUMNS_PER_ROW')) define('PRODUCT_LISTING_COLUMNS_PER_ROW',3);
if (!defined('PRODUCT_LISTING_GRID_SORT')) define('PRODUCT_LISTING_GRID_SORT',0);
$product_listing_layout_style = isset($_GET['view'])? $_GET['view']: PRODUCT_LISTING_LAYOUT_STYLE;
$row = 0;
$col = 0;
$list_box_contents = array();
$title = '';

Changing the $row or $col has no effect.

My product listing pages are not actually “blank”. The main category ID “101000” product listing pages all have a jumbled up combination of both rows and columns for every product. (so each product is listed twice). All other product listing pages only show the first product in the “row” format. (additional products are missing).

Thanks,
Danny

Daniel Osko

13 Nov 2013, 10:15 AM
#47
danielosko avatar

danielosko

Zen Follower

Join Date:
Dec 2008
Location:
Hanover Township PA, USA
Posts:
122
Plugin Contributions:
0

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

Hello Everyone,
Since no one seems to have gotten “bunyip’s” code working with Zencart 1.5.0 and the Flexible Product Listing plugin…, Does ANYONE know how to implement “yellow1912’s” 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));

Specifically:

  1. Which file is the code inserted into? (includes/templates/classic/tpl_modules_product_listing.php)???
  2. Where is the Category ID placed within the code?
  3. Can multiple Category ID’s be utilized?
  4. Should the NEW file be "product_listing_c_$c.php" or “product_listing_c.php”
  5. ANY other info required.

Thanks All,
Danny

Daniel Osko

13 Nov 2013, 4:22 PM
#48
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)?

  1. Yes, yellow1912's code goes at the very top of tpl_modules_product_listing.php: ```php
  • @version $Id: tpl_modules_product_listing.php 3241 2006-03-22 04:27:27Z ajeh $
    */
    include(DIR_WS_MODULES . zen_get_module_directory(FILENAME_PRODUCT_LISTING));

2) You don't specify the categories to get special templates in this code; that is handled dynamically.

3) Yes, you can have unlimited special product_listing files. The code is really elegant, and will use whatever is the most specific listing file available. You can have a generic special file for widgets, and an extra-special file for blue widgets, while red and green widgets get the generic special file. Most thingamabobs will get the stock listing file, but you can use a special file for purple thingamabobs.

4) Make a "product_listing_c_##.php" file for each variant, where ## is the broadest category id you want to use the file for.

5) The code will automatically use an applicable listing file if it exists, or else use the stock one. No other action is required.
13 Nov 2013, 4:31 PM
#49
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)?

Each category ID is separated by a numeric factor of 100 so that future categories can be added without effecting the presently used category ID’s. Odd... the category id is supposed to be an auto-incrementing field, and the id is not needed for any kind of sorting anyway, not to mention that you should not be able to "affect the presently used category ID's". You can set the category sort orders independently. How do you get the ids spaced out, and how will you later insert new ids into the sequence? Sounds risky to me...

13 Nov 2013, 10:54 PM
#50
danielosko avatar

danielosko

Zen Follower

Join Date:
Dec 2008
Location:
Hanover Township PA, USA
Posts:
122
Plugin Contributions:
0

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

AWSOME! FANTASTIC! I LOVE IT!

I cannot tell you how frickin happy I am! I have wanted to implement this since 2009. YOU are the MAN!

I, on the other hand, am an idiot. I had the product_listing.php and the tpl_modules_product_listing.php files both listed in two different places and causing conflicts..., (probably from all of the plugins over the years) and I had a "space" in the product_listing _##.php file I was testing. DUH!

So, the **product_listing.php **and the product_listing_##.php files go under:
"includes/modules/"

and the tpl_modules_product_listing.php file goes under:
"includes/templates/YOUR_TEMPLATE/templates/"

I can hardly wait to launch this new site.

Again, THANK YOU! THANK YOU! THANK YOU!
Danny:D

Daniel Osko

13 Nov 2013, 11:10 PM
#51
danielosko avatar

danielosko

Zen Follower

Join Date:
Dec 2008
Location:
Hanover Township PA, USA
Posts:
122
Plugin Contributions:
0

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

Hi Glenn,

I developed an Excel program which allows me to mass upload data to my SQL database. I have an input page which shoots out info to populate the products, products_description and products_to_categories SQL Files. It also includes the category and category_description SQL files.

Since I like to keep all the categories and sub-categories in alpha/numeric order.., this is a great way of visually seeing them. And since I have a 100 number space between them, I can easily add more categories or sub-categories to them. It also makes it easier to add an image and/or text in the "categories_description" column or add a custom category button image.

It may sound a little crazy, but I like it.
Danny

Daniel Osko

15 Nov 2013, 1:53 AM
#52
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)?

As long as you are competent and comfortable manipulating your database directly as you describe, that's great. I would caution anyone else reading this that the approach can easily corrupt your database if you make a mistake, and should not be attempted by anyone but a pro.