Forums / General Questions / Showing product category in featured/new products

Showing product category in featured/new products

Locked

Started by mycompleteness on 21 Mar 2009, 5:28 AM · Views: 930

Results 1 to 7 of 7
This thread is locked. New replies are disabled.
21 Mar 2009, 5:28 AM
#1
mycompleteness avatar

mycompleteness

New Zenner

Join Date:
Mar 2009
Posts:
14
Plugin Contributions:
0

Showing product category in featured/new products

Hi there,

The store I'm setting up is comprised of music albums and singles.

There is not much to separate the albums and singles apart from the categories. But when the products are placed in either the "featured products" or "new products" boxes on the main page, you can't tell what is what.

I'm wondering if there's a way to list under each product (in the "new" and "featured" boxes) what it's originating category is, ie:

(PICTURE OF PRODUCT)
(name of product)
(category)
(price)

I'm expecting there's a little bit of coding to be done to make this happen, so if someone could let me know what code I might need to place (and in what file), I'd be very very happy!

Cheers,
Sarah

21 Mar 2009, 4:25 PM
#2
ajeh avatar

ajeh

Oba-san

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

Re: Showing product category in featured/new products

For files where you do not know the categories_id, you could use:
zen_categories_lookup(zen_products_lookup($products_new->fields['products_id'], 'master_categories_id'))

Where the one function looks up the categories_name from the master_categories_id of the product ...

Just use the appropriate products_id where the:
$products_new->fields['products_id']

is being used in the function ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

22 Mar 2009, 2:03 AM
#3
mycompleteness avatar

mycompleteness

New Zenner

Join Date:
Mar 2009
Posts:
14
Plugin Contributions:
0

Re: Showing product category in featured/new products

I'm sorry but I'm not that advanced to understand where that code needs to go :P

Please correct me if I'm wrong, but I think the code needs to go somewhere in the files /includes/templates/template_default/templates/tpl_modules_products_featured_listing.php and /includes/templates/template_default/templates/tpl_modules_products_new_listing.php, however there is so much PHP in those that I'm really unsure (those files list everything including name, weight, model, price, etc).

I only need to add the category below the featured and new products on the main page in the center column, not anywhere else on the site.

Thanks.

22 Mar 2009, 3:48 AM
#4
ajeh avatar

ajeh

Oba-san

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

Re: Showing product category in featured/new products

Actually you want to copy the files:
/includes/modules/featured_products.php
/includes/modules/new_products.php

to your templates and overrides:
/includes/modules/your_template_dir/featured_products.php
/includes/modules/your_template_dir/new_products.php

and customize the code there to add that code for the categories_name ...

Look for how the products_id is referred to in the code and you need to reference it the same way ...

For example in the featured_products.php around line 71 or so I changed the code to read:

// find categories_name
$cat_name = zen_categories_lookup(zen_products_lookup($featured_products->fields['products_id'], 'master_categories_id'), 'categories_name');
    $list_box_contents[$row][$col] = array('params' =>'class="centerBoxContentsFeatured centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"',
    'text' => (($featured_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'cPath=' . $productsInCategory[$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><br />') . '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'cPath=' . $productsInCategory[$featured_products->fields['products_id']] . '&products_id=' . $featured_products->fields['products_id']) . '">' . $featured_products->fields['products_name'] . '</a><br />' . $cat_name . '<br />' . $products_price);

NOTE: None of this is going to work if you do not add the Known Bug Fixes for v1.3.8 at:
http://www.zen-cart.com/forum/showthread.php?p=697924#post697924

specifically post #30 ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

22 Mar 2009, 3:50 AM
#5
ajeh avatar

ajeh

Oba-san

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

Re: Showing product category in featured/new products

Note: I did add the paramater for 'categories_name' that I did not include in my first post ... but this is option for that field only in the categories lookup function because that is the default value sent back if nothing is specified ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

22 Mar 2009, 5:01 AM
#6
mycompleteness avatar

mycompleteness

New Zenner

Join Date:
Mar 2009
Posts:
14
Plugin Contributions:
0

Re: Showing product category in featured/new products

Works a treat, it's exactly what I wanted to do.

Thanks for the heads up about the bug fixes too.

Cheers! :D

22 Mar 2009, 1:55 PM
#7
ajeh avatar

ajeh

Oba-san

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

Re: Showing product category in featured/new products

You are most welcome and glad that this worked for you ... thanks for the update ... :smile:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!