diff --git a/docs/templating/twig_function_reference/content_twig_functions.md b/docs/templating/twig_function_reference/content_twig_functions.md index 2cafe97abd..ae7a135812 100644 --- a/docs/templating/twig_function_reference/content_twig_functions.md +++ b/docs/templating/twig_function_reference/content_twig_functions.md @@ -28,7 +28,7 @@ You can provide `ibexa_render()` with either a content item or a Location object |Argument|Type|Description| |------|------|------| -|`content`
or
`location`|`Ibexa\Contracts\Core\Repository\Values\Content\Content`
or
`Ibexa\Contracts\Core\Repository\Values\Content\Location`|Content item or its location.| +|`content` or `location`|[`Content`](../../api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-Content.html) or [`Location`](../../api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-Location.html)|Content item or its location.| |`method`|`string`|(optional) [Rendering method](#rendering-methods). One of: `direct`, `inline`, `esi`, `ssi`. (Default method is `direct`)| |`viewType`|`string`|(optional) [View type](template_configuration.md#view-types). (Default view type is `embed`)| @@ -60,7 +60,7 @@ If the content item doesn't have a translation in the prioritized or passed lang | Argument | Type | Description | |---------------|------|-------------| -| `content` | `Ibexa\Contracts\Core\Repository\Values\Content\Content`
or
`Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo` | Content item or its ContentInfo object.| +| `content` | [`Content`](../../api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-Content.html), [`ContentInfo`](../../api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-ContentInfo.html), or [`ContentAwareInterface`](../../api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-ContentAwareInterface.html) | Content item, its ContentInfo object, or ContentAwareInterface object.| | `forcedLanguage` | `string` | (optional) Language to use (for example, `fre-FR`). | ``` html+twig @@ -69,30 +69,44 @@ If the content item doesn't have a translation in the prioritized or passed lang {{ ibexa_content_name(content, 'pol-PL') }} ``` +``` html+twig +{{ ibexa_content_name(product) }} + +{{ ibexa_content_name(product, 'fr-FR') }} +``` + ### `ibexa_seo_is_empty()` `ibexa_seo_is_empty()` returns a Boolean value which indicates whether [SEO]([[= user_docĀ =]]/search_engine_optimization/seo/) data is available for the content item that is passed as an argument. | Argument | Type | Description | |---------------|------|-------------| -| `content` | `Ibexa\Contracts\Core\Repository\Values\Content\Content`
or
`Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo` | Content item or its ContentInfo object.| +| `content` | [`Content`](../../api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-Content.html) or [`ContentAwareInterface`](../../api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-ContentAwareInterface.html) | Content item or ContentAwareInterface object.| ``` html+twig {{ ibexa_seo_is_empty(content) }} ``` +``` html+twig +{{ ibexa_seo_is_empty(product) }} +``` + ### `ibexa_seo()` `ibexa_seo()` attaches [SEO]([[= user_docĀ =]]/search_engine_optimization/seo/) data to the content item's HTML code. | Argument | Type | Description | |---------------|------|-------------| -| `content` | `Ibexa\Contracts\Core\Repository\Values\Content\Content`
or
`Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo` | Content item or its ContentInfo object.| +| `content` | [`Content`](../../api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-Content.html) or [`ContentAwareInterface`](../../api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-ContentAwareInterface.html) | Content item or ContentAwareInterface object.| ``` html+twig {{ ibexa_seo(content) }} ``` +``` html+twig +{{ ibexa_seo(product) }} +``` + !!! tip The following example uses both SEO-related functions: @@ -112,12 +126,15 @@ If the content item doesn't have a translation in the prioritized or passed lang | Argument | Type | Description | |---------------|------|-------------| -| `content` | [`Ibexa\Contracts\Core\Repository\Values\Content\Content`](../../api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-Content.html) | Content item to display the category name for. | +| `content` | [`Content`](../../api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-Content.html) or [`ContentAwareInterface`](../../api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-ContentAwareInterface.html) | Content item to display the category name for. | ```html+twig {{ content|ibexa_taxonomy_entries_for_content|map(entry => "#{entry.name}")|join(', ') }} ``` +```html+twig +{{ product|ibexa_taxonomy_entries_for_content|map(entry => "#{entry.name}")|join(', ') }} +``` ## Non-content related queries diff --git a/docs/templating/twig_function_reference/field_twig_functions.md b/docs/templating/twig_function_reference/field_twig_functions.md index ca7d5e10d4..69ea44c4c7 100644 --- a/docs/templating/twig_function_reference/field_twig_functions.md +++ b/docs/templating/twig_function_reference/field_twig_functions.md @@ -32,7 +32,7 @@ The field is rendered with the default template, but you can optionally pass a d | Argument | Type | Description | | ------ | ----- | ----- | -| `content` | `Ibexa\Contracts\Core\Repository\Values\Content\Content` | Content item the field belongs to. | +| `content` | [`Content`](../../api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-Content.html) or [`ContentAwareInterface`](../../api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-ContentAwareInterface.html) | Content item the field belongs to. | | `fieldDefinitionIdentifier` | `string` | Field identifier. | | `params` | `hash` | (optional) Hash of parameters passed to the template block. | @@ -48,6 +48,18 @@ The field is rendered with the default template, but you can optionally pass a d }) }} ``` +``` html+twig +{{ ibexa_render_field(product, 'name') }} + +{{ ibexa_render_field(product, 'image', { + 'template': '@ibexadesign/fields/image.html.twig', + 'attr': {class: 'thumbnail-image'}, + 'parameters': { + 'alias': 'small' + } +}) }} +``` + #### Parameters You can pass the following parameters to `ibexa_render_field()`: @@ -80,7 +92,7 @@ If the content item doesn't have a translation in the prioritized or passed lang | Argument | Type | Description | |-----|------|-----| -| `content`| `Ibexa\Contracts\Core\Repository\Values\Content\Content` | Content item the field belongs to.| +| `content` | [`Content`](../../api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-Content.html) or [`ContentAwareInterface`](../../api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-ContentAwareInterface.html) | Content item the field belongs to.| | `fieldDefIdentifier` | `string` | Identifier of the field. | | `forcedLanguage` | `string` | (optional) Language to use (for example, "fre-FR"). | @@ -88,6 +100,10 @@ If the content item doesn't have a translation in the prioritized or passed lang {{ ibexa_field_value(content, 'image') }} ``` +``` html+twig +{{ ibexa_field_value(product, 'image') }} +``` + ### `ibexa_field()` `ibexa_field()` returns the field object. @@ -96,7 +112,7 @@ If the content item doesn't have a translation in the prioritized or passed lang | Argument | Type | Description | |-------|------|------| -| `content`| `Ibexa\Contracts\Core\Repository\Values\Content\Content` | Content item the field belongs to.| +| `content` | [`Content`](../../api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-Content.html) or [`ContentAwareInterface`](../../api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-ContentAwareInterface.html) | Content item the field belongs to.| | `fieldDefIdentifier` | `string` | Identifier of the field. | | `forcedLanguage` | `string` | {optional) Language to use (for example, "fre-FR"). | @@ -109,6 +125,10 @@ You can use `ibexa_field()` to access the field type identifier: {{ ibexa_field(content, 'my_field').fieldTypeIdentifier }} ``` +``` html+twig +{{ ibexa_field(product, 'my_field').fieldTypeIdentifier }} +``` + ## Field information ### `ibexa_field_name()` @@ -120,7 +140,7 @@ If the content item doesn't have a translation in the prioritized or passed lang | Argument | Type | Description | |---------------|------|-------------| -| `content` | `Ibexa\Contracts\Core\Repository\Values\Content\Content` or `Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo` | Content item the field belongs to. | +| `content` | [`Content`](../../api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-Content.html), [`ContentInfo`](../../api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-ContentInfo.html), or [`ContentAwareInterface`](../../api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-ContentAwareInterface.html) | Content item the field belongs to. | | `fieldDefIdentifier` | `string` | Identifier of the field. | | `forcedLanguage` | `string` | (optional) Language to use (for example, `fre-FR`). | @@ -131,6 +151,12 @@ If the content item doesn't have a translation in the prioritized or passed lang {{ ibexa_field_name(content, 'title', 'ger-DE') }} ``` +``` html+twig +{{ ibexa_field_name(product, 'name') }} + +{{ ibexa_field_name(product, 'name', 'pl-PL') }} +``` + ### `ibexa_field_description()` `ibexa_field_description()` returns the description of a content item's field. @@ -140,7 +166,7 @@ If the content item doesn't have a translation in the prioritized or passed lang | Argument | Type | Description | |---------------|------|-------------| -| `content` | `Ibexa\Contracts\Core\Repository\Values\Content\Content` or `Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo` | Content item the field belongs to. | +| `content` | [`Content`](../../api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-Content.html), [`ContentInfo`](../../api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-ContentInfo.html), or [`ContentAwareInterface`](../../api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-ContentAwareInterface.html) | Content item the field belongs to. | | `fieldDefIdentifier` | `string` | Identifier of the field. | | `forcedLanguage` | `string` | (optional) Language to use (for example, `fre-FR`). | @@ -150,13 +176,19 @@ If the content item doesn't have a translation in the prioritized or passed lang {{ ibexa_field_description(content, 'title', 'ger-DE') }} ``` +``` html+twig +{{ ibexa_field_description(product, 'name') }} + +{{ ibexa_field_description(product, 'name', 'fr-FR') }} +``` + ### `ibexa_field_is_empty()` `ibexa_field_is_empty()` returns Boolean information whether a given field of a content item is empty. | Argument | Type | Description | |---------------|------|-------------| -| `content` | `Ibexa\Contracts\Core\Repository\Values\Content\Content` or `Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo` | Content item the field belongs to. | +| `content` | [`Content`](../../api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-Content.html) or [`ContentAwareInterface`](../../api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-ContentAwareInterface.html) | Content item the field belongs to. | | `fieldDefIdentifier` | `string` | Identifier of the field. | | `forcedLanguage` | `string` | (optional) Language to use (for example, `fre-FR`). | @@ -164,6 +196,10 @@ If the content item doesn't have a translation in the prioritized or passed lang {{ ibexa_field_is_empty(content, 'title') }} ``` +``` html+twig +{{ ibexa_field_is_empty(product, 'name') }} +``` + #### Examples For example, use `ibexa_field_is_empty()` to check whether a field is empty or filled before rendering it: @@ -174,6 +210,12 @@ For example, use `ibexa_field_is_empty()` to check whether a field is empty or f {% endif %} ``` +``` html+twig +{% if not ibexa_field_is_empty(product, 'image') %} + {{ ibexa_render_field(product, 'image') }} +{% endif %} +``` + ### `ibexa_field_group_name()` `ibexa_field_group_name()` returns a human-readable name of a field group. @@ -193,11 +235,17 @@ For example, use `ibexa_field_is_empty()` to check whether a field is empty or f | Argument | Type | Description | |---------------|------|-------------| -| `content` | `Ibexa\Contracts\Core\Repository\Values\Content\Content` | Content item the field may belong to. | +| `content` | [`Content`](../../api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-Content.html) or [`ContentAwareInterface`](../../api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-ContentAwareInterface.html) | Content item the field may belong to. | | `fieldDefIdentifier` | `string` | Identifier of the field. | ``` html+twig {% if ibexa_has_field(content, 'existing') %} {{ ibexa_render_field(content, 'existing') }} {% endif %} +``` + +``` html+twig +{% if ibexa_has_field(product, 'existing') %} + {{ ibexa_render_field(product, 'existing') }} +{% endif %} ``` \ No newline at end of file diff --git a/docs/templating/twig_function_reference/image_twig_functions.md b/docs/templating/twig_function_reference/image_twig_functions.md index 7568a42233..ad72507ba5 100644 --- a/docs/templating/twig_function_reference/image_twig_functions.md +++ b/docs/templating/twig_function_reference/image_twig_functions.md @@ -13,7 +13,7 @@ page_type: reference To render images, use the [`ibexa_render_field()`](field_twig_functions.md#ibexa_render_field) Twig function with the variation name passed as an argument, for example: ``` html+twig -[[= include_file('docs/templating/twig_function_reference/field_twig_functions.md', 38, 45) =]] +[[= include_file('docs/templating/twig_function_reference/field_twig_functions.md', 40, 48) =]] ``` ## Image information @@ -48,12 +48,16 @@ To render images, use the [`ibexa_render_field()`](field_twig_functions.md#ibexa | Argument | Type | Description | | ------ |----- | ----- | -| `content` | `Ibexa\Contracts\Core\Repository\Values\Content\Content` | Content item to display the image for. | +| `content` | [`Content`](../../api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-Content.html) or [`ContentAwareInterface`](../../api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Values-Content-ContentAwareInterface.html) | Content item to display the image for. | ``` html+twig {% set firstImage = ibexa_content_field_identifier_first_filled_image(content) %} ``` +``` html+twig +{% set firstImage = ibexa_content_field_identifier_first_filled_image(product) %} +``` + #### Examples You can use `ibexa_content_field_identifier_first_filled_image()` to find and render the first existing image in an article: