@@ -89,7 +89,11 @@ Frontend template: Fluid template for a Content Block with a Collection
8989Line 1: We use `Asset.css ViewHelper <f:asset.css> <https://docs.typo3.org/permalink/t3viewhelper:typo3-fluid-asset-css >`_
9090to load the provided CSS file only if a carousel is displayed on that page. The
9191`Asset collector <https://docs.typo3.org/permalink/t3coreapi:asset-collector >`_
92- takes care that the file is not loaded more then once per page.
92+ takes care that the file is not loaded more then once per page. All Fluid
93+ ViewHelpers prefixed with `cb: ` are provided by :composer: `friendsoftypo3/content-blocks `
94+ they are therefore not listed in the official View Helper reference. The inline
95+ ViewHelper `cb:assetPath() ` resolves paths to the `asset ` folder of the current
96+ content block.
9397
9498Line 2: We use the `Asset.script ViewHelper <f:asset.script> <https://docs.typo3.org/permalink/t3viewhelper:typo3-fluid-asset-script >`_
9599to load the JavaScript file the same way.
@@ -99,18 +103,18 @@ to loop through each item. We then render a button for each carousel item.
99103
100104Line 11: We loop the items a second time to now display all carousel slides.
101105
102- Line 13: As the field of type "Files" may contain more then one file, the
103- variable {data.carousel_items} contains an array. We loop through the array
104- and display all images found.
105-
106- Line 14: We use the `Image ViewHelper <f:image> <https://docs.typo3.org/permalink/t3viewhelper:typo3-fluid-image >`_
106+ Line 13: The field ` image ` was defined with option ` relationship: manyToOne ` in
107+ the :ref: ` config.yaml < carousel-configuration >` it can therefore only contain
108+ one image at maximum. As supplying an image is also mandatory ` minitems: 1 `
109+ we can be sure there is always exactly one image. And just use the
110+ `Image ViewHelper <f:image> <https://docs.typo3.org/permalink/t3viewhelper:typo3-fluid-image >`_
107111to display the image.
108112
109- Line 18 : As the field `{item.description} ` is of type Textarea with rich-text
113+ Line 16 : As the field `{item.description} ` is of type Textarea with rich-text
110114enabled we have to use the `Format.html ViewHelper <f:format.html> <https://docs.typo3.org/permalink/t3viewhelper:typo3-fluid-format-html >`_
111115to properly display it.
112116
113- Line 25, 29 : The previous and next buttons use localized text for their labels.
117+ Line 23, 27 : The previous and next buttons use localized text for their labels.
114118We use the `Translate ViewHelper <f:translate> <https://docs.typo3.org/permalink/t3viewhelper:typo3-fluid-translate >`_
115119to translate these labels and a view helper provided by the Content Block
116120extension to determine the path to the language file.
@@ -128,4 +132,51 @@ should be displayed in the TYPO3 backend in the Page module:
128132 :linenos:
129133
130134The same fields like for the frontend template are available and the same
131- ViewHelpers can be used.
135+ ViewHelpers can be used. However we display them in a simplified form.
136+
137+ Line 1: We are using the layout `Preview `, which already gives some structure to
138+ the display of the backend element:
139+
140+ .. figure :: /Images/ContentBlocks/BackendLayout.png
141+ :alt: Screenshot of a Content Block in the TYPO3 Backend, demonstrating the sections of the layout
142+
143+ The sections of a content element backend layout: (1) Header, (2) Content, (3) Footer
144+
145+ The line on the very top with the name of the content element, the icon and the
146+ edit buttons is generated by TYPO3 automatically and cannot be influenced by
147+ a backend template. It uses the label `title ` defined in :file: `language/labels.xlf `
148+ and the icon :file: `assets/icon.svg `.
149+
150+ As always we use the `Layout ViewHelper <f:layout> <https://docs.typo3.org/permalink/t3viewhelper:typo3fluid-fluid-layout >`_
151+ to select the `Preview ` layout.
152+
153+ Each section is declared using the `Section ViewHelper <f:section> <https://docs.typo3.org/permalink/t3viewhelper:typo3fluid-fluid-section >`_.
154+
155+ Line 10: We once more use the
156+ `For ViewHelper <f:for> <https://docs.typo3.org/permalink/t3viewhelper:typo3fluid-fluid-for >`_
157+ to loop through all items of the slider and display them one by one.
158+
159+ Line 21: Labels can and should also be localized in the backend. To not lose
160+ context we prefixed all labels to be used in the backend with `backend. `.
161+
162+ .. tip ::
163+ See also chapter `Backend Preview in the Content Blocks
164+ manual <https://docs.typo3.org/permalink/friendsoftypo3/content-blocks:api-backend-preview> `_.
165+
166+
167+ .. _carousel-assets :
168+
169+ Content Block specific assets
170+ =============================
171+
172+ The assets in folder :directory: `assets ` can be loaded in the
173+ :ref: `Frontend Template <carousel-fluid >`. They will only be loaded when the
174+ Content Block is loaded on the current page. If compression
175+ (:ref: `config.compressCss <t3tsref:confval-config-compresscss >`,
176+ :ref: `config.compressJs <t3tsref:confval-config-compressjs >`) and concatenation
177+ (:ref: `config.concatenateCss <t3tsref:confval-config-concatenatecss >`,
178+ :ref: `concatenateJs <t3tsref:confval-config-concatenatejs >`) are enabled
179+ all assets are compressed and concatenated into as few as possible small asset
180+ files.
181+
182+ This also has the advantage that your JavaScript is only loaded if needed.
0 commit comments