From 62fc5268cd4365b1c7b7ceda01fd3f443d6397f7 Mon Sep 17 00:00:00 2001 From: Simon Praetorius Date: Fri, 13 Feb 2026 15:46:28 +0100 Subject: [PATCH 01/12] [DOCS] Add f:cObject example for TypoScript ContentObject This has been moved from the TYPO3 API docs. --- Documentation/Global/CObject.rst | 133 +++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) diff --git a/Documentation/Global/CObject.rst b/Documentation/Global/CObject.rst index 6cd001f..8d223c7 100644 --- a/Documentation/Global/CObject.rst +++ b/Documentation/Global/CObject.rst @@ -116,3 +116,136 @@ When passing an object with `{data}`, the properties of the object are accessible with :typoscript:`.field` in TypoScript. If only a single value is passed or the `currentValueKey` is specified, :typoscript:`.current = 1` can be used in the TypoScript. + +.. _typo3-fluid-cobject-contentobject: + +Use data from a TypoScript ContentObject +---------------------------------------- + +As a more advanced use case, the ViewHelper can be used to pass data from a +Fluid template to a content object defined in TypoScript. The following example +demonstrates this with a user counter. The value +of our user counter should come from the Blog-Post. (Every Blog-Post should +count how many times it's been viewed in this example). + +In the Fluid template we add: + +.. code-block:: html + :caption: EXT:my_extension/Resources/Private/Templates/SomeTemplate.html + + {post.viewCount} + +Alternatively, we can use a self-closing tag. The data is being passed +with the help of the :html:`data` attribute. + +.. code-block:: html + :caption: EXT:my_extension/Resources/Private/Templates/SomeTemplate.html + + + +Also advisable for this example is the inline notation, because you can +easily read it from left to right: + +.. code-block:: html + :caption: EXT:my_extension/Resources/Private/Templates/SomeTemplate.html + + {post.viewCount -> f:cObject(typoscriptObjectPath: 'lib.myCounter')} + +Now we still have to evaluate the passed value in our TypoScript +template. We can use the :typoscript:`stdWrap` attribute :typoscript:`current` +to achieve this. It works like a switch: If set to 1, the value, which we +passed to the TypoScript object in the Fluid template will be used. In our +example, it looks like this: + +.. code-block:: typoscript + :caption: EXT:my_extension/Configuration/TypoScript/setup.typoscript + + lib.myCounter = TEXT + lib.myCounter { + current = 1 + wrap = | + } + +This TypoScript snippet outputs the current number of visits written +in bold. + +Now for example we can output the user counter as image instead of +text without modifying the Fluid template. We have to use the +following TypoScript: + +.. code-block:: typoscript + :caption: EXT:my_extension/Configuration/TypoScript/setup.typoscript + + lib.myCounter = IMAGE + lib.myCounter { + file = GIFBUILDER + file { + 10 = TEXT + 10.text.current = 1 + } + } + +At the moment, we're only passing a single value to the TypoScript. +It's more versatile, though, to pass multiple values to the TypoScript object +because then you can select which value to use in the TypoScript, and the +values can be concatenated. You can also pass whole objects to the +ViewHelper in the template: + +.. code-block:: html + :caption: EXT:my_extension/Resources/Private/Templates/SomeTemplate.html + + {post -> f:cObject(typoscriptObjectPath: 'lib.myCounter')} + +Now, how do you access individual properties of the object in the +TypoScript-Setup? You can use the property :typoscript:`field` of +:typoscript:`stdWrap`: + +.. code-block:: typoscript + :caption: EXT:my_extension/Configuration/TypoScript/setup.typoscript + + lib.myCounter = COA + lib.myCounter { + 10 = TEXT + 10.field = title + 20 = TEXT + 20.field = viewCount + wrap = (|) + } + +Now we always output the title of the blog, followed by the amount of +page visits in parenthesis in the example above. + +You can also combine the :typoscript:`field` based approach with +:typoscript:`current`: If you set the property :html:`currentValueKey` +in the cObject ViewHelper, this value will be available in +the TypoScript template with :typoscript:`current`. That is especially useful +when you want to emphasize that the value is very +*important* for the TypoScript template. For example, the +*amount of visits* is significant in our view +counter: + +.. code-block:: html + :caption: EXT:my_extension/Resources/Private/Templates/SomeTemplate.html + + {post -> f:cObject(typoscriptObjectPath: 'lib.myCounter', currentValueKey: 'viewCount')} + +In the TypoScript template you can now use both, :typoscript:`current` +and :typoscript:`field`, and have therefor the maximum flexibility with the +greatest readability. The following TypoScript snippet outputs the same +information as the previous example: + +.. code-block:: typoscript + :caption: EXT:my_extension/Configuration/TypoScript/setup.typoscript + + lib.myCounter = COA + lib.myCounter { + 10 = TEXT + 10.field = title + 20 = TEXT + 20.current = 1 + wrap = (|) + } + +The cObject ViewHelper is a powerful option to use the +best advantages of both worlds by making it possible to embed TypoScript +expressions in Fluid templates. From 40133d3fef4fdacc77b119ce126b70628b8bf2a5 Mon Sep 17 00:00:00 2001 From: Simon Praetorius Date: Sat, 14 Feb 2026 11:46:02 +0100 Subject: [PATCH 02/12] [DOCS] Various typos Co-authored-by: Lina Wolf <48202465+linawolf@users.noreply.github.com> --- Documentation/Global/CObject.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Documentation/Global/CObject.rst b/Documentation/Global/CObject.rst index 8d223c7..3b44e19 100644 --- a/Documentation/Global/CObject.rst +++ b/Documentation/Global/CObject.rst @@ -135,7 +135,7 @@ In the Fluid template we add: {post.viewCount} -Alternatively, we can use a self-closing tag. The data is being passed +Alternatively, we can use a self-closing tag. The data is passed with the help of the :html:`data` attribute. .. code-block:: html @@ -221,7 +221,7 @@ in the cObject ViewHelper, this value will be available in the TypoScript template with :typoscript:`current`. That is especially useful when you want to emphasize that the value is very *important* for the TypoScript template. For example, the -*amount of visits* is significant in our view +*number of visits* is significant in our view counter: .. code-block:: html @@ -230,7 +230,7 @@ counter: {post -> f:cObject(typoscriptObjectPath: 'lib.myCounter', currentValueKey: 'viewCount')} In the TypoScript template you can now use both, :typoscript:`current` -and :typoscript:`field`, and have therefor the maximum flexibility with the +and :typoscript:`field`, and have therefore the maximum flexibility with the greatest readability. The following TypoScript snippet outputs the same information as the previous example: From 270f38a466c5d1344b07e0f00f512ade127454a3 Mon Sep 17 00:00:00 2001 From: Sarah McCarthy Date: Sat, 14 Feb 2026 11:49:46 +0100 Subject: [PATCH 03/12] Apply suggestion from @linawolf Co-authored-by: Lina Wolf <48202465+linawolf@users.noreply.github.com> --- Documentation/Global/CObject.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Documentation/Global/CObject.rst b/Documentation/Global/CObject.rst index 3b44e19..cb20cf5 100644 --- a/Documentation/Global/CObject.rst +++ b/Documentation/Global/CObject.rst @@ -125,8 +125,7 @@ Use data from a TypoScript ContentObject As a more advanced use case, the ViewHelper can be used to pass data from a Fluid template to a content object defined in TypoScript. The following example demonstrates this with a user counter. The value -of our user counter should come from the Blog-Post. (Every Blog-Post should -count how many times it's been viewed in this example). +of our user counter should come from theblog post. (In this example, every blog post should count how many times it has been viewed.) In the Fluid template we add: From 1bbf1f5e99887cfd3bf74f60f1cc9fd4f9330f1e Mon Sep 17 00:00:00 2001 From: Sarah McCarthy Date: Sat, 14 Feb 2026 11:50:07 +0100 Subject: [PATCH 04/12] Apply suggestion from @linawolf Co-authored-by: Lina Wolf <48202465+linawolf@users.noreply.github.com> --- Documentation/Global/CObject.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/Global/CObject.rst b/Documentation/Global/CObject.rst index cb20cf5..af10472 100644 --- a/Documentation/Global/CObject.rst +++ b/Documentation/Global/CObject.rst @@ -142,8 +142,8 @@ with the help of the :html:`data` attribute. -Also advisable for this example is the inline notation, because you can -easily read it from left to right: +Inline notation is also advisable in this example, because it is +easy to read from left to right: .. code-block:: html :caption: EXT:my_extension/Resources/Private/Templates/SomeTemplate.html From c3461e82376a3541252438c827c14232f5b13339 Mon Sep 17 00:00:00 2001 From: Sarah McCarthy Date: Sat, 14 Feb 2026 11:50:17 +0100 Subject: [PATCH 05/12] Apply suggestion from @linawolf Co-authored-by: Lina Wolf <48202465+linawolf@users.noreply.github.com> --- Documentation/Global/CObject.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/Global/CObject.rst b/Documentation/Global/CObject.rst index af10472..f848434 100644 --- a/Documentation/Global/CObject.rst +++ b/Documentation/Global/CObject.rst @@ -168,7 +168,7 @@ example, it looks like this: This TypoScript snippet outputs the current number of visits written in bold. -Now for example we can output the user counter as image instead of +For example, we can output the user counter as image instead of text without modifying the Fluid template. We have to use the following TypoScript: From 7d410345f31246a9a9e9d9b8bbbc891f6d5f5768 Mon Sep 17 00:00:00 2001 From: Sarah McCarthy Date: Sat, 14 Feb 2026 11:50:26 +0100 Subject: [PATCH 06/12] Apply suggestion from @linawolf Co-authored-by: Lina Wolf <48202465+linawolf@users.noreply.github.com> --- Documentation/Global/CObject.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/Global/CObject.rst b/Documentation/Global/CObject.rst index f848434..20b0dfd 100644 --- a/Documentation/Global/CObject.rst +++ b/Documentation/Global/CObject.rst @@ -184,10 +184,10 @@ following TypoScript: } } -At the moment, we're only passing a single value to the TypoScript. -It's more versatile, though, to pass multiple values to the TypoScript object -because then you can select which value to use in the TypoScript, and the -values can be concatenated. You can also pass whole objects to the +At the moment, we are only passing a single value to TypoScript. +However, it is more versatile to pass multiple values to the TypoScript object, +because you can then select which value to use in TypoScript, and the +values can be concatenated. You can also pass entire objects to the ViewHelper in the template: .. code-block:: html From 11a8b3eda81e79626678c047ffb6b7ff8a20c315 Mon Sep 17 00:00:00 2001 From: Sarah McCarthy Date: Sat, 14 Feb 2026 11:50:34 +0100 Subject: [PATCH 07/12] Apply suggestion from @linawolf Co-authored-by: Lina Wolf <48202465+linawolf@users.noreply.github.com> --- Documentation/Global/CObject.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/Global/CObject.rst b/Documentation/Global/CObject.rst index 20b0dfd..3bdb33d 100644 --- a/Documentation/Global/CObject.rst +++ b/Documentation/Global/CObject.rst @@ -196,7 +196,7 @@ ViewHelper in the template: {post -> f:cObject(typoscriptObjectPath: 'lib.myCounter')} Now, how do you access individual properties of the object in the -TypoScript-Setup? You can use the property :typoscript:`field` of +TypoScript setup? You can use the property :typoscript:`field` of :typoscript:`stdWrap`: .. code-block:: typoscript From 92ac17b4f97d9d2c74f93c154c9cfd1fb4667ab6 Mon Sep 17 00:00:00 2001 From: Sarah McCarthy Date: Sat, 14 Feb 2026 11:50:50 +0100 Subject: [PATCH 08/12] Apply suggestion from @linawolf Co-authored-by: Lina Wolf <48202465+linawolf@users.noreply.github.com> --- Documentation/Global/CObject.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/Global/CObject.rst b/Documentation/Global/CObject.rst index 3bdb33d..a94df82 100644 --- a/Documentation/Global/CObject.rst +++ b/Documentation/Global/CObject.rst @@ -211,8 +211,8 @@ TypoScript setup? You can use the property :typoscript:`field` of wrap = (|) } -Now we always output the title of the blog, followed by the amount of -page visits in parenthesis in the example above. +In this example, we output the title of the blog followed by the number of +page visits in parentheses. You can also combine the :typoscript:`field` based approach with :typoscript:`current`: If you set the property :html:`currentValueKey` From 38646998a252bc03798491164bfd884407568d85 Mon Sep 17 00:00:00 2001 From: Simon Praetorius Date: Sat, 14 Feb 2026 11:53:00 +0100 Subject: [PATCH 09/12] [DOCS] Add headlines for TypoScript cObj example --- Documentation/Global/CObject.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/Global/CObject.rst b/Documentation/Global/CObject.rst index a94df82..db4df15 100644 --- a/Documentation/Global/CObject.rst +++ b/Documentation/Global/CObject.rst @@ -184,6 +184,9 @@ following TypoScript: } } +Passing objects to TypoScript +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + At the moment, we are only passing a single value to TypoScript. However, it is more versatile to pass multiple values to the TypoScript object, because you can then select which value to use in TypoScript, and the @@ -214,6 +217,9 @@ TypoScript setup? You can use the property :typoscript:`field` of In this example, we output the title of the blog followed by the number of page visits in parentheses. +Using :typoscript:`current` to pass values +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + You can also combine the :typoscript:`field` based approach with :typoscript:`current`: If you set the property :html:`currentValueKey` in the cObject ViewHelper, this value will be available in From c62ea6b6ede89df85a9bc31b8ac9dd4e7bf5f52f Mon Sep 17 00:00:00 2001 From: Sarah McCarthy Date: Sat, 14 Feb 2026 13:36:44 +0100 Subject: [PATCH 10/12] [TASK] Language checks --- Documentation/Global/CObject.rst | 71 ++++++++++++++------------------ 1 file changed, 32 insertions(+), 39 deletions(-) diff --git a/Documentation/Global/CObject.rst b/Documentation/Global/CObject.rst index db4df15..d1483eb 100644 --- a/Documentation/Global/CObject.rst +++ b/Documentation/Global/CObject.rst @@ -122,39 +122,37 @@ can be used in the TypoScript. Use data from a TypoScript ContentObject ---------------------------------------- -As a more advanced use case, the ViewHelper can be used to pass data from a -Fluid template to a content object defined in TypoScript. The following example -demonstrates this with a user counter. The value -of our user counter should come from theblog post. (In this example, every blog post should count how many times it has been viewed.) +As an example of a more advanced use case, the cObject viewhelper can pass +content data from a Fluid template to a content object defined in TypoScript. The +following example demonstrates this with a user counter. The user counter is in +a blog post (the blog post has a count of how many times it has been viewed.) -In the Fluid template we add: +Add the viewhelper to your Fluid template. This can be done in 3 different +ways. The basic tag syntax: .. code-block:: html :caption: EXT:my_extension/Resources/Private/Templates/SomeTemplate.html {post.viewCount} -Alternatively, we can use a self-closing tag. The data is passed -with the help of the :html:`data` attribute. +Or a self-closing tag. Data is passed in the :html:`data` attribute. .. code-block:: html :caption: EXT:my_extension/Resources/Private/Templates/SomeTemplate.html -Inline notation is also advisable in this example, because it is -easy to read from left to right: +Or inline notation, which is easy to read and understand (from left to right): .. code-block:: html :caption: EXT:my_extension/Resources/Private/Templates/SomeTemplate.html {post.viewCount -> f:cObject(typoscriptObjectPath: 'lib.myCounter')} -Now we still have to evaluate the passed value in our TypoScript -template. We can use the :typoscript:`stdWrap` attribute :typoscript:`current` -to achieve this. It works like a switch: If set to 1, the value, which we -passed to the TypoScript object in the Fluid template will be used. In our -example, it looks like this: +Then, add TypoScript (to your TypoScript template) to process this data. In our +example below, the :typoscript:`stdWrap` attribute :typoscript:`current` +works like a switch: if set to 1, it contains the value that was passed to the +TypoScript object from the Fluid template: .. code-block:: typoscript :caption: EXT:my_extension/Configuration/TypoScript/setup.typoscript @@ -165,12 +163,10 @@ example, it looks like this: wrap = | } -This TypoScript snippet outputs the current number of visits written -in bold. +This TypoScript snippet outputs the current number of visits in bold. -For example, we can output the user counter as image instead of -text without modifying the Fluid template. We have to use the -following TypoScript: +We can easily modify this TypoScript to output the user counter as an image instead +of text: .. code-block:: typoscript :caption: EXT:my_extension/Configuration/TypoScript/setup.typoscript @@ -187,20 +183,17 @@ following TypoScript: Passing objects to TypoScript ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -At the moment, we are only passing a single value to TypoScript. -However, it is more versatile to pass multiple values to the TypoScript object, -because you can then select which value to use in TypoScript, and the -values can be concatenated. You can also pass entire objects to the -ViewHelper in the template: +Up till now, we have only been passing a single value to the TypoScript object. +However, it is also possible to pass multiple values, useful for selecting which value to +use or concatenating values, or you can pass objects (here the `post` object): .. code-block:: html :caption: EXT:my_extension/Resources/Private/Templates/SomeTemplate.html {post -> f:cObject(typoscriptObjectPath: 'lib.myCounter')} -Now, how do you access individual properties of the object in the -TypoScript setup? You can use the property :typoscript:`field` of -:typoscript:`stdWrap`: +But how do we access the object's properties in our TypoScript? By setting the +:typoscript:`field` property of :typoscript:`stdWrap` (in a :typoscript:`COA`): .. code-block:: typoscript :caption: EXT:my_extension/Configuration/TypoScript/setup.typoscript @@ -214,16 +207,15 @@ TypoScript setup? You can use the property :typoscript:`field` of wrap = (|) } -In this example, we output the title of the blog followed by the number of -page visits in parentheses. +This TypoScript snippet outputs the title of the blog and the number of page visits in parentheses. Using :typoscript:`current` to pass values ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -You can also combine the :typoscript:`field` based approach with -:typoscript:`current`: If you set the property :html:`currentValueKey` -in the cObject ViewHelper, this value will be available in -the TypoScript template with :typoscript:`current`. That is especially useful +It is also possible to use the :typoscript:`current` switch here. +If you set the property :html:`currentValueKey` +in the cObject ViewHelper, the value will be available in +the TypoScript template as :typoscript:`current`. That is especially useful when you want to emphasize that the value is very *important* for the TypoScript template. For example, the *number of visits* is significant in our view @@ -234,10 +226,9 @@ counter: {post -> f:cObject(typoscriptObjectPath: 'lib.myCounter', currentValueKey: 'viewCount')} -In the TypoScript template you can now use both, :typoscript:`current` -and :typoscript:`field`, and have therefore the maximum flexibility with the -greatest readability. The following TypoScript snippet outputs the same -information as the previous example: +Then, in the TypoScript template, use :typoscript:`field` aswell as +:typoscript:`current` to output the value of the view count. The following +TypoScript snippet outputs the same information as above: .. code-block:: typoscript :caption: EXT:my_extension/Configuration/TypoScript/setup.typoscript @@ -251,6 +242,8 @@ information as the previous example: wrap = (|) } -The cObject ViewHelper is a powerful option to use the -best advantages of both worlds by making it possible to embed TypoScript +Using :typoscript:`current` makes the TypoScript easier to read and the logic +easier to understand. + +In summary, the cObject ViewHelper is a powerful option to embed TypoScript expressions in Fluid templates. From 53d83bab4e5bc7289bd81a06dda95323615a3365 Mon Sep 17 00:00:00 2001 From: Sarah McCarthy Date: Sat, 14 Feb 2026 14:07:52 +0100 Subject: [PATCH 11/12] [TASK] Add permalinks --- Documentation/Global/CObject.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/Global/CObject.rst b/Documentation/Global/CObject.rst index d1483eb..b5b9250 100644 --- a/Documentation/Global/CObject.rst +++ b/Documentation/Global/CObject.rst @@ -180,6 +180,8 @@ of text: } } +.. _typo3-fluid-cobject-contentobject-typoscript: + Passing objects to TypoScript ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -209,6 +211,8 @@ But how do we access the object's properties in our TypoScript? By setting the This TypoScript snippet outputs the title of the blog and the number of page visits in parentheses. +.. _typo3-fluid-cobject-contentobject-typoscript-current: + Using :typoscript:`current` to pass values ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From 5b2fc49cb9ea58eb096c5d9c3691244ae5fb5ebc Mon Sep 17 00:00:00 2001 From: Lina Wolf <48202465+linawolf@users.noreply.github.com> Date: Sat, 14 Feb 2026 15:42:37 +0100 Subject: [PATCH 12/12] Apply suggestion from @linawolf --- Documentation/Global/CObject.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/Global/CObject.rst b/Documentation/Global/CObject.rst index b5b9250..61b1034 100644 --- a/Documentation/Global/CObject.rst +++ b/Documentation/Global/CObject.rst @@ -213,8 +213,8 @@ This TypoScript snippet outputs the title of the blog and the number of page vis .. _typo3-fluid-cobject-contentobject-typoscript-current: -Using :typoscript:`current` to pass values -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Using `current` to pass values +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It is also possible to use the :typoscript:`current` switch here. If you set the property :html:`currentValueKey`