Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Categories and Parent selector View modes: 
User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 1/12/2014 6:24:50 PM
   
Categories and Parent selector
I've got a setup that is using Categories and having a difficult time understanding why the parent category isn't being added to the selection. My setup is:

Categories
root
-group1
--sub group1
--sub group2
-group2
--sub group1
--sub group2
-group3
Repeater WHERE clause
{%"DocumentID IN (SELECT DocumentID from CMS_DocumentCategory inner join CMS_Category on CMS_DocumentCategory.CategoryID = CMS_Category.CategoryID where (CategoryDisplayName = '" + CurrentDocument.DocumentName + "' OR CategoryDisplayName = 'All'))"|(handlesqlinjection)false@%}
This is looking for the same category name as the document name being rendered and displays other doc types content on the page. So my content tree and category tree look the same.

What I can't figure out is if I have -group1 selected, the item will display on the page. BUT if I have a child of -group1 (-group1--sub group2) selected, by default it doesn't have the parent category -group1 selected or included. I'd think what I'd see in the database would be:

Document1|Sub Group1
Document1|Group1

But it only has one record and does not properly display the parent.

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 1/24/2014 8:01:04 AM
   
RE:Categories and Parent selector
Any thoughts on this?

User avatar
Member
Member
Jerreck - 1/24/2014 8:45:02 AM
   
RE:Categories and Parent selector
What if you compared the DocumentID of the current document to the DocumentID found on the CMS_DocumentCategory table and pulled-in documents whose CategoryID matched the current document's?

Then, maybe you could also use the current document's CategoryID to select its ParentID on the CMS_Category table.

I'm not sure if it will work in one query (or accomplish your goal), but I figured I would throw it out there.

User avatar
Member
Member
kentico_davidb2 - 2/5/2014 7:10:31 AM
   
RE:Categories and Parent selector
You are right, within the database, documents are only associated with the category itself, there is no record for "Ancestor categories".

I suppose that unless you want to create very complex SQL in the WHERE condition, you may also create a view in the database, which would resemble the CMS_DocumentCategory table, but would also have records for DocumentIDs vs all IDs of "Category ancestors" like you described at the end of your post.

All categories are connected by hierarchical structure using CategoryParentID.