guidance for using nested tables

For Joomla! 3.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Locked
grapeguy
Joomla! Apprentice
Joomla! Apprentice
Posts: 26
Joined: Wed Dec 14, 2005 10:02 pm
Location: Sunset, Texas USA
Contact:

guidance for using nested tables

Post by grapeguy » Fri May 29, 2015 8:29 pm

Using the popular library scenario I'd like to add sections to my library. A library can have multiple sections, and a section can have multiple sub-sections or none. A section would only belong to one parent section or library. A book would only belong to one section. (i have custom data associated with these so category is out, but that is the behavior I'm looking for).

I have used the JTableNested class on the table that will hold the sections, but I don't seem to be able to get the lft, rgt, level, and path fields to update when I add a new section.

I don't remember where I found some basic notes on JTableNested, that I uses as my starting point.

Pointer to a reasonable example would be appreciated.

jcms
I've been banned!
Posts: 2233
Joined: Wed Nov 19, 2014 9:23 am

Re: guidance for using nested tables

Post by jcms » Sat May 30, 2015 2:34 am


grapeguy
Joomla! Apprentice
Joomla! Apprentice
Posts: 26
Joined: Wed Dec 14, 2005 10:02 pm
Location: Sunset, Texas USA
Contact:

Re: guidance for using nested tables

Post by grapeguy » Tue Jun 02, 2015 7:40 pm

Nope, that document isn't very helpful either reads just like the definition page.

I am using Joomla!3.4. and the document I've been using is https://docs.joomla.org/Using_nested_sets

I have the table class defined as JTableNested, and the fields added to the table as documented.

I use the 'parent_id' field with it set to either the ROOT or anther entry, but it is always being saved with the nodes parent_id == 0 and the level == 0. Everything else looks sane, and the lft, rgt values are being updated as appropriate.

I see there is a section on "Adding a new node" but it is not very helpful on where I should put the $table->setLocation() call.

Does it go in the table class like the bind or store function, or does it go in a model class function like prepareTable,...

Marvin_Martiano
Joomla! Intern
Joomla! Intern
Posts: 92
Joined: Fri Sep 09, 2011 12:36 pm

Re: guidance for using nested tables

Post by Marvin_Martiano » Fri Jun 05, 2015 3:59 pm

Where does your scenario differ from using subcategories? Book = item, Library = category, Section = sub-category? I don't get it, maybe if you explain it someone sees it and understands & can reply?

grapeguy
Joomla! Apprentice
Joomla! Apprentice
Posts: 26
Joined: Wed Dec 14, 2005 10:02 pm
Location: Sunset, Texas USA
Contact:

Re: guidance for using nested tables

Post by grapeguy » Fri Jun 05, 2015 9:21 pm

Well, I found what I needed by drilling down into the CategoriesModelCategory class. I found what I needed there to add to my class's save function.

I originally thought of using Joomla Categories, but then I needed to associate more data, hence creating my own custom category type table with JTableNested. That and I'm already using categories for something else, and I haven't seen much documentation on using the optional sections and components of a extension's category (ie: category.myextension.component2.section1 where component2 would be the genre's in the library, component1 would be something else that is categorized by the extension.)

I noticed during my digging that "access groups" is also an extension of JTableNested.

Next I need to dig into why I can't mark an entry as 'trashed' on the admin side so that I can clean up test data, but no big hurry.

Thanks,
Chris.


Locked

Return to “Joomla! 3.x Coding”