Forums / All Other Contributions/Addons / Simple Category Tree

Simple Category Tree

Views: 97,118

Results 181 to 200 of 249
26 Oct 2008, 7:49 AM
#181
some_name_not_taken avatar

some_name_not_taken

Zen Follower

Join Date:
Sep 2008
Posts:
106
Plugin Contributions:
0

Simple Category Tree

yellow1912:

What are you trying to do?

Define session, then call on session with $content by the looks of things.

So I have now changed the code as follows

<?php $_SESSION['category_tree']->build_deepest_level_children(), retrieve_cpath(); $content .= $_SESSION['category_tree']->build_category_string('ul', 'li', '', 0, 2); ?>

...but this, too, is not correct.

26 Oct 2008, 7:51 AM
#182
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Simple Category Tree

Define session, then call on session with $content by the looks of things.

--> Can you explain?

And the code you posted is wrong by the way, what are you trying to do with retrieve_cpath()?

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

26 Oct 2008, 7:58 AM
#183
some_name_not_taken avatar

some_name_not_taken

Zen Follower

Join Date:
Sep 2008
Posts:
106
Plugin Contributions:
0

Re: Simple Category Tree

I am just trying to make the tree display as follows:

category1
subcategory1
product1
category2
subcategory2
product2

etc.

If $session needs to define all that is then called on by $content to build the desired tree it is logical to assume that all that needs to be defined, except the layout parameters (which appear to be handled by $content), needs to be defined in the $session, so I need to work out some way of entering more definitions into the $session line or some way of being able to call on multiple $session variables in the $content line.

26 Oct 2008, 8:03 AM
#184
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Simple Category Tree

Note:
This tree does not contain product, you will have to modify it if you want it to do what you want.

I think you may need to read more about php regarding:

  1. Class and methods
  2. Session

You will also need to know that $content is simply a normal variable, it just happens that the way Zen sidebox works is: you stuff all the content of the sidebox into this variable, and Zen will print it out for you.

You can always do something like

$content = '';

$content .= 'first line<br />';
$content .= 'second line<br />';

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

26 Oct 2008, 8:11 AM
#185
some_name_not_taken avatar

some_name_not_taken

Zen Follower

Join Date:
Sep 2008
Posts:
106
Plugin Contributions:
0

Re: Simple Category Tree

Yes, I do need to update my knowledge of PHP, but practical usually works best for me and once I have the outline I will quickly develop my skills where Zen Cart is concerned.

I now have the following (working) code...

...but still not to products level

<?php
$content = '';
$content .= $_SESSION['category_tree']->build_category_string('ul', 'li', '', 0, 2);
$content .= $_SESSION['category_tree']->build_deepest_level_children();
$content .= $_SESSION['category_tree']->retrieve_categories_tree_array();
?>

I guess that when you said about adding products myself you were meaning that the tree does not contain that kind of functionality, so I would have to expand on the existing code and effectively build a new module? ...and the simple_category_tree and all_subcat_produts can only give you tree levels down to subcategory only?

26 Oct 2008, 8:16 AM
#186
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Simple Category Tree

Yes, the tree does not go to product level, you will have to add that if you want to, basically it's not so hard, just traverse the tree and query products id then attach them there.
This type of functionality is not planned for this module in any near future, but you can add if you want to.

There is a module in the download that returns a tree with product level, however.

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

26 Oct 2008, 8:31 AM
#187
some_name_not_taken avatar

some_name_not_taken

Zen Follower

Join Date:
Sep 2008
Posts:
106
Plugin Contributions:
0

Re: Simple Category Tree

yellow1912:

Yes, the tree does not go to product level, you will have to add that if you want to, basically it's not so hard, just traverse the tree and query products id then attach them there.
This type of functionality is not planned for this module in any near future, but you can add if you want to.

There is a module in the download that returns a tree with product level, however.

modules -> pages -> index -> header_php.php?

OK, thanks, but as the files from all_subcats_products basically overwrote the existing files for simple_category_tree that should mean that the line

$_SESSION['category_tree']->build_deepest_level_children();

will retrieve things on a product level, otherwise this line effectively does nothing.

26 Oct 2008, 8:43 AM
#188
some_name_not_taken avatar

some_name_not_taken

Zen Follower

Join Date:
Sep 2008
Posts:
106
Plugin Contributions:
0

Re: Simple Category Tree

The code still won't display subcategories...

$_SESSION['category_tree']->build_deepest_level_children()

...simple, yes, but still not working.

Full code

<?php
$content = '';
$content .= $_SESSION['category_tree']->build_category_string('ul', 'li', '', 0, 2);
$content .= $_SESSION['category_tree']->build_deepest_level_children();
$content .= $_SESSION['category_tree']->retrieve_cpath()
?>
26 Oct 2008, 9:06 AM
#189
some_name_not_taken avatar

some_name_not_taken

Zen Follower

Join Date:
Sep 2008
Posts:
106
Plugin Contributions:
0

Re: Simple Category Tree

Right, I've added a 'li' value to accomodate the subcategory line, but cannot get the subcategory to display - I just get li showing where the subcategory should be.

(The first number in the brackets indicates the category ID, so a value of 0 shows all category IDs, but 1 would only show category 1, 2 for category 2 only, etc. whilst the second number controls the subcategories... if you can get them to display, that is).

26 Oct 2008, 9:16 AM
#190
some_name_not_taken avatar

some_name_not_taken

Zen Follower

Join Date:
Sep 2008
Posts:
106
Plugin Contributions:
0

Re: Simple Category Tree

So, it looks like even with the correct syntax subcategories, like actual products, cannot be displayed either ...and certainly not in any kind of unordered list.

Well, it would have been useful to know that several hours ago.

Thanks for your time and help anyway, Yellow.

26 Oct 2008, 9:25 AM
#191
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Simple Category Tree

some name not taken:

So, it looks like even with the correct syntax subcategories, like actual products, cannot be displayed either ...and certainly not in any kind of unordered list.

Well, it would have been useful to know that several hours ago.

Thanks for your time and help anyway, Yellow.
Subcategories can be displayed, if not what is the use of a category tree? products are not supported by this tree tho. You really need to read php document by the way, practice is good but you need a base knowledge first, just hacking around the code will waste you more time.

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

26 Oct 2008, 9:46 AM
#192
some_name_not_taken avatar

some_name_not_taken

Zen Follower

Join Date:
Sep 2008
Posts:
106
Plugin Contributions:
0

Re: Simple Category Tree

True, but hacking around the code gives me insight into how things work, so when I'm reading about the subject I have an actual frame of reference to work with.

At the moment I am reading online information, trying to apply it, coming up with nothing and wasting allot of time.

I have looked at the previous posts on this thread, found more information, applied it... and come up with nothing.

Without some kind of working model to work with I cannot make any progress. - I do not want somebody to put my site together (or even the menu) but a little more information would be really useful even if it just gets the submenus displaying because then I would be able to tweak it and apply the working know-how to other things.

This also applies to many other frustrated users (and all too many ex-users) of Zen Cart, who, like myself, are quite prepared to develop their skills but who need a little help with their initial projects and development of their stores.

As you will have noticed I have been making a point of highlighting how things are done with this contribution with the specific aim of helping other people, so what happens when they see that I have abandoned trying to get this working and that yet another good idea is something beyond their skills? - Many will simply have had enough and abandon Zen Cart and, whether they do or not, Zen Cart will suffer.

26 Oct 2008, 3:38 PM
#193
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Simple Category Tree

I believe you understand the concept of free software, and more over, this module is just an add-on. If you read the very first page of this topic, I even stated that I may not give any support at all, use it at your own risk.

All its features along with instructions and such are listed in the readme file. It is the user's responsibility to read and understand how the code works, this module is for to normal users who just want some plug and play feature, this one is for someone who at least has the base knowledge of coding.

From all the sample codes you posted, it shows that you dont even have such knowledge (missing a semicolon when calling function, or not knowing how to call a class method). Such very basic knowledge have to be learned, which is why I suggest you read more about php and its syntax etc... before trying to hack around. (I read a 350 pages book before I started years ago, and I had Java, C and C++ background before working on PHP)

More over, you didn't even try to read the readme file carefully, or maybe you did read it carefully but didnt get it because of my poor English skill?

Anyhow, like I mentioned, there is a module in the add-on that does exactly what you want (list all the cats and products on the tree). It will help you.

Regards

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

24 Nov 2008, 9:25 PM
#194
wiccanwitch420 avatar

wiccanwitch420

Zen Follower

Join Date:
Nov 2008
Posts:
196
Plugin Contributions:
0

Re: Simple Category Tree

Hello, my name is Jamie, I am very new to all of this stuff and I have no knowledge of code. I am looking at two features you have been talking about:
all_subcats_products
and simple category tree

The only thing that I am looking to do, is have my categories all listed to the left. In order to see the sub categories you have to click on the category. I do not like that once you click on the category you will see all the categories, and only pop up new product from the main category. I want it to work that when you click on the main category it will show all products , and you will have the choice to click on any of the subcategories separetly to get more specific.

If I am correct, then you mod of all_subcats_products is the one to use to accomplish this?

If not which is the correct one?

Also, where can I get the newest version of it?

On your page yellow I do see the mod for the trees but not the all_subcats_products

Please let me know. My site in case you need it is

https://www.mysticcrypt.com

thank you.

30 Nov 2008, 1:33 PM
#195
balihr avatar

balihr

Totally Zenned

Join Date:
Oct 2008
Location:
Croatia
Posts:
1,805
Plugin Contributions:
22

Re: Simple Category Tree

hy everyone!

i have a beginners question (since that's what i am :smile:).

how can i change the indent of subcategories. It seems to be to far from parent category.

i would like it to look like:

category
...subcat
...subcat

and not

....category
.............subcat
.............subcat

the site is https://www.bali.hr if you need it...

BTW, yellow, thanx for a great addon!

My site - Pro ZC Help
My portfolio | My plugins

17 Dec 2008, 9:30 PM
#196
yelow avatar

yelow

Zen Follower

Join Date:
Sep 2008
Posts:
115
Plugin Contributions:
0

Re: Simple Category Tree

Thanks very much for this mod!

I've implemented and adjusted it to my taste, it looks and functions perfectly!

I do (of course) have one question, and this might have been foreseen already, is there any way to set apart the current page's link in a diff. style?

i.e. does the 'current page' have a class/id attached to it (or something?) or is there a call I can rig that checks the current page and reflects that on the menu?

thanks,

and again, thanks for the mod!!

-Tim

<!-- just commenting -->
17 Dec 2008, 9:33 PM
#197
yelow avatar

yelow

Zen Follower

Join Date:
Sep 2008
Posts:
115
Plugin Contributions:
0

Re: Simple Category Tree

balihr:

hy everyone!

i have a beginners question (since that's what i am :smile:).

how can i change the indent of subcategories. It seems to be to far from parent category.

i would like it to look like:

category
...subcat
...subcat

and not

....category
.............subcat
.............subcat

the site is https://www.bali.hr if you need it...

BTW, yellow, thanx for a great addon!

This is an issue that I was working on myself, just now, and the site in question (http://store.persite.com) has this, currently:

.has_sub {
	padding-left: 0px;
	margin-left: 0px;
	}

.level_0 {
	list-style-position: inside;
	list-style-type: disc;
	color: #F2BE11;
	padding-left: 2px;
	margin-left: 0px;
	}
	
	
.level_1 {
	list-style-position: inside;
	list-style-type: disc;
	color: #537294;
	padding-left: 5px;
	margin-left: 0px;
	}
	
.level_1 text {
	color: #F2BE11;
	font-variant: small-caps;
	}
	
.level_2  {
	list-style-type: circle;
	color: #F2BE11;
	margin-left: 3px;
	}
	
.level_3 {
	list-style-type: circle;
	color: #537294;
	margin-left: 3px;
	}
	
.level_4 {
	list-style-type: block;
	color: #F2BE11;
	margin-left: 10px;
	}
	
.level_2 .level_3 .level_4  .level_5 {
	padding-left: 0px;
	}

Adjust to your taste, but keep in mind that the two main factors are your MARGIN-LEFT and your PADDING-LEFT and each has different effects on Internet Explorer and Firefox so check both continuously.

-Tim

<!-- just commenting -->
19 Dec 2008, 11:31 PM
#198
balihr avatar

balihr

Totally Zenned

Join Date:
Oct 2008
Location:
Croatia
Posts:
1,805
Plugin Contributions:
22

Re: Simple Category Tree

aaaaaaaammmmm......

i don't get it. :blush:

the site you mentioned has exactly what i'm looking for.

but, how/where do i put this code you gave me? don't forget, i'm just a beginner who is still trying to understand the basics... :smile:

My site - Pro ZC Help
My portfolio | My plugins

11 Feb 2009, 10:05 AM
#199
dlg_ie avatar

dlg_ie

New Zenner

Join Date:
Oct 2008
Posts:
30
Plugin Contributions:
0

Re: Simple Category Tree

Hi Yellow1912,

just wanted to say a very big THANK YOU for your time and effort developing the mod all_sub_cats_products.zip.
It's just what I was looking for and it worked straight away.
Thanks again !

Denis
http://viaterra.net/store (still in development)

10 Mar 2009, 6:47 AM
#200
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Simple Category Tree

This is just to share that I have rewritten the module to be more flexible (for my own need)

I should not call it Simple Tree tho, because seem like many ppl dont think it's that simple, any how, to sum it up:

  1. It's easier, more flexible now to tell the tree the "wrapper" you want to put the parent - children in, example:
echo $_SESSION['category_tree']->buildCategoryString('<ul class="{class}">{child}</ul>', '<li class="{class}"><a class="{class} category-top" href="{link}"><span>{name}</span></a><span>|</span>{child}</li>', 0, 2, 1, false, true);
```2. Can attach other links to the tree, example:
```php
$_SESSION['category_tree']->attachToCategoryTree(array('name'=> HEADER_FILENAME_SOMETHING2, 'cPath' => zen_href_link(FILENAME_FILENAME_SOMETHING2, '', 'NONSSL', false), 'id' => 'sell', 'children' => array(
                                                    array('name'=>HEADER_FILENAME_SOMETHING1, 'id' => 'sales', 'cPath' => zen_href_link(FILENAME_FILENAME_SOMETHING1, '', 'NONSSL', false)),
                                                    array('name'=>HEADER_FILENAME_SOMETHING, 'id' => 'listings', 'cPath' => zen_href_link(FILENAME_SOMETHING, '', 'NONSSL', false))
                                                    )));    

I guess other than that and a number of other small features it remains the same:

  1. It uses only 1 single query to get the tree
  2. It can cache the tree
  3. You can put it anywhere
  4. You can have as many trees on the same page as you want
  5. Limit maximum level of cat to display
  6. Choose to always expand or not.
  7. You can start the tree from any category, example:
    on a recent project, I have 3 boxes: grand parent, parent, and children. Parent box links depend on which category is currently active on the grandparent box, and children box display links depending on links currently active on parent.

With this module, you can tweak it to anything you want, expanded category, ajax tree type etc....

Well, but again we have people having frustrating time with this module in the past since they dont know php, and you HAVE to know a bit about PHP to well, at least know which parameters you should pass into the function. So I will not post the module here to avoid such frustration, if you are interested and think you can handle it with little help from me, post here or send a PM. I will send it to you.

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