Answers.Body: <p>This is not possible natively to have conditional fields based on the structure's level. For the same cases as yours, I'm also using different entry types.</p>
  
  <p>Maybe you could consider moving your children to a Channel and link them to their parent using an Entry field + some routing, or using one of the plugins bellow to add a bit of hack, but I would not recommend it at all:</p>
  
  <ul>
  <li><a href="https://plugins.craftcms.com/conditions" rel="nofollow noreferrer">https://plugins.craftcms.com/conditions</a></li>
  <li><a href="https://plugins.craftcms.com/cp-css" rel="nofollow noreferrer">https://plugins.craftcms.com/cp-css</a></li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-27T15:31:59.270Z
Answers.Text: Thanks. I had a feeling this would be the case. I was thinking that I could possibly create a plugin that automates the level > entry type mapping via JavaScript, but I'm not sure it's possible to know what level a structure entry is before it's been saved, so that might not make sense.
Answers.UserDisplayName: Timmy O'Mahony
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-27T15:36:33.783Z
Answers.Text: You can get the current level in JS if you inspect the value of `#parentId > .elements > [data-level]`. To add custom JS scripts in the CP, you could use this plugin: https://plugins.craftcms.com/cp-js
Answers.UserDisplayName: Romain P.
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-27T15:24:06.693Z
Answers.LastActivityDate: 2020-02-27T15:24:06.693Z
Answers.UserDisplayName: Romain P.
Body: <p>I have a site that will heavily rely on the structure entry type to allow the client to publish content.</p>
  
  <p>The "1st" level of the structure will always act as a <em>table of contents</em> for its children. The child pages will always contain the actual content (supplied via a matrix field). </p>
  
  <pre><code>- Page A (TOC)
      - Page B (Content)
      - Page C (Content)
          - Page D (Content)
  - Page E (TOC)
      - Page F (Content)
      - Page G (Content)
  - Page H (TOC)
      - Page I (Content)
  - ...
  </code></pre>
  
  <p>This means that the fields visible in the control panel for level 1 entries need to be different to the fields for level 2 + entries.</p>
  
  <p>Is it possible to have conditional fields based on the structure's level?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-02-27T13:46:40.117Z
Comments.Text: I notice I can set up different "entry types" for sections which would allow the user to select the fields they want to use. This could be done via a "Content" entry type and "Table of contents" entry type, although not automatically
Comments.UserDisplayName: Timmy O'Mahony
Tags: <entries><field><structure>
Title: Conditional fields based on structure level
ThreadText: # Conditional fields based on structure level
  
  (Asked by: username_0 on 2020-02-27)
  
  I have a site that will heavily rely on the structure entry type to allow the client to publish content.
  
  The "1st" level of the structure will always act as a *table of contents* for its children. The child pages will always contain the actual content (supplied via a matrix field).
  
  ```
  - Page A (TOC)
      - Page B (Content)
      - Page C (Content)
          - Page D (Content)
  - Page E (TOC)
      - Page F (Content)
      - Page G (Content)
  - Page H (TOC)
      - Page I (Content)
  - ...
  
  ```
  
  This means that the fields visible in the control panel for level 1 entries need to be different to the fields for level 2 + entries.
  
  Is it possible to have conditional fields based on the structure's level?
  
  **Tags:** entries, field, structure
  
  > **Comments:**
  > **username_0**: I notice I can set up different "entry types" for sections which would allow the user to select the fields they want to use. This could be done via a "Content" entry type and "Table of contents" entry type, although not automatically  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-02-27. Score: 2 | Accepted answer
  
  This is not possible natively to have conditional fields based on the structure's level. For the same cases as yours, I'm also using different entry types.
  
  Maybe you could consider moving your children to a Channel and link them to their parent using an Entry field + some routing, or using one of the plugins bellow to add a bit of hack, but I would not recommend it at all:
  
  * <https://plugins.craftcms.com/conditions>
  * <https://plugins.craftcms.com/cp-css>
  
  > **Comments:**
  > **username_0**: Thanks. I had a feeling this would be the case. I was thinking that I could possibly create a plugin that automates the level > entry type mapping via JavaScript, but I'm not sure it's possible to know what level a structure entry is before it's been saved, so that might not make sense.  
  > **username_1**: You can get the current level in JS if you inspect the value of `#parentId > .elements > [data-level]`. To add custom JS scripts in the CP, you could use this plugin: https://plugins.craftcms.com/cp-js  
  
  ---
  
  