-->

Typo3 LTS9 Routing: ReUse config.YAML

2020-07-30 02:39发布

问题:

What's the right way to reuse config.yaml for routing?

Situation: I have a typo3 installation with different websites. The routing-config with more than 200 lines is saved in: \typo3conf\sites\website1\config.yaml

What the right way to use this config.yaml with all other websites and only reconfig the differences in: \typo3conf\sites\website2-100\config.yaml

With typoscript this where easy. Is there a way to use this:

1. <INCLUDE_TYPOSCRIPT: source="FILE:\typo3conf\sites\website1\config.yaml">
2. Overide differences like "rootPageID: 2" or delete configs with ">"

回答1:

If you use TYPO3v9, you can use imports:.

Documentation:

https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/Yaml/Index.html

From TYPOv10 on they can be relative, too:

Changelog:

https://docs.typo3.org/c/typo3/cms-core/master/en-us/Changelog/10.1/Feature-88742-ImportYamlFilesRelativeToTheCurrentYamlFile.html



回答2:

To elaborate Jonas' hint, here a more concrete example:

Site configuration for the single site which is similar to all other and thus should be as short as possible, stored in sites/mysite/config.yaml

rootPageId: 14523 
base: 'https://www.mysite.mytld' 

imports:
  - { resource: "EXT:mysitepackage/Configuration/Sites/defaultSiteConf.yaml" }

Content of EXT:mysitepackage/Configuration/Sites/defaultSiteConf.yaml, the default config shared for basically all sites (although exceptions are possible).

 imports:
  - { resource: "EXT:mysitepackage/Configuration/Sites/errorHandling.yaml" }
  - { resource: "EXT:mysitepackage/Configuration/Sites/language.yaml" }
  - { resource: "EXT:mysitepackage/Configuration/Sites/route.pages.yaml" }
  - { resource: "EXT:mysitepackage/Configuration/Sites/route.tt_news.yaml" }

Content of EXT:mysitepackage/Configuration/Sites/language.yaml, as an example that the default config can be split into multiple files to track changes more easily

languages:
  - title: Deutsch
    enabled: true
    base: /
    typo3Language: de
    locale: de_DE.UTF-8
    iso-639-1: de
    navigationTitle: Deutsch
    hreflang: de-DE
    direction: ltr
    flag: de
    languageId: '0'
  - title: English
    enabled: true
    base: /en/
    typo3Language: default
    locale: en_GB.UTF-8
    iso-639-1: en
    navigationTitle: English
    hreflang: en-GB
    direction: ltr
    fallbackType: fallback
    fallbacks: '0'
    flag: gb
    languageId: '1'


标签: yaml typo3