These were being generated through the Categories Tabs Menu ON/OFF :oops:Quote:
...now have a row of category listings above the EZ Page line that cannot be removed
...and I still cannot get this (either of these?) modules working...
Printable View
These were being generated through the Categories Tabs Menu ON/OFF :oops:Quote:
...now have a row of category listings above the EZ Page line that cannot be removed
...and I still cannot get this (either of these?) modules working...
It replaces the original tree of ZenCart, it uses a single query to retrieve the tree along with caching through session, so it saves the resources. (if you have a large number of cats, you will notice a difference in loading speed)Quote:
What is the purpose of Simple Category Tree?
You will the have to style the tree the way you want, of course.
This module can also let you retrieve more than 1 trees, for example: some people want to break the tree into multiple boxes. This module let you prints out part of the tree only, so you can print out only the sub-categories of the current category for example. It also allows you to limit the number of category level it will display....
Zencart does not list products of the categories that contain only subcats, this module helps you to do that.Quote:
I am not sure what use the all_sub_cats_products would then be.
Thank-you, Yellow1912, the confusion of files is beginning to make sense now and I can now more clearly see the scale of potential visualised by other people posting on this thread.
So my next question is how do I get this working?
I can see that first of all I need to get Simple Catergory Tree working, so I have uploaded the auto_loaders file and the classes file, but am now not sure where to go from here.
I have checked the Layout Boxes Controller but don't see anything there, so is there where I need to create two files of my own? ...and where would they go ...and what should they contain to get me going?
I don't need a precise idiot's guide, here - just some pointers whilst I familiarise myself with the file structure of Zen Cart and apply some of what I have seen already in the posts on this thread.
If I remember correctly, I included in the readme a very short example as how to create a new sidebox that contains the new category tree. Is the instruction included in the package you downloaded? Did you have any problem following the instruction? Or did you follow it yet the sidebox still doesnt show up in admin?
Regards
I am not sure about the readme.txt, but I think that you would use the code lines in there to modify the code in the sample_sidebox.txt
So, looking at the code contained therein
I would need to create two files, my_categories.php (which would be placed inCode:includes/modules/sideboxes/my_categories.php
PHP Code:
<?php
require($template->get_template_dir('tpl_categories.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_my_categories.php');
$title = 'Simple Categories Tree Demo';
$title_link = false;
require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
?>
includes/templates/template_default/sideboxes/tpl_my_categories.php
PHP Code:
<?php
$content = '';
$content .= $_SESSION['category_tree']->build_category_string('ul', 'li', '', 0, 2);
?>
includes/templates/custom_templates/sideboxes)
...and tpl_my_categories.php (which would be placed in
includes/templates/custom_templates/templates)?
...the whole of which would then require activating in the Layout Boxes Controller?
Two further question, though:
Would this would display correctly in centercolumn or would it be a sidebox only display?
What needs to go into the tpl_my_categories.php?
You got it right.
Note that the code just shows you how to create a new sidebox which contains the new category tree.
You can follow the example to create more than 1 sideboxes (say 1 sidebox only show the top categories, while the other one only shows the subcategories of the current visited category)
And nothing can stop you from displaying the tree ANYWHERE on your site:
echo
$_SESSION['category_tree']->build_category_string('ul', 'li', '', 0, 2);
Please read the document and perhaps check the code to see which parameter does what.
Thank-you, Yellow!
So what about that tpl_my_categories.php (sorry, - amended things whilst you were posting!)? - Does that need to contain anything or is it OK as a blank file?
...and when you say sideboxes, that would include the centercolumn area would it not?
Thanks, again.
That code explains where I went wrong when I first tried to use this - blank tpl_my_categories.php...
Then the 0,2 references from the root of the category tree and depth (number of levels), so change according to preference?
Then (for anyone else reading this) the li can be styled through CSS and given a CSS class name.
In case you had not already guessed I am asking some of questions in order to make things perfectly clear not just for myself, but also for anyone else wanting to use your contributions.
Taken from the readme:
This class is very simple to use, you have only a few functions that you can call:
1. Basic:
a. build_category_string($parent_tag = 'div', $child_tag = 'span', $divider = '', $categories_id = 0,
$max_level = 9, $include_root = false, $strict = false)
--> This is the most important function, it will build and return the category string (already in html code) for you, all you have to do is to print it out.
As you can see, the function takes a number of parameters:
Let me draw a sample cat tree so that you can understand it better: (assuming we use the default params)
|<div class="level_0 has_sub">
|--------<span class="level_0 has_sub"> link here
|----------------|<div class="level_1 has_sub">
|----------------|--------<span class="level_1 no_sub">link here</span>
|----------------|--------<span class="level_1 has_sub current">link here</span>
|----------------|----------------|<div class="level_2 has_sub current">
|----------------|----------------|--------<span class="level_2 no_sub"> link here</span>
|----------------|----------------|--------<span class="level_2 no_sub"> link here</span>
|----------------|----------------|</div>
|----------------|</div>
</div>
And it goes on and on.
* $divider will be put between children (sub cats same level), so be careful when you use it along with parent_tag and child_tag, you may have invalid html code.
* $categories: the root of the tree, what it to start else where? pass the cat id there.
For instance, here is the code I used to build a tree based on the current Category current visiting:
if(isset($_GET['cPath']))
$_SESSION['category_tree']->build_category_string('ul', 'li', '', $_GET['cPath'], 2)
* $include_root: this is interesting, usually when you build a tree, you dont want to include the root of that tree, however, if you want to, set this to true.
* $strict: this is alsu interesting: the category tree will auto expand when you go into deeper sub cat (even if the max_level is exceeded). However, if you want it to always stick to the max level strictly, set this to true.
b. retrieve_cpath($categories_id)
--> The name said it all, you passed in the cat id, you get the whole cPath back, this will even accept cPath (in case you have part of the cPath and want to get back the complete cPath)
c. retrieve_categories_tree_array()
--> return the whole category tree, in case you want to play with it
d. retrieve_deepest_cats_array($categories_id)
--> Very very useful one, this one will return the deepest level sub cats of any given cat id. Given the way ZC works, you know that these cats are the ones that actually hold products. If you want to retrieve all products of a parent cat, this is the one you need.
This function returns an array of cat id
e. build_deepest_level_children()
--> if you want to use the function above(d), make sure you call this one first, this will build the info needed.