-
Notifications
You must be signed in to change notification settings - Fork 59
[FEATURE] Document Content Block Examples #325
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9911622
[FEATURE] Document Content Block Examples
linawolf 1714ad2
[FEATURE] Document Content Block Examples
linawolf 3e568f1
[TASK] Add screenshot
linawolf f61a1b2
Update Documentation/ContentBlocks/Index.rst
linawolf 0882c86
Apply suggestions from code review
linawolf 6f812f7
Update Documentation/ContentBlocks/Index.rst
linawolf 5fc28fc
Apply suggestions from code review
linawolf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,158 @@ | ||
| :navigation-title: Custom Content Blocks | ||
| .. include:: /Includes.rst.txt | ||
|
|
||
| .. _content-blocks: | ||
|
|
||
| ===================== | ||
| Custom Content Blocks | ||
| ===================== | ||
|
|
||
| When we filled the `stage with content <https://docs.typo3.org/permalink/t3sitepackage:slide-mode>`_ | ||
| we noticed that the content does not look like the content within the original | ||
| HTMl layout. | ||
|
|
||
| This is because the stage does not contain normal content, as provided by | ||
| Fluid-Styled Content, but a Jumbotron element or a slider. | ||
|
|
||
| .. note:: | ||
| The extension :composer:`friendsoftypo3/content-blocks` is not an official | ||
| part of the TYPO3 Core yet. It is also possible to | ||
| `Create a custom content element with TYPO3 Core only <https://docs.typo3.org/permalink/t3coreapi:adding-your-own-content-elements>`_. | ||
|
|
||
| .. _content-blocks-installation: | ||
|
|
||
| Install extension Content Blocks | ||
| ================================ | ||
|
|
||
| The extension :composer:`friendsoftypo3/content-blocks` is an extension that | ||
| is not part of the TYPO3 Core but maintained by a group of community members. | ||
|
|
||
| There are plans to integrate this extension into the Core, however at the | ||
| time of writing there are no finite decisions yet. | ||
|
|
||
| First install the extension :composer:`friendsoftypo3/content-blocks`: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| ddev composer req friendsoftypo3/content-blocks | ||
|
|
||
| Set up the extension and delete all caches: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| ddev typo3 extension:setup | ||
| ddev typo3 cache:flush | ||
|
|
||
| .. _content-blocks-jumbotron: | ||
|
|
||
| The jumbotron content block | ||
| =========================== | ||
|
|
||
| The site package you generated in step | ||
| `Generate a site package <https://docs.typo3.org/permalink/t3sitepackage:minimal-design>`_ | ||
| comes with two content elements. We look at the more basic content elements first. | ||
|
|
||
| You can now replace the content element in the area "Stage" of start page with | ||
| one of type "Jumbotron". | ||
|
|
||
| .. figure:: /Images/ContentBlocks/CreateContentElement.png | ||
| :alt: Screenshot of the "New Page Content" dialog with the Carousel and Jumbotron as additional features | ||
|
|
||
| The new Content Blocks "Jumbotron" and "Carousel" | ||
|
|
||
| You can now create a jumbotron with a button and a link. | ||
|
|
||
| Directory :path:`packages/my_site_package/ContentBlocks/ContentElements` contains | ||
| one directory for each Content Block that can be used as normal Content Elements. | ||
|
|
||
| .. _content-blocks-jumbotron-directory: | ||
|
|
||
| Directory structure of a content block | ||
linawolf marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
linawolf marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| -------------------------------------- | ||
|
|
||
| A content block consists of a configuration (:file:`config.yaml`), a template and | ||
linawolf marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| optionally assets and or language files: | ||
|
|
||
| The jumbotron consists of the following files: | ||
|
|
||
| .. directory-tree:: | ||
| :level: 2 | ||
| :show-file-icons: true | ||
|
|
||
| * packages/my_site_package/ContentBlocks/ContentElements/jumbotron | ||
|
|
||
| * assets | ||
|
|
||
| * icon.svg | ||
|
|
||
| * language | ||
|
|
||
| * labels.xlf | ||
|
|
||
| * templates | ||
|
|
||
| * frontend.html | ||
|
|
||
| * config.yaml | ||
|
|
||
| .. _content-blocks-jumbotron-config: | ||
|
|
||
| The configuration of the jumbotron Content Block | ||
| ------------------------------------------------ | ||
|
|
||
| File :path:`packages/my_site_package/ContentBlocks/ContentElements/jumbotron/config.yaml` | ||
| defines what fields should be available for the Content Block in the backend: | ||
|
|
||
| .. literalinclude:: /CodeSnippets/my_site_package/ContentBlocks/ContentElements/jumbotron/config.yaml | ||
| :caption: packages/my_site_package/ContentBlocks/ContentElements/jumbotron/config.yaml | ||
| :linenos: | ||
|
|
||
| Each content block must have a unique name with a prefix of your choice that | ||
linawolf marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| should be unique within your project. (Line 1) | ||
|
|
||
| It is possible to use fields that are already pre-defined in the TYPO3 Core like | ||
| `header` (Line 8) and `bodytext` (Line 11). | ||
|
|
||
| We also newly define two fields, one of type `Text <https://docs.typo3.org/permalink/friendsoftypo3/content-blocks:field-type-text>`_ | ||
| (Line 15-19) and one of type `Link <https://docs.typo3.org/permalink/friendsoftypo3/content-blocks:field-type-link>`_ | ||
| (Line 21-23). You can find all available types here: `Field Types <https://docs.typo3.org/permalink/friendsoftypo3/content-blocks:field-types>`_. | ||
|
|
||
| The meaning behind the other settings here can be found in the | ||
| `YAML reference of the Content Blocks guide <https://docs.typo3.org/permalink/friendsoftypo3/content-blocks:yaml-reference>`_. | ||
|
|
||
| .. _content-blocks-jumbotron-template: | ||
|
|
||
| The jumbotron template | ||
| ---------------------- | ||
|
|
||
| The frontend template for the Content Block "Jumbotron" is a normal Fluid | ||
| template. You already used Fluid for the | ||
| `Page templates <https://docs.typo3.org/permalink/t3sitepackage:fluid-templates>`_ | ||
| and to adjust the templates of Fluid-Styles Content elements in chapter | ||
linawolf marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
linawolf marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| `Overriding the default templates of content elements <https://docs.typo3.org/permalink/t3sitepackage:content-element-rendering>`_. | ||
|
|
||
| .. literalinclude:: /CodeSnippets/my_site_package/ContentBlocks/ContentElements/jumbotron/templates/frontend.html | ||
| :caption: packages/my_site_package/ContentBlocks/ContentElements/jumbotron/templates/frontend.html | ||
| :linenos: | ||
|
|
||
| Line 3: The values of the database entry of the current content element can be | ||
| found in variable `{data}`. In this line we render the content of the field | ||
| `header`. The field was defined in line 8 of the :file:`config.yaml`. | ||
|
|
||
| Line 4: Here we output the content of field `bodytext` as this field is a | ||
| Rich-Text Editor we use the | ||
| `Format.html ViewHelper <f:format.html> <https://docs.typo3.org/permalink/t3viewhelper:typo3-fluid-format-html>`_ | ||
| to format and sanitize the output. | ||
|
|
||
| Line 5: We use the `Link.typolink ViewHelper <f:link.typolink> <https://docs.typo3.org/permalink/t3viewhelper:typo3-fluid-link-typolink>`_ | ||
| to render a link to the target that was defined in our custom field `button_link`. | ||
|
|
||
| .. _content-blocks-next: | ||
|
|
||
| Next steps | ||
| ========== | ||
|
|
||
| * The generated site package contains a second, more elaborate example in | ||
| directory :path:`packages/my_site_package/ContentBlocks/ContentElements/carousel`. | ||
| * Learn how to use the `Kickstart command <https://docs.typo3.org/permalink/friendsoftypo3/content-blocks:cb-skeleton>`_ | ||
| to create your own content blocks. | ||
linawolf marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.