IchHabRecht / content_defender

Define allowed or denied content element types in your backend layouts
GNU General Public License v2.0
80 stars 36 forks source link

Default settings for backend layout columns #102

Open saitho opened 2 years ago

saitho commented 2 years ago

Not sure if this is the right place or if that should be a TYPO3 core feature.

We're using mutliple extensions providing content elements that should only be used in specific backend layouts.

I'd like to define a default setting for disallowed content elements that is applied to all backend layouts.

Current approach

The current approach would be defining a default value and copying that into the columns in PageTS via copy operator <. The problem with that is that extensions defining own CEs can not exclude them from all other backend layouts they obviously don't know about.

MyDefaultColumn {
  disallowed {
    CType = some_ce
  }
}

mod {
  web_layout {
    BackendLayouts {
      my_backend_layout {
        config.backend_layout.rows.1 {
          columns {
            1 < MyDefaultColumn
            2 < MyDefaultColumn
          }
        }
      }
    }
  }
}

Suggested approach

Due to the limitations of PageTS in regards of using reference (=<) the suggested approach is supplying a default object for Ext:content_defender which is considered at runtime during evaluation of the settings. This effectively serves as default value for column settings which is extended by the regular settings on the backend layout.

Ext:content_defender

mod.web_layout.ContentDefender {
  Defaults {
    Column {
      disallowed {
        CType = 
      }
    }
  }
}

Ext:my_ext

// disallow my_ce for all backend layout columns
mod.web_layout.ContentDefender.Defaults.Column.disallowed.CType := addToList(my_ce)

mod {
  web_layout {
    BackendLayouts {
      my_backend_layout {
        config {
          backend_layout {
            rows {
              1 {
                columns {
                  1 {
                    disallowed {
                     // but allow it here
                     CType := addToList(my_ce)
                    }
                  }
                  2 {
                    // ...
                    // my_ce is disallowed here
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
IchHabRecht commented 1 year ago

Hi @saitho

Thank you for your feature proposal. Currently I don't see any way to include a default allowed/disallowed property in content_defender. If I understand you correctly, you do have a sitepackage providing the backendlayout and its configuration. The sitepackage "knows" about its dependencies (and therefore for loaded extensions and available content element types) and should be able to define allowed/disallowed element types per column.

BenjaminBeck commented 10 months ago

I needed something similar: https://github.com/BenjaminBeck/content_defender_mod