Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kentico 9 - Limit page type based on page template

Tags:

kentico

I'm trying to limit editors to create wrong document on Kentico nodes. I know there is Page Types -> Scopes for this, but in my case it is hard to configure it. In my scenario I have a repeated node structure like this:

Root (template: ROOT)
  - Page 1 (type: Page; template: PAGE)
  - Page 2 (type: Page; template: PAGE)
  - Page 3 (type: Page; template: PAGE)
  ...
  - Section A (type: Page; template: SECTION)
    - Node 1 (type: Page; template: NODE)
    - Node 2 (type: Page; template: NODE)
    - Node 3 (type: Page; template: NODE)
    ...
  - Section B (type: Page; template: SECTION)
    - Node 1 (type: Page; template: NODE)
    - Node 2 (type: Page; template: NODE)
    - Node 3 (type: Page; template: NODE)
    ...
  - Section C (type: Page; template: SECTION)
    - Node 1 (type: Page; template: NODE)
    - Node 2 (type: Page; template: NODE)
    - Node 3 (type: Page; template: NODE)
    ...

Editor could create a lot of sections, but always with the SECTION template. I want that under a Section an editor can create only a Node of type "PAGE".

This is what I'm trying to do: I create a new Macro rule (on Macro rules application) that check if current page has a specific template (passed on parameters) see image

Then I create a new Scope (Page Type -> Scopes) see image

I think it was all ok (on "Section A" I can add only "Page" documents), but also in "Page 1" (with template different from SECTION) I can add only "Page" documents. It seems that my condition return always "true"

I try to change the parameter field in my Macro with "DocumentPageTemplateID" against "NodeTemplateID", but I have the same result.

I believe to be close to the solution. Can you help me?

PS: I know that I can create a different page type for Section A, B, C and then use the Page Type Scopes, but I prefer to do this in base of the Template instead of Type.

Thank you

like image 238
Alberto Avatar asked Feb 06 '23 10:02

Alberto


1 Answers

Instead of using the Page page type for a 'Section', create a new Section page type and set the default template for it. Then maybe create another new page type called 'Node' and set a default template for it as well. No need to get crazy with scopes, just set the scope for both the Section and Node page types to be at the root and only allow Nodes to be placed below Sections and Sections can only be placed below the Root document.

like image 100
Brenden Kehren Avatar answered May 25 '23 06:05

Brenden Kehren