Searchable Items (parent/child relationship)

Topics: Developer Forum, Project Management Forum, User Forum
Oct 12, 2008 at 3:59 PM
How can I build a parent/child items that is searchable?  I want to build a directory like the yellow book where you have categories and sub-categories.  For example:

Automotive----
                       |--- Dealers
                                        |--- North Carolina
                                        |--- South Carolina
                                        |--- Georgia
                                        |--- etc...
                       |--- Parts and Services
                                        |--- Exterior
                                                       |--- Bumpers
                                                       |--- Doors
                                                       |--- Fans/Electrical
                                        |--- Interior
                       |--- Car Reports
                       |--- etc...

Coordinator
Oct 12, 2008 at 5:32 PM
There is a search API available through N2.Find.Items...

To push more work to the database you could maintain a list of references to the parent trail from each leaf:

N2.Context.Perister.ItemSaving += {
    e.AffectedItem.GetDetailCollection("ParentTrail", true).Replace(Find.EnumerateParents(e.AffectedItem));
}

Then you can query N2.Find.Items.Where.Detail("ParentTrail").Eq(currentCategory).Select();