Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-9030: Add content name pattern examples #2513

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 77 additions & 12 deletions docs/administration/content_organization/content_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,66 @@

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.

**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.)

**Description** – a detailed description of the content type. (Optional.)

<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.)

**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.)
**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.)

**Description** –
a detailed description of the content type. (Optional.)

<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 is included literally.
If no pattern is provided, the system will automatically use the first Field. (Optional.)

Check warning on line 47 in docs/administration/content_organization/content_types.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/administration/content_organization/content_types.md#L47

[Ibexa.FutureTense] Use present tense instead of future.
Raw output
{"message": "[Ibexa.FutureTense] Use present tense instead of future.", "location": {"path": "docs/administration/content_organization/content_types.md", "range": {"start": {"line": 47, "column": 39}}}, "severity": "WARNING"}

??? note "Pattern examples"

The following pattern takes the value of the field with the identifier `title` (which is required):
```
<title>
```

The following pattern combines several field values:
```
<firstname> <lastname>
```

The following pattern takes the value of the field with the identifier `seo_title` (which is optional) if not empty,
else the value of the field with the identifier `short_title` (which is optional),
else it takes the one with identifier `title` (which is required):
```
<seo_title|short_title|title>
```

The following pattern takes the value of the field with the identifier `nickname` if not empty,
else it takes the ones with identifiers `firstname` and `lastname` with a space inbetween:
```
<nickname|(<firstname> <lastname>)>
```

- Input-output example:
- `fistname`: "*Alice*"
- `lastname`: "*Doe*"
- `nickname`: "" (empty)
- Generated content name: "*Alice Doe*"
- Input-output example:
- `fistname`: "*Robert*"
- `lastname`: "*Doe*"
- `nickname`: "*Bob*"
- Generated content name: "*Bob*"

**Notice that you won't be able to obtain a vertical bar `|` or parentheses in the generated names as they are special characters.**
Copy link
Contributor

@mnocon mnocon Oct 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
**Notice that you won't be able to obtain a vertical bar `|` or parentheses in the generated names as they are special characters.**
**The grouping`(`, `)` symbols used together are treated as special keywords and can only be used together as such, without the possibility to use them as standard characters. **

Nitpick: I believe you can obtain them in the generated names - if the fields contain them, they just cannot be part of the pattern in other meaning than the "special one"

I did some tests and it looks like you can use the | symbol in its standard meaning - only the grouping is not allowed.

CT settings:
Zrzut ekranu 2024-10-9 o 13 57 21

Content:
Zrzut ekranu 2024-10-9 o 13 57 29

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mnocon
OK for removing pipe and being clearer about parentheses.
I'm adding an example of what could go wrong so one could even search for "EZMETAGROUP_0" and find this explanation. What do you think about the following phrasing?:

Suggested change
**Notice that you won't be able to obtain a vertical bar `|` or parentheses in the generated names as they are special characters.**
**Notice that the grouping parentheses (characters `(`and `)`) are always treated as special characters, and can't be used as standard characters (unexpected text would appear in between like `(EZMETAGROUP_0)`).**



**URL alias name pattern** –
a pattern which controls how the virtual URLs of the Locations is generated when content items are created based on this content type.
Only the last part of the virtual URL is affected. The pattern works in the same way as the Content name pattern.
Text is converted using the selected method of URL transformation.
If no pattern is provided, the system automatically uses the name of the content item itself. (Optional.)

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

Expand All @@ -46,17 +99,29 @@

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

**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).
**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).

!!! note

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.
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.

**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.
**Sort children by default by** –
rule for sorting sub-items.
If the instances of this content type can serve as containers,
their children are sorted according to what is selected here.

**Sort children by default in order** – another rule for sorting sub-items. This decides the sort order for the criterion chosen above.
**Sort children by default in order** –
another rule for sorting sub-items.
This decides the sort order for the criterion chosen above.

<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).
<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).

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

Expand Down
Loading