From ffd016313fbed92d475c642618e76bf229e50c46 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 13 Jul 2022 20:10:39 +0200 Subject: [PATCH] Remove cObject ViewHelper page (#543) The page was not specific to Extbase and has been removed to "TYPO3 Explained". Related: TYPO3-Documentation/TYPO3CMS-Book-ExtbaseFluid#536 Co-authored-by: Sybille Peters --- ...t-for-rendering-the-cobject-viewhelper.rst | 185 ------------------ Documentation/8-Fluid/Index.rst | 1 - 2 files changed, 186 deletions(-) delete mode 100644 Documentation/8-Fluid/5-using-typoscript-for-rendering-the-cobject-viewhelper.rst diff --git a/Documentation/8-Fluid/5-using-typoscript-for-rendering-the-cobject-viewhelper.rst b/Documentation/8-Fluid/5-using-typoscript-for-rendering-the-cobject-viewhelper.rst deleted file mode 100644 index 63da2eb6..00000000 --- a/Documentation/8-Fluid/5-using-typoscript-for-rendering-the-cobject-viewhelper.rst +++ /dev/null @@ -1,185 +0,0 @@ -.. include:: /Includes.rst.txt -.. index:: - TypoScript ViewHelper - Fluid; f:cObject - -====================================================== -Using TypoScript for rendering: The cObject ViewHelper -====================================================== - -The cObject ViewHelper is a very powerful ViewHelper. It connects -Fluid with the options that TypoScript offers. The following line in the -HTML template will be replaced with the referenced TypoScript object. - -.. code-block:: html - :caption: EXT:my_extension/Resources/Private/Templates/SomeTemplate.html - - - -Now we only have to define ``lib.title`` in the TypoScript -Setup: - -.. code-block:: typoscript - :caption: EXT:my_extension/Configuration/TypoScript/setup.typoscript - - lib.title = TEXT - lib.title.value = Extbase and Fluid - -»Extbase and Fluid« will be outputted in the template. Now we can output an -image (e.g. headlines with unusual fonts) by changing the TypoScript to: - -.. code-block:: typoscript - :caption: EXT:my_extension/Configuration/TypoScript/setup.typoscript - - lib.title = IMAGE - lib.title { - file = GIFBUILDER - file { - 10 = TEXT - 10.value = Extbase and Fluid - } - } - -.. sidebar:: TypoScript - - TypoScript is a flexible configuration language, which can control - the rendering of a page in much detail. It consists of TypoScript objects - (also known as ``Content`` object or ``cObject``) and - their configuration options. - - The simplest ``Content`` object is ``TEXT`` - which outputs unmodified text. The TypoScript object ``IMAGE`` - can be used to generate images, and database entries can be outputted - with ``CONTENT``. - -So far, it's not a "real world" example because no data is -being passed from Fluid to the TypoScript. We'll demonstrate how to pass -a parameter to the TypoScript with the example of 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 ``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 ``stdWrap`` attribute ``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 simply 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 ``field`` of -``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 ``field`` based approach with -``current``: If you set the property ``currentValueKey`` -in the ``cObject`` ViewHelper, this value will be available in -the TypoScript template with ``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, ``current`` -and ``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 - -In the next chapter, we'll turn our attention to a function which most -ViewHelper have. This function makes it possible to modify the HTML output -of a ViewHelper by adding your own tag attributes. diff --git a/Documentation/8-Fluid/Index.rst b/Documentation/8-Fluid/Index.rst index cac2baf0..3ed17c6e 100644 --- a/Documentation/8-Fluid/Index.rst +++ b/Documentation/8-Fluid/Index.rst @@ -31,7 +31,6 @@ sample. 2-using-different-output-formats 3-moving-repeating-snippets-to-partials 4-creating-a-consistent-look-and-feel-with-layouts - 5-using-typoscript-for-rendering-the-cobject-viewhelper 6-adding-additional-tag-attributes-with-additionalattributes 7-using-boolean-conditions 9-using-php-based-views