Page 1 of 2 12 LastLast
Results 1 to 10 of 27

Hybrid View

  1. #1
    Join Date
    Oct 2007
    Posts
    7
    Plugin Contributions
    0

    Default Add Category Name to Product Listing above description

    Is it possible to add the "Catagory Name" below the "Product's Name" on the product listing pages (right above the description)?

    I assume that this can be done by adding a line of code in the Product Listing Files (such as the tpl_modules_products_new_listing.php file, etc...), however I have no idea what the code is that you would add.

    Any suggestions on what code to add to the product listing files?

  2. #2
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    64,672
    Plugin Contributions
    6

    Default Re: Add Category Name to Product Listing above description

    The easiest way is to use a function call for it:
    zen_categories_lookup($categories_id)

    where $categories_id would be the one you are in ... for example, on the Product Listing module you should be able to use:
    zen_categories_lookup($current_category_id)

    to display the current categories_name ...
    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: v1.5.1]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...

  3. #3
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    64,672
    Plugin Contributions
    6

    Default Re: Add Category Name to Product Listing above description

    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 ...
    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: v1.5.1]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...

  4. #4
    Join Date
    Oct 2007
    Posts
    7
    Plugin Contributions
    0

    Default Re: Add Category Name to Product Listing above description

    Linda,

    Thanks for the fast reply… YOU ARE AWESOME! Your posts have been a huge help to me on this forum!

    I hate to be a pain, but I could use a little more help on this – I just don’t know anything about code (I barely know enough to figure out which files produce the code that makes the product listings).

    Would it be possible for you to show me what code to put on which lines (maybe using the Product Listing Module as an example)? And then I can change it on the other files from your example.

    Thanks for any assistance you can give!

  5. #5
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    64,672
    Plugin Contributions
    6

    Default Re: Add Category Name to Product Listing above description

    On the New Products Listing you can:

    Try copying the file:
    /includes/templates/templates_default/templates/tpl_modules_products_new_listing.php

    to your templates and overrides directory:
    /includes/templates/your_template_dir/templates/tpl_modules_products_new_listing.php

    and edit it and change:
    PHP Code:
          if (PRODUCT_NEW_LIST_NAME != '0') {
            
    $display_products_name '<a href="' zen_href_link(zen_get_info_page($products_new->fields['products_id']), 'cPath=' zen_get_generated_category_path_rev($products_new->fields['master_categories_id']) . '&products_id=' $products_new->fields['products_id']) . '"><strong>' $products_new->fields['products_name'] . '</strong></a>' str_repeat('<br clear="all" />'substr(PRODUCT_NEW_LIST_NAME31)); 
    to read:
    PHP Code:
          if (PRODUCT_NEW_LIST_NAME != '0') {
    //        $display_products_name = '<a href="' . zen_href_link(zen_get_info_page($products_new->fields['products_id']), 'cPath=' . zen_get_generated_category_path_rev($products_new->fields['master_categories_id']) . '&products_id=' . $products_new->fields['products_id']) . '"><strong>' . $products_new->fields['products_name'] . '</strong></a>' . str_repeat('<br clear="all" />', substr(PRODUCT_NEW_LIST_NAME, 3, 1));
            
    $show_cat_name zen_categories_lookup(zen_products_lookup($products_new->fields['products_id'], 'master_categories_id'));
            
    $display_products_name '<a href="' zen_href_link(zen_get_info_page($products_new->fields['products_id']), 'cPath=' zen_get_generated_category_path_rev($products_new->fields['master_categories_id']) . '&products_id=' $products_new->fields['products_id']) . '"><strong>' $products_new->fields['products_name'] . '</strong></a>' '<br>cat: ' $show_cat_name str_repeat('<br clear="all" />'substr(PRODUCT_NEW_LIST_NAME31)); 
    On the Product Listing you can copy the module:
    /includes/modules/products_listing.php

    to your templates and overrides directory:
    /includes/modules/your_template_dir/products_listing.php

    and change:
    PHP Code:
            if (isset($_GET['manufacturers_id'])) {
              
    $lc_text '<h3 class="itemTitle"><a href="' zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > and $_GET['filter_id']) > ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' $listing->fields['products_id']) . '">' $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>' ;
            } else {
              
    $lc_text '<h3 class="itemTitle"><a href="' zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > and $_GET['filter_id']) > ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' $listing->fields['products_id']) . '">' $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>';
            } 
    to read:
    PHP Code:
            $show_cat_name zen_categories_lookup(zen_products_lookup($listing->fields['products_id'], 'master_categories_id'));
            if (isset(
    $_GET['manufacturers_id'])) {
              
    $lc_text '<h3 class="itemTitle"><a href="' zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > and $_GET['filter_id']) > ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' $listing->fields['products_id']) . '">' $listing->fields['products_name'] . '<br />Cat: ' $show_cat_name '</a></h3><div class="listingDescription">' zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>' ;
            } else {
              
    $lc_text '<h3 class="itemTitle"><a href="' zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > and $_GET['filter_id']) > ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' $listing->fields['products_id']) . '">' $listing->fields['products_name'] . '<br />Cat: ' $show_cat_name '</a></h3><div class="listingDescription">' zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>';
            } 
    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: v1.5.1]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...

  6. #6
    Join Date
    Oct 2007
    Posts
    7
    Plugin Contributions
    0

    Default Re: Add Category Name to Product Listing above description

    Thanks Linda!

    Works like a charm!

    I really appreciate it! Thank you SO MUCH!

  7. #7
    Join Date
    Nov 2008
    Location
    Jervis Bay, NSW Australi
    Posts
    16
    Plugin Contributions
    0

    red flag Re: Add Category Name to Product Listing above description

    Quote Originally Posted by Ajeh View Post
    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 ...
    Hi Linda,

    How would this work on the shopping cart page? there is no product id or cPath id to work with - I wish for my product description links in the shopping cart to link back to the main categorie and not directly back to the product - I tried too many hours to figure out a method for this and I cant, I dont know how to call the product id - the varibles in the shopping cart page confused me too much - now im tired.

    there must be away, my site operates on a very different format from most sites and I am using categories like a mother product for a family of linked products - I cant really explain how it works but I will show case this site when Im done, and will release the template minus a few copyrighted logos & images back to the Zen community in a few weeks.

    Cheers Lee.
    nup, I got nothen.

  8. #8
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    64,672
    Plugin Contributions
    6

    Default Re: Add Category Name to Product Listing above description

    For the shopping_cart see if using for the products_id if:
    $product['id']

    works better for you to obtain the master_categories_id of the product ...
    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: v1.5.1]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...

  9. #9
    Join Date
    Nov 2008
    Location
    Jervis Bay, NSW Australi
    Posts
    16
    Plugin Contributions
    0

    Default Re: Add Category Name to Product Listing above description

    Quote Originally Posted by Ajeh View Post
    For the shopping_cart see if using for the products_id if:
    $product['id']

    works better for you to obtain the master_categories_id of the product ...
    Yes it done the job, thank you Linda.

    I then tried to create a new function that returned the products category_id from the products_id (I managed to dig up some relevant old code from a post you done on the osComerce forum:

    zen_get_products_category_id($products_id)

    and it kept braking the site, stupid me = turns out this function already existed in Zen Cart.... thats why the function would not work.

    I still dont know which file the actual function is located in, I assumed it would have been in the functions_categories.php file?

    I dont want to change it, its works just the way I need it too.

    does the Zen Cart Wiki explain what functions are available too use when customizing a store and a brief run down of what they do?
    nup, I got nothen.

  10. #10
    Join Date
    May 2011
    Posts
    6
    Plugin Contributions
    0

    Default Re: Add Category Name to Product Listing above description

    Quote Originally Posted by Ajeh View Post
    For the shopping_cart see if using for the products_id if:
    $product['id']

    works better for you to obtain the master_categories_id of the product ...
    Hi Guys,

    I know this is an extremely old post but I have been stuck on this all afternoon - hopefully someone can shed some more light on this issue. Not sure if you are still around Linda...

    I am looking to display the category name of each item on the shopping cart page. I have followed suggestions found here and I know this is a peculiar issue. I have been able to display master_categories_id and one would assume that displaying a name instead of the id is possible on the shopping cart page.
    I just cannot figure this one out.

    Linda you have been a wonderful help in this post. Thank you very much if you do happen to fly by.

    Any help or suggestions would be greatly appreciated.

    P.s. I am currently running the latest version of Zen Cart.

    Regards,
    Evan

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. description under sub-category listing
    By stefknits in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 3 Mar 2008, 07:43 PM
  2. description under sub-category listing
    By stefknits in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 28 Feb 2008, 09:26 PM
  3. adding description to category listing
    By jonathan_pohl in forum Templates, Stylesheets, Page Layout
    Replies: 11
    Last Post: 12 Feb 2008, 12:48 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •