Page 2 of 25 FirstFirst 123412 ... LastLast
Results 11 to 20 of 249
  1. #11
    Join Date
    Oct 2006
    Posts
    5,477
    Plugin Contributions
    11

    Default Re: Simple Category Tree

    Also, dont forget to clear cache/session or set define ('SCT_REBUILD_TREE','true'); when you test the new code.
    Otherwise the mod will use the prebuilt tree.
    I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

  2. #12
    Join Date
    Mar 2004
    Location
    Calgary, Alberta
    Posts
    290
    Plugin Contributions
    1

    Default Re: Simple Category Tree

    Okay I'm puzzled....

    did the change, that message went away. Now no messages, just a blank page, even with e_strict, with the debug turned on, the display_on, etc, and nada, nothing....

  3. #13
    Join Date
    Oct 2006
    Posts
    5,477
    Plugin Contributions
    11

    Default Re: Simple Category Tree

    a link to the site?
    I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

  4. #14
    Join Date
    Oct 2006
    Posts
    5,477
    Plugin Contributions
    11

    Default Re: Simple Category Tree

    Oops *_*
    Last edited by yellow1912; 11 Feb 2008 at 11:22 AM.
    I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

  5. #15
    Join Date
    Mar 2004
    Location
    Calgary, Alberta
    Posts
    290
    Plugin Contributions
    1

    Default Re: Simple Category Tree

    www.totalgarage.ca/products is the site, and just updated the files,

    [11-Feb-2008 03:28:48] PHP Fatal error: Call to a member function init() on a non-object in Products\includes\autoload_func.php on line 90

  6. #16
    Join Date
    Oct 2006
    Posts
    5,477
    Plugin Contributions
    11

    Default Re: Simple Category Tree

    And is strict error turned on here?
    I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

  7. #17
    Join Date
    Mar 2004
    Location
    Calgary, Alberta
    Posts
    290
    Plugin Contributions
    1

    Default Re: Simple Category Tree

    I created the /includes/local/configure.php file with the

    <?php
    define('STRICT_ERROR_REPORTING', true);
    ?>

  8. #18
    Join Date
    Oct 2006
    Posts
    5,477
    Plugin Contributions
    11

    Default Re: Simple Category Tree

    Huhm, it's weird seeing how nothing is printed out, since the class is working fine on my site (cant post link here since it's on localhost)

    I just wonder why it doesnt print out any error though, weird, lol

    Just to test, try putting this right below the <?php in the simple category class file:
    die("blah");
    I just wonder if the file is even read and executed, that's all.
    If you see blah appears on the site, then you know it's read and excuted. Then you can cut that line and paste it somewhere below that, probably in the init function, and so on and so forth to see where the code stops executing.

    Normally, turning on strict error report will point out where the error is right away, i dont know why it doesnt work here though.
    I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

  9. #19
    Join Date
    Oct 2006
    Posts
    5,477
    Plugin Contributions
    11

    Default Re: Simple Category Tree

    Also, below is the updated code that should fix the error with rebuild switch having no effect at all:

    PHP Code:
    <?php
    /**
     * Simple Category Tree
     * @Version: Beta 1
     * @Authour: yellow1912
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     */ 

    define ('SCT_REBUILD_TREE','true');
    class 
    simple_categories_generator{
        var 
    $category_tree = array();
        var 
    $parent_open_tag '';
        var 
    $parent_close_tag '';
        var 
    $child_open_tag '';
        var 
    $child_close_tag '';
        function 
    simple_categories_generator() {}
        function 
    init(){
            if(
    SCT_REBUILD_TREE != 'false' || count($this->category_tree) == 0){
                global 
    $languages_id$db;
                
    $categories_query "select c.categories_id, cd.categories_name, c.parent_id
                              from " 
    TABLE_CATEGORIES " c, " TABLE_CATEGORIES_DESCRIPTION " cd
                              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);

                
    // reset the tree first
                
    $this->category_tree = array(); 
                while (!
    $categories->EOF) {
                    
    $this->category_tree[$categories->fields['categories_id']] = array('name' => $categories->fields['categories_name'],
                    
    'parent_id' => $categories->fields['parent_id']);
                    
    $this->category_tree[$categories->fields['categories_id']]['path'][] = $categories->fields['categories_id'];
                    
    $this->category_tree[$categories->fields['parent_id']]['sub_cats'][] = $categories->fields['categories_id'];
                    
    $categories->MoveNext();
                }
                
                
    // walk through the array and build sub/cPath and other addtional info needed
                
    foreach($this->category_tree as $key => $value){
                    
    // add sub 'class' for print-out purpose
                    
    $this->category_tree[$key]['sub'] = isset($this->category_tree[$key]['sub_cats']) ? 'has_sub' 'no_sub';
                    
    // only merge if parent cat is not 0
                    
    if($this->category_tree[$key]['parent_id'] > 0){
                        if(
    is_array($this->category_tree[$this->category_tree[$key]['parent_id']]['path']) && count($this->category_tree[$this->category_tree[$key]['parent_id']]['path'])> 0)
                            
    $this->category_tree[$key]['path'] = array_merge($this->category_tree[$this->category_tree[$key]['parent_id']]['path'],$this->category_tree[$key]['path']);
                    }
                    
    $this->category_tree[$key]['cPath'] = is_array($this->category_tree[$key]['path']) ? implode('_',$this->category_tree[$key]['path']) : $key;
        
                }
                
    // for debugging using super global mod
                
    $_POST['category_tree'] = $this->category_tree;
            }
        }
        
    // 9 is a ridiculous level already. If you go deeper than that, you have some problem with performance + structure
        // Max level should be around 3
        
    function build_category_string($parent_tag 'div'$child_tag 'span'$divider ''$categories_id 0$max_level 9$include_root false){
            if(!
    is_int($categories_id)){
                
    $temp explode('_',$categories_id);
                
    $categories_id $temp(count($temp)-1);
            }
            
            
    $result '';
            
    // don't check if max_level = 0, since we assume store owners are not crazy enough to do that
            // --> less check = faster
            
    if(isset($this->category_tree[$categories_id])){
                
    // 
                
    $sub $this->category_tree[$categories_id]['sub'];
                
    $level 0;
                
    $class "level_$level $sub";
                
    $this->_build_tags($parent_tag$child_tag);
                
    // check if we should include the root or only its branches
                
    if($include_root && $categories_id 0){
                    
    $result sprintf($this->parent_open_tag$class).sprintf($this->child_open_tag$class);
                    
    $result .= $this->_build_category_string($categories_id$level$max_level$divider);
                    
    $result .= $this->child_close_tag.$this->parent_close_tag;
                }
                else{
                    
    $result .= $this->__build_category_string($categories_id$level$max_level$divider);
                }
                
            }
            return 
    $result;
        }

        function 
    _build_category_string($categories_id$level$max_level$divider){        
            
    $result $this->build_category_link($this->category_tree[$categories_id]['name'],$this->category_tree[$categories_id]['cPath']);
            
    $level++;
            
    $result .= $this->__build_category_string($categories_id$level$max_level$divider);
            return 
    $result;
        }

        function 
    __build_category_string($categories_id$level$max_level$divider){
            
    $result '';
            if(
    $level $max_level){        
                
    $sub $this->category_tree[$categories_id]['sub'];
                
    $class "level_$level $sub";
                if(isset(
    $this->category_tree[$categories_id]['sub_cats'])){
                        
    $result .= sprintf($this->parent_open_tag$class);
                        
    $count count($this->category_tree[$categories_id]['sub_cats']);
                        for(
    $i=0$i $count$i++){
                            
    $sub $this->category_tree[$value]['sub'];
                            
    $class "level_$level $sub";
                            
    $result .= sprintf($this->child_open_tag$class).$this->_build_category_string($this->category_tree[$categories_id]['sub_cats'][$i],$level,$max_level$divider).$this->child_close_tag;
                            
    $result .= ($i < ($count-1)) ? $divider '';
                        }
                        
    $result .= $this->parent_close_tag;
                    }
            }
            return 
    $result;
        }
        
        function 
    _build_tags($parent_tag$child_tag){
            if(!empty(
    $parent_tag)){
                
    $this->parent_open_tag "<$parent_tag class='%s'>";
                
    $this->parent_close_tag "</$parent_tag>";        
            }
            else{
                
    $this->parent_open_tag $this->parent_close_tag '';        
            }
            if(!empty(
    $child_tag)){
                
    $this->child_open_tag "<$child_tag class='%s'>";
                
    $this->child_close_tag "</$child_tag>";        
            }
            else{
                
    $this->child_open_tag $this->child_close_tag '';
            }
        }
        
        function 
    build_category_link($categories_name$cPath){
            return 
    '<a href="' zen_href_link(FILENAME_DEFAULT'cPath=' $cPath) . '">'.$categories_name.'</a>';
        }
    }
    ?>

    new auto loader:
    PHP Code:
    <?php
    /**
     * ch_categories_tree_generator
     * @Version: 
     * @Authour: 
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     */ 
    if (!defined('IS_ADMIN_FLAG')) {
        die(
    'Illegal Access');
    }
    $autoLoadConfig[0][] = array('autoType'=>'class''loadFile'=> 'simple_categories_generator.php');
    $autoLoadConfig[180][] = array('autoType'=>'classInstantiate',
                                    
    'className'=>'simple_categories_generator',
                                    
    'objectName'=>'category_tree',
                                    
    'checkInstantiated'=>true,
                                    
    'classSession'=>true);
    $autoLoadConfig[180][] = array('autoType'=>'objectMethod',
                                    
    'objectName'=>'category_tree',
                                    
    'methodName' => 'init');

    ?>
    I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

  10. #20
    Join Date
    Mar 2004
    Location
    Calgary, Alberta
    Posts
    290
    Plugin Contributions
    1

    Default Re: Simple Category Tree

    die(..) worked.

    I did have to change the file name in the auto loader as 'simple_categories_generator.php' was simple_categories_tree_generator.php

 

 
Page 2 of 25 FirstFirst 123412 ... LastLast

Similar Threads

  1. Category Tree
    By fneergaard in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 13 Aug 2010, 11:42 PM
  2. Redesigning Category Tree
    By moomo in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 30 Dec 2009, 01:53 PM
  3. Category tree
    By ner0tik in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 10 Aug 2006, 02:19 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
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR