Category - Subcategory Structure

Hi all, I’m new to this forum and to Yii…I want to create a multi level category/subcategory structure

i look on the forum e on the web but i didnt find nothing useful to help me…

i saw this extesions but seems thats its no avaible to download…nestedsetbehavior

what I want its like blog post where you can assign different categories and sub categories to you post…

thank you all for the help!!

The best way I found to make infinite Category >Subcategory > Subcategory etc is making one category table. Remember it’s all in the Database how things are connected. I have an ID and a ParentID, so any subcat of a cat has a ParentID of the Cat’s ID. So if ID =5 and ParentID = 2, it means 5 is a subcategory of 2, 2 can also be a subcategory of something if it’s ParentID is >0.

so a category with no parent has a ParentID of 0.

Your ParentID is like a foreign key





	'category'=>array(self::HAS_MANY, 'Category', 'ParentID'),




Hope that makes sense

thank you ver much for your reply…yes that make sense…i understand what you mean…

but its all to develop…i have no idea how to implement that…

do you have something to read about ? im sorry but im new to yii…

I’m pretty new to this stuff too and relatively an amateur, but reading and doing the Yii blog tutorial gets you going nicely. It pretty much covers all the basics. There’s a few useful docs on the main framework site. Also read the docs about the MVC.

Cheers

thanks!!

hi,

make a search with "tree" in extension directory: you will find some usefull behaviors (to manage parent child relationships), widgets (for displaying trees) and so on …

In databases, trees can be organised as said above with parent_id relations, but also as nested set or nested intervals …

To resume: you need a database structure, some actions and behaviors to handle your tree organization (move, update, create and so on) and some cool javascripts to display them.

By looking the source codes you will learn a lot on how to manage that and maybe find your own way to handle your trees exactly the way you want.

Good luck

thank you luc!