Elements generated on theme installation
To provide better experience for end users after theme installation Publisher can create some default content used by theme.
Thanks to this feature theme developer can be sure that all of his article or category templates will be visible without
complicated configuration by end user.
Generated elements can be declared in theme.json config file under generatedData
key. Example:
| {
"name": "my/custom-theme",
"generatedData": { ... }
}
|
Theme generators supports now those elements: routes
, menus
, containers
, widgets
, and contentLists
.
All elements have this same properties as are supported by API requests, plus few extra like:
- in routes:
numberOfArticles
- number of fake articles generated and attached to route
- in menus:
children
- array of child menus attached to parent one
- in widgets:
containers
- array of containers names where widgets should be automatically attached
Example routes block
| "generatedData": {
"routes": [
{
"name": "Politics", # required
"slug": "politics", # optional
"type": "collection", # required
"templateName": "category.html.twig", # optional
"articlesTemplateName": "article.html.twig", # optional
"numberOfArticles": 1 # optional (number of articles generated and attached to route)
},
...
|
Example containers block
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 | "generatedData": {
"containers": [
{
"name": "mainNav", # required
"styles": "border: 1px ", # optional
"visible": true, # optional (default true)
"cssClass": "col-md-12", # optional
"data": { # optional
"some_extra_data": true
}
},
{
"name": "frontArticles" # required
}
...
|
Example contentLists block
| "generatedData": {
"contentLists": [
{
"name": "Example automatic list", # required
"type": "automatic", # required
"description": "New list", # required
"limit": 5, # optional
"cacheLifeTime": 30, # optional
"filters": "{\"metadata\":{\"located\":\"Porto\"}}" # optional
}
...
|