Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14
  1. #11
    Join Date
    Dec 2006
    Location
    Seligman, MO U.S.A.
    Posts
    2,101
    Plugin Contributions
    5

    Default Re: Using category image on the nav menu?

    Well, I've got it narrowed down.........I think. With this menu, the code has to be put into the includes/classes/categories_ul_generator.php

    I found code to call to the database for the Category images, gathered from includes/functions/functions_lookups.php

    I also found code to display the images from includes/templates/CUSTOM/templates/tpl_modules_category_icon_display.php

    So with these codes in there I get images.........but EVERY one of them is the "No Image" image. But no matter what I do, it won't display the correct Category icon.

    Maybe somebody can tell me what's wrong here?

    PHP Code:
    <?php
    //placeholder21// +----------------------------------------------------------------------+
    // |zen-cart Open Source E-commerce                                       |
    // +----------------------------------------------------------------------+
    // | Copyright(c) 2003 The zen-cart developers                           |
    // |                                                                      |
    // | http://www.zen-cart.com/index.php                                    |
    // |                                                                      |
    // | Portions Copyright(c) 2003 osCommerce                               |
    // +----------------------------------------------------------------------+
    // | This source file is subject to version 2.0 of the GPL license,       |
    // | that is bundled with this package in the file LICENSE, and is        |
    // | available through the world-wide-web at the following url:           |
    // | http://www.zen-cart.com/license/2_0.txt.                             |
    // | If you did not receive a copy of the zen-cart license and are unable |
    // | to obtain it through the world-wide-web, please send a note to       |
    // | [email protected] so we can mail you a copy immediately.          |
    // +----------------------------------------------------------------------+
    // $Id: categories_ul_generator.php 2004-07-11  DrByteZen $
    //      based on site_map.php v1.0.1 by networkdad 2004-06-04
    //

    class zen_categories_ul_generator {
        var 
    $root_category_id 0,
        
    $max_level 0,
        
    $data = array(),
        
    $parent_group_start_string '<ul%s>',
        
    $parent_group_end_string '</ul>',
        
    $child_start_string '<li%s>',
        
    $child_end_string '</li>',
        
    $spacer_string '
    '
    ,
        
    $spacer_multiplier 1;
        
        var 
    $document_types_list ' (3) ';
        
    // acceptable format example: ' (3, 4, 9, 22, 18) '    

    /*
     * Return category's image
     * TABLES: categories
     */
      
    function zen_get_categories_image($what_am_i) {
        global 
    $db;

        
    $the_categories_image_query"select categories_image from " TABLE_CATEGORIES " where categories_id= '" $what_am_i "'";
        
    $the_products_category $db->Execute($the_categories_image_query);

        return 
    $the_products_category->fields['categories_image'];
      }

        
        function 
    zen_categories_ul_generator($load_from_database true)
        {
            global 
    $languages_id$db;
            
    $this->data = array();
            
    $categories_query "select c.categories_id, cd.categories_name, c.parent_id, c.categories_image
                                            from " 
    TABLE_CATEGORIES " c, " TABLE_CATEGORIES_DESCRIPTION " cd, " TABLE_PRODUCT_TYPES_TO_CATEGORY " ptc
                                            where c.categories_id = cd.categories_id
                                            and c.categories_status=1 " 
    .
                                            
    " and cd.language_id = '" . (int)$_SESSION['languages_id'] . "' " .
                                            
    " order by c.parent_id, c.sort_order, cd.categories_name";
            
    $categories $db->Execute($categories_query);
            while (!
    $categories->EOF) {
                
    $this->data[$categories->fields['parent_id']][$categories->fields['categories_id']] = array('name' => $categories->fields['categories_name'], 'count' => 0);
                
    $categories->MoveNext();
            }
        }    

        
        function 
    buildBranch($parent_id$level$submenu=true$parent_link='')
        {
            
    $result sprintf($this->parent_group_start_string, ($submenu==true) ? ' class="level'. ($level+1) . '"' '' );
            
            if ((
    $this->data[$parent_id])) {
                foreach(
    $this->data[$parent_id] as $category_id => $category) {
                    
    $category_link $parent_link $category_id;
                    if ((
    $this->data[$category_id])) {
                        
    $result .= sprintf($this->child_start_string, ($submenu==true) ? ' class="submenu"' '');
                    } else {
                        
    $result .= sprintf($this->child_start_string'');
                    }
                    
    $result .= str_repeat($this->spacer_string$this->spacer_multiplier 1) . '<a href="' zen_href_link(FILENAME_DEFAULT'cPath=' $category_link) . '">' zen_image(DIR_WS_IMAGES zen_get_categories_image(zen_get_products_category_id((int)$_GET['products_id'])),zen_get_categories_name(zen_get_products_category_id((int)$_GET['products_id']), $_SESSION['languages_id']), CATEGORY_ICON_IMAGE_WIDTHCATEGORY_ICON_IMAGE_HEIGHT);
                    
    $result .= $category['name'];
                    
    $result .= '</a>';
                      
                    if ((
    $this->data[$category_id]) && (($this->max_level == '0') || ($this->max_level $level+1))) {
                        
    $result .= $this->buildBranch($category_id$level+1$submenu$category_link '_');
                    }
                    
    $result .= $this->child_end_string;
                }
            }
            
            
    $result .= $this->parent_group_end_string;
            return 
    $result;
        }
        
        function 
    buildTree($submenu=false)
        {
            return 
    $this->buildBranch($this->root_category_id''$submenu);
        }
    }
    ?>

    This is on a test site, but it IS live, so I can give you the url, if anybody wants to look at the results as of right now.
    Last edited by Get Em Fast; 24 Feb 2011 at 07:12 AM.
    Teach them to shop and they will shop today;
    Teach them to Zen and they will OWN a shop tomorrow!

  2. #12
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Using category image on the nav menu?

    The original version of that file has only one piece of data per category to put into the $data array:

    $this->data[$categories->fields['parent_id']][$categories->fields['categories_id']] = array('name' => $categories->fields['categories_name'], 'count' => 0);

    I think this is where you want to add the image field.

    $this->data[$categories->fields['parent_id']][$categories->fields['categories_id']] = array('name' => $categories->fields['categories_name'], 'count' => 0, 'image' => $categories->fields['categories_image']);

    Then you can retrieve $this->data['parent_id']['categories_id']['image'] later. I believe it will show up in the build_branch() function as $category['image'], analogous to $category['name'].

    foreach($this->data[$parent_id] as $category_id => $category)

    The original has
    PHP Code:
                    $result .= str_repeat($this->spacer_string$this->spacer_multiplier 1) . '<a href="' zen_href_link(FILENAME_DEFAULT'cPath=' $category_link) . '">';
                    
    $result .= $category['name']; 
    Maybe something like this:
    PHP Code:
                    $result .= str_repeat($this->spacer_string$this->spacer_multiplier 1) . '<a href="' zen_href_link(FILENAME_DEFAULT'cPath=' $category_link) . '">';
                    
    $result .= zen_image(DIR_WS_IMAGES $category['image'], $category['name'], CATEGORY_ICON_IMAGE_WIDTHCATEGORY_ICON_IMAGE_HEIGHT);
                    
    $result .= $category['name']; 

  3. #13
    Join Date
    Dec 2006
    Location
    Seligman, MO U.S.A.
    Posts
    2,101
    Plugin Contributions
    5

    Default Re: Using category image on the nav menu?

    AH-HA!!!!! That's it! That's exactly what I've been looking for. Man, I was SOOOO close the exactly that a dozen times.............but not quite. You wouldn't believe how many times I was so close..........well, now that I see it............I can't either.

    Anyway.........sending you a pm.
    Teach them to shop and they will shop today;
    Teach them to Zen and they will OWN a shop tomorrow!

  4. #14
    Join Date
    Dec 2006
    Location
    Seligman, MO U.S.A.
    Posts
    2,101
    Plugin Contributions
    5

    Default Re: Using category image on the nav menu?

    Well, I'm glad to know that I DID contribute to this little project, as it worked great on my site, but when added to the clients site, it was back to the old "No Image" image. So, I added the code in the above posts, and also had to add c.categories_image to the database query, as I had already added to mine. That done it. Worked like a charm on customers' site, as well........and looks very nice! I WILL include images on ALL levels, but he only wanted them on the Top level.
    Teach them to shop and they will shop today;
    Teach them to Zen and they will OWN a shop tomorrow!

 

 
Page 2 of 2 FirstFirst 12

Similar Threads

  1. Adding my own menu items to the nav
    By Momof9Blessings in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 8 Jul 2016, 05:01 PM
  2. using image for category menu
    By gogumagamza in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 12 Sep 2009, 11:27 PM
  3. Separate Nav Category Menu into multiple lines?
    By zkitten in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 8 Jun 2009, 12:02 PM
  4. Using a CSS Navigation Menu for the top NAV bar
    By spikeycactus in forum Templates, Stylesheets, Page Layout
    Replies: 8
    Last Post: 30 Oct 2008, 10:59 AM
  5. Category image in let hand nav?
    By roger06 in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 1 Sep 2008, 07:38 PM

Posting Permissions

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