Skip to content

Commit ead5679

Browse files
committed
content_types.md: ADd pattern examples; format Markdown
1 parent 7da580c commit ead5679

File tree

1 file changed

+77
-12
lines changed

1 file changed

+77
-12
lines changed

docs/administration/content_organization/content_types.md

Lines changed: 77 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,66 @@ Each content type is characterized by a set of metadata which define the general
3030

3131
Note that even if your content type defines a Field intended as a name for the content item (for example, a title of an article or product name), do not confuse it with this Name, which is a piece of metadata, not a Field.
3232

33-
**Identifier** – an identifier for internal use in configuration files, templates, PHP code, etc. It must be unique, can only contain lowercase letters, digits and underscores; the maximum length is 50 characters. (Mandatory.)
34-
35-
**Description** – a detailed description of the content type. (Optional.)
36-
37-
<a id="content-name-pattern"></a>**Content name pattern** – a pattern that defines what name a new content item based on this content type gets. The pattern usually consists of Field identifiers that tell the system which Fields it should use when generating the name of a content item. Each Field identifier has to be surrounded with angle brackets. Text outside the angle brackets will be included literally. If no pattern is provided, the system will automatically use the first Field. (Optional.)
38-
39-
**URL alias name pattern** – a pattern which controls how the virtual URLs of the Locations will be generated when content items are created based on this content type. Note that only the last part of the virtual URL is affected. The pattern works in the same way as the Content name pattern. Text outside the angle brackets will be converted using the selected method of URL transformation. If no pattern is provided, the system will automatically use the name of the content item itself. (Optional.)
33+
**Identifier** –
34+
an identifier for internal use in configuration files, templates, PHP code, etc.
35+
It must be unique, can only contain lowercase letters, digits and underscores;
36+
the maximum length is 50 characters. (Mandatory.)
37+
38+
**Description** –
39+
a detailed description of the content type. (Optional.)
40+
41+
<a id="content-name-pattern"></a>
42+
**Content name pattern** –
43+
a pattern that defines what name a new content item based on this content type gets.
44+
The pattern usually consists of Field identifiers that tell the system which Fields it should use when generating the name of a content item.
45+
Each Field identifier has to be surrounded with angle brackets.
46+
Text outside the angle brackets will be included literally.
47+
If no pattern is provided, the system will automatically use the first Field. (Optional.)
48+
49+
??? note "Pattern examples"
50+
51+
The following pattern takes the value of the field with the identifier `title` (which is required):
52+
```
53+
<title>
54+
```
55+
56+
The following pattern combines several field values:
57+
```
58+
<firstname> <lastname>
59+
```
60+
61+
The following pattern takes the value of the field with the identifier `seo_title` (which is optional) if not empty,
62+
else the value of the field with the identifier `short_title` (which is optional),
63+
else it takes the one with identifier `title` (which is required):
64+
```
65+
<seo_title|short_title|title>
66+
```
67+
68+
The following pattern takes the value of the field with the identifier `nickname` if not empty,
69+
else it takes the ones with identifiers `firstname` and `lastname` with a space inbetween:
70+
```
71+
<nickname|(<firstname> <lastname>)>
72+
```
73+
74+
- Input-output example:
75+
- `fistname`: "*Alice*"
76+
- `lastname`: "*Doe*"
77+
- `nickname`: "" (empty)
78+
- Generated content name: "*Alice Doe*"
79+
- Input-output example:
80+
- `fistname`: "*Robert*"
81+
- `lastname`: "*Doe*"
82+
- `nickname`: "*Bob*"
83+
- Generated content name: "*Bob*"
84+
85+
**Notice that you won't be able to obtain a vertical bar `|` or parentheses in the generated names as they are special characters.**
86+
87+
88+
**URL alias name pattern** –
89+
a pattern which controls how the virtual URLs of the Locations will be generated when content items are created based on this content type.
90+
Note that only the last part of the virtual URL is affected. The pattern works in the same way as the Content name pattern.
91+
Text outside the angle brackets will be converted using the selected method of URL transformation.
92+
If no pattern is provided, the system will automatically use the name of the content item itself. (Optional.)
4093

4194
!!! tip "Changing URL alias and Content name patterns"
4295

@@ -46,17 +99,29 @@ Each content type is characterized by a set of metadata which define the general
4699

47100
The old URL aliases will continue to redirect to the same content items.
48101

49-
**Container** – a flag which indicates if content items based on this content type are allowed to have sub-items or not (mainly relevant for actions via the UI, not validated by every PHP API).
102+
**Container** –
103+
a flag which indicates if content items based on this content type are allowed to have sub-items or not
104+
(mainly relevant for actions via the UI, not validated by every PHP API).
50105

51106
!!! note
52107

53-
This flag was added for convenience and only affects the interface. In other words, it doesn't control any actual low-level logic, it simply controls the way the graphical user interface behaves.
108+
This flag was added for convenience and only affects the interface.
109+
In other words, it doesn't control any actual low-level logic,
110+
it simply controls the way the graphical user interface behaves.
54111

55-
**Sort children by default by** – rule for sorting sub-items. If the instances of this content type can serve as containers, their children will be sorted according to what is selected here.
112+
**Sort children by default by** –
113+
rule for sorting sub-items.
114+
If the instances of this content type can serve as containers,
115+
their children will be sorted according to what is selected here.
56116

57-
**Sort children by default in order** – another rule for sorting sub-items. This decides the sort order for the criterion chosen above.
117+
**Sort children by default in order** –
118+
another rule for sorting sub-items.
119+
This decides the sort order for the criterion chosen above.
58120

59-
<a id="default-content-availability"></a>**Make content available even with missing translations** – a flag which indicates if content items of this content type should be available even without a corresponding language version. See [Content availability](content_availability.md).
121+
<a id="default-content-availability"></a>
122+
**Make content available even with missing translations** –
123+
a flag which indicates if content items of this content type should be available even without a corresponding language version.
124+
See [Content availability](content_availability.md).
60125

61126
![Creating a new content type](admin_panel_new_content_type.png)
62127

0 commit comments

Comments
 (0)