Hierarchical Viewer showing too much

Duncan Koza asked on November 26, 2019 23:36

I have some document page types in a folder page type. I want to show the folder page type name and all the document page types listed under it.

My Tree looks like this

  • Page Page Type
    • Sub Page Page Type
      • Folder Page Type
        • Document Page Type

I am using the Hierarchical Viewer but here is my problem. My Page Page Type is showing the Folder and Documents and so is my Sub Page Page Type. I only want my Sub Page Page Type to show the Folder and Documents.

Is there a way to limit my Hierarchical viewer to only show the Folder Page types directly under it's current page?

Correct Answer

Duncan Koza answered on December 2, 2019 17:33

ok, this is weird!! I solved it, but I don't know why it works. At least it works now.

This is what I did:

Under the Content Filter of the Hierarchical viewer in Kentico 11, I was filtering for my File Folder and File pages types, but decided I would no longer do that Because I was already applying the transformations in my heirarchical viewer to just those specific page types. Anyway, I removed the page types from the page type field under Content Filter. haha. At least it works.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Mike Wills answered on November 27, 2019 00:21

Hi Duncan,

In the scenario you described, are you wanting "Sub Page Page Type" to show the Folder and Documents, when "Sub Page Page Type" is the current document? If so, is this mostly about setting the Path property of the Hierarchical Viewer so that it starts with the children of the current page? If I'm reading the question right, you'd need to set it to something like:

./%

Regards,

Mike

0 votesVote for this answer Mark as a Correct answer

Duncan Koza answered on November 27, 2019 16:53

I tried that and it works for my Sub Page Page Type. The only issue is that my Page Page type will attempt to show the same folder page type if it doesn't have it's own direct folder page type under it.

0 votesVote for this answer Mark as a Correct answer

Mike Wills answered on November 27, 2019 17:19

Yes, that makes sense, because the path expression "./%" will allow all descendants under the current page. To control this, you have fine grain control of what page types are displayed at what level in the hierarchical query using the hierarchical transformation configurations. For example, you can ensure that only "Folder Page Type" and maybe "Document Page Type" are rendered at level 0. If neither of those types exist at level 0, nothing else will be rendered.

Using hierarchical transformations

0 votesVote for this answer Mark as a Correct answer

Duncan Koza answered on November 29, 2019 04:27

I'll give that linked page a second read through and double check my code.

0 votesVote for this answer Mark as a Correct answer

Duncan Koza answered on December 2, 2019 17:16

ok, I've read through the documentation and I am still having the same issue.

I am using the Hierarchical Viewer in Kentico 11.

I have set the path to ./% and I have set the maximum nesting level to 2.

My site Structure for pages looks like this, they all use the same template but are unique page types:

  • Main Page Type
    • Sub1 Page Type
      • Sub2 Page Type

At any time, anywhere within the tree above, a user could add a Page Type called "File Folder" with a bunch of Page Types called "Files" within that.

So, it could look like this (as an example):

  • Main Page Type
    • File Folder (Page Type)
      • File (Page Type)
      • File (Page Type)
    • Sub1 Page Type
      • Sub2 Page Type
        • File Folder (Page Type)
          • File (Page Type)

The issue that I am having is with my Sub1 Page Type, if there isn't a File Folder directly under it, I feel like it shouldn't display the "File Folder" page type, but it does. I have two item transformations. One at Level 0, specifically and only for the File Folder page type and one at Level 1, specifically and only for the File Page Type. I have read that any transformation with a Level 0 will function for all levels. I guess that since I set the maximum nesting level to 2, the hierarchical viewer will look to the next level to find the File Folder page type, but I don't want it to do that.

Any thoughts?

0 votesVote for this answer Mark as a Correct answer

Mike Wills answered on December 2, 2019 17:41

Good news! Thanks Duncan.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.