### Set up Development Environment with ddev Source: https://github.com/friendsoftypo3/content-blocks/blob/main/README.md Commands to start a local development environment using ddev. This includes starting the ddev instance, installing composer dependencies, and initiating the TYPO3 installation process. ```bash ddev start ddev composer install touch .Build/public/FIRST_INSTALL ddev launch ``` -------------------------------- ### Example Interactive Creation Process Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Commands/Make/Index.rst This shows an example of the interactive prompts and user inputs when creating a content block using the `make:content-block` command without pre-defined options. ```bash Choose the content type of your content block [Content Element]: [content-element] Content Element [page-type ] Page Type [record-type ] Record Type > content-element Enter your vendor name: > my-vendor Enter your content block name: > my-content-block-name Choose an extension in which the content block should be stored: [sitepackage] Test Package for content blocks > sitepackage ``` -------------------------------- ### Page Type Configuration Example Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/YamlReference/ContentTypes/PageTypes/Index.rst Example of a basic Page Type configuration file for a blog. ```APIDOC ## Page Type Configuration Example ### Description This example demonstrates how to define a custom Page Type named 'example/blog' with a specific type name and an additional field. ### Method N/A (Configuration File) ### Endpoint N/A (Configuration File) ### Parameters N/A (Configuration File) ### Request Example ```yaml name: example/blog typeName: 1701284006 fields: - identifier: additional_field type: Text ``` ### Response N/A (Configuration File) ``` -------------------------------- ### Install Mask to Content Blocks Migration Tool Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Migrations/Mask/Index.rst Install the migration tool via composer. This command requires Composer to be installed. ```shell composer req nhovratov/mask-to-content-blocks ``` -------------------------------- ### Install Content Blocks Extension Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Migrations/Mask/Index.rst If Content Blocks is not yet installed, install it using composer. This command requires Composer to be installed. ```shell composer req friendsoftypo3/content-blocks ``` -------------------------------- ### Lint Command Example Output Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Commands/Lint/Index.rst An example of the output from the content-blocks:lint command, showing detected configuration errors with their paths and error messages. ```bash +-----------------------------+---------------------------------------------------+ | Path | example/card-group | EXT:content_blocks_examples | +-----------------------------+---------------------------------------------------+ | /fields/3/fields/3/fields/0 | Additional object properties are not allowed: max | +-----------------------------+---------------------------------------------------+ [ERROR] Found 1 errors ``` -------------------------------- ### Example Output of labels.xlf Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Commands/LanguageGenerate/Index.rst This is an example of the XML structure for a generated labels.xlf file, including various trans-unit elements for different labels and descriptions. ```xml
My demo title This is just a demo/demo Existing field override My Slug My Slug Description my_collection text my_collection text external_table external_table_2 related_content My translation ``` -------------------------------- ### List all Content Blocks Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Commands/List/Index.rst Use this command to get a basic overview of all loaded Content Blocks. ```bash vendor/bin/typo3 content-blocks:list ``` -------------------------------- ### Example content-blocks.yaml Configuration Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Commands/Make/Index.rst This YAML file sets default values for vendor, skeleton-path, extension, and content-type for the make:content-block command. ```yaml vendor: nh extension: content_blocks_examples content-type: record-type skeleton-path: folder1/content-block-skeletons ``` -------------------------------- ### Example Output of List Command Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Commands/List/Index.rst This is an example of the tabular output generated by the list command, showing details like vendor, name, extension, content type, and table. ```bash +-----------+-------------------+-------------------------+-----------------+-----------------------------+ | vendor | name | extension | content-type | table | +-----------+-------------------+-------------------------+-----------------+-----------------------------+ | example | tabs | content_blocks_examples | Content Element | tt_content | | example | accordion | content_blocks_examples | Content Element | tt_content | | example | card-group | content_blocks_examples | Content Element | tt_content | | example | cta | content_blocks_examples | Content Element | tt_content | | example | icon-group | content_blocks_examples | Content Element | tt_content | | example | imageslider | content_blocks_examples | Content Element | tt_content | | example | example-page-type | content_blocks_examples | Page Type | pages | | hov | record1 | content_blocks_examples | Record Type | tx_hov_domain_model_record1 | | hov | record2 | content_blocks_examples | Record Type | tx_hov_domain_model_record1 | | hov | notype | content_blocks_examples | Record Type | tx_hov_domain_model_notype | +-----------+-------------------+-------------------------+-----------------+-----------------------------+ ``` -------------------------------- ### Create Content Block on Non-Composer Installations Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Commands/Make/Index.rst For TYPO3 installations not managed by Composer, use the direct path to the `typo3` executable to run the `make:content-block` command. ```bash typo3/sysext/core/bin/typo3 make:content-block ``` -------------------------------- ### Example Site Set Configuration Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/API/SiteSets/Index.rst Configure site sets manually in YAML to manage dependencies on Content Blocks. This is useful for managing dependencies without the GUI. ```yaml name: my-vendor/my-set label: My Set dependencies: - example/card-group - example/cta ``` -------------------------------- ### Create Content Block Skeleton in One Line Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Commands/Make/Index.rst This example demonstrates how to create a new content block skeleton by providing all required options directly on the command line. ```bash vendor/bin/typo3 make:content-block --content-type="content-element" --vendor="my-vendor" --name="my-name" --title="My shiny new Content Element" --extension="my_sitepackage" ``` -------------------------------- ### Clear Caches and Setup Extension After Creation Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Commands/Make/Index.rst After creating a new content block, it's necessary to clear system caches and set up the extension to ensure database changes are recognized. ```bash vendor/bin/typo3 cache:flush -g system vendor/bin/typo3 extension:setup --extension=my_sitepackage ``` -------------------------------- ### Example Extbase Controller (PHP) Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Guides/CreateExtbasePlugin/Index.rst A sample Extbase controller that retrieves data from the current content object and passes it to the Fluid view. It returns an HTML response. ```php request->getAttribute('currentContentObject'); $dataFromTypoScript = $contentObject->data; $this->view->assign('data', $dataFromTypoScript); return $this->htmlResponse(); } } ``` -------------------------------- ### Color Field Type Value Picker Items Example Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/YamlReference/FieldTypes/Color/Index.rst Example of how to define static color items for the value picker in the Color field type. Each item has a label and a corresponding hex value. ```yaml valuePicker: items: - label: 'Red' value: #FF0000 - label: 'Green' value: #008000 - label: 'Blue' value: #0000FF ``` -------------------------------- ### Create Content Block Skeleton Interactively Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Commands/Make/Index.rst Run the `make:content-block` command without required options to initiate an interactive guided process for creating a new content block. ```bash vendor/bin/typo3 make:content-block ``` -------------------------------- ### Advanced Slug Field Configuration with Fallback Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/YamlReference/FieldTypes/Slug/Index.rst This example demonstrates an advanced configuration for a Slug field, utilizing fallback fields for generation and including a date field. ```yaml name: example/slug fields: - identifier: slug type: Slug eval: unique generatorOptions: fields: - - header - fallbackField - date ``` -------------------------------- ### Run Unit and Functional Tests Source: https://github.com/friendsoftypo3/content-blocks/blob/main/README.md Execute unit or functional tests for the content-blocks project. Ensure composer dependencies are installed before running tests. ```bash composer install Build/Scripts/runTests.sh -s unit Build/Scripts/runTests.sh -s functional ``` -------------------------------- ### Define a Custom Basic with a Field Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/API/Basics/Index.rst Create your own reusable set of fields by defining a Basic in the ContentBlocks/Basics directory. This example shows a single text field with a label. ```yaml identifier: Vendor/YourBasic fields: - identifier: a_basic_field type: Text label: LLL:EXT:sitepackage/Resources/Private/Language/locallang.xlf:a_basic_field ``` -------------------------------- ### Example of Custom Vendor Prefix Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/API/Prefixing/Index.rst This configuration enables prefixing for all fields using a custom static vendor prefix, overriding the default vendor name. ```yaml name: my-vendor/my-element prefixFields: true prefixType: vendor vendorPrefix: tx_foo ``` -------------------------------- ### HTML Wrapper Example from FSC Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Guides/FluidStyledContent/Index.rst This HTML structure shows the default wrappers FSC adds to content elements, including an ID and spacing classes. ```html
``` -------------------------------- ### Minimal Radio Field Example Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/YamlReference/FieldTypes/Radio/Index.rst A basic configuration for a Radio field type, demonstrating the essential 'type' and 'items' properties. ```yaml name: example/radio fields: - identifier: radioboxes type: Radio items: - label: 'First option' value: 0 - label: 'Second option' value: 1 ``` -------------------------------- ### Minimal Collection Field Configuration Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/YamlReference/FieldTypes/Collection/Index.rst A basic example of a Collection field type, defining a simple list of text fields. ```yaml name: example/collection fields: - identifier: collection type: Collection labelField: text fields: - identifier: text type: Text ``` -------------------------------- ### Suggest Options Configuration Example Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/YamlReference/FieldTypes/Relation/Index.rst This YAML snippet illustrates the configuration for the suggest (autocomplete) wizard within a Relation field. It specifies additional search fields, a WHERE clause for filtering, and the minimum characters required to trigger the search. ```yaml suggestOptions: default: additionalSearchFields: 'nav_title, url' addWhere: 'AND pages.doktype = 1' minimumCharacters: 2 ``` -------------------------------- ### Link Field with Value Picker Configuration Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/YamlReference/FieldTypes/Link/Index.rst This example demonstrates how to configure a Link field with a value picker. The value picker allows users to select from predefined options, each with a label and a corresponding URL. ```yaml valuePicker: items: - label: 'TYPO3 CMS' value: 'https://www.typo3.org' - label: 'TYPO3 GmbH' value: 'https://www.typo3.com' ``` -------------------------------- ### Install Content Blocks via Composer Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Installation/Index.rst Use this Composer command to add the Content Blocks extension to your TYPO3 project. Ensure you are in your project's root directory. ```shell composer require friendsoftypo3/content-blocks ``` -------------------------------- ### Extend Specific Content Block TypoScript Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Guides/ExtendContentBlockTypoScript/Index.rst This example demonstrates how to extend the TypoScript for a specific content block. It allows for custom settings, variables, and data processing, and should be placed in EXT:site_package/Configuration/TypoScript/setup.typoscript. ```typoscript tt_content.myvendor_mycontentblockname { settings { defaultHeaderType = {$styles.content.defaultHeaderType} } variables { demo = TEXT demo { value = some text } } dataProcessing { 200 = menu 200 { special = rootline as = breadcrumb } } } ``` -------------------------------- ### Example of Vendor Prefixing Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/API/Prefixing/Index.rst This configuration enables prefixing for all fields using the 'vendor' type, where only the vendor part of the content block name is used as the prefix. ```yaml name: my-vendor/my-element prefixFields: true prefixType: vendor ``` -------------------------------- ### Advanced SelectNumber Field with Icons and Default Value Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/YamlReference/FieldTypes/SelectNumber/Index.rst This example demonstrates a SelectNumber field configured with icons, a default selected value, and specific items. ```yaml name: example/select-number fields: - identifier: select_number_icons type: SelectNumber fieldWizard: selectIcons: disabled: false default: 2 items: - label: 'Image beside text (left)' value: 1 icon: content-beside-text-img-left - label: 'Image beside text (right)' value: 2 icon: content-beside-text-img-right - label: 'Image above text (center)' value: 3 icon: content-beside-text-img-above-cent ``` -------------------------------- ### Run Automatic Mask to Content Blocks Migration Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Migrations/Mask/Index.rst Execute the migration command to convert Mask elements into Content Blocks. This command should be run after installing both the migration tool and Content Blocks. ```shell vendor/bin/typo3 mask-to-content-blocks:migrate ``` -------------------------------- ### Override File Type with Palette Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/API/TypeOverrides/Index.rst This example demonstrates overriding a file type, specifically 'image', by defining a Palette. This allows for custom field configurations within the file reference. ```yaml name: friendsoftypo3/example table: tx_friendsoftypo3_example prefixFields: false labelField: title fields: - identifier: title type: Text label: Title - identifier: file_override type: File overrideType: image: - identifier: image_overlay_palette type: Palette label: 'LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.imageoverlayPalette' fields: - identifier: alternative useExistingField: true - identifier: description useExistingField: true - type: Linebreak - identifier: link useExistingField: true - identifier: title useExistingField: true - type: Linebreak - identifier: example_custom_field type: Text label: 'My custom Field' - type: Linebreak - identifier: crop useExistingField: true ``` -------------------------------- ### Define Entry Points for Element Browser Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/YamlReference/FieldTypes/Relation/Index.rst Configure the default starting page for the element browser when using the Relation field type. This setting helps to direct users to specific locations within the record structure. ```yaml elementBrowserEntryPoints: _default: 42 ``` -------------------------------- ### Example of Full Prefixing Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/API/Prefixing/Index.rst This configuration enables prefixing for all fields using the 'full' type, where the entire content block name is used as the prefix after removing dashes and converting slashes to underscores. ```yaml name: my-vendor/my-element prefixFields: true prefixType: full ``` -------------------------------- ### Minimal Content Element Configuration Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/API/ContentElements/Index.rst Defines a basic Content Element with a name and a single field. Use this as a starting point for custom content types. ```yaml name: example/cta fields: - identifier: header useExistingField: true ``` -------------------------------- ### Advanced Relation Field with Suggest Options Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/YamlReference/FieldTypes/Relation/Index.rst This example demonstrates an advanced Relation field configuration, including settings for the suggest (autocomplete) wizard to enhance user experience during record selection. ```yaml name: example/relation fields: - identifier: page_select type: Relation allowed: 'pages' maxitems: 1 suggestOptions: default: additionalSearchFields: 'nav_title, url' addWhere: 'AND pages.doktype = 1' ``` -------------------------------- ### Advanced Textarea Field Configuration Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/YamlReference/FieldTypes/Textarea/Index.rst Demonstrates an advanced Textarea field setup with default value, placeholder, required status, and specified rows. Useful for detailed text input requirements. ```yaml name: example/textarea fields: - identifier: textarea type: Textarea default: "Default value" placeholder: "Placeholder text" required: true rows: 15 ``` -------------------------------- ### Minimal Tab Field Configuration Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/YamlReference/FieldTypes/Tab/Index.rst Demonstrates the minimal configuration for a 'Tab' field type within a TYPO3 Content Block's form definition. This example shows how to insert a tab between other fields. ```yaml name: example/tab fields: - identifier: text type: Text - identifier: tab_1 type: Tab - identifier: text2 type: Textarea ``` -------------------------------- ### Minimal Palette Field Configuration Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/YamlReference/FieldTypes/Palette/Index.rst A minimal example of defining a Palette field in YAML, including nested fields. Ensure unique identifiers for palettes to prevent overrides. ```yaml name: example/palette fields: - identifier: palette_1 type: Palette label: Palette 1 description: My palette description fields: - identifier: number type: Number - identifier: text type: Text ``` -------------------------------- ### Extend Partial Root Paths for All Content Blocks Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Guides/SharedPartials/Index.rst Configure the `partialRootPaths` for all Content Blocks to include custom partials from your extension. This is typically done in your site package's TypoScript setup. ```typoscript lib.contentBlock { partialRootPaths { 100 = EXT:site_package/Resources/Private/Partials/ContentElements/ } } ``` -------------------------------- ### Define a Basic Record Type Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/YamlReference/ContentTypes/RecordTypes/Index.rst Configure a new record type by specifying its name, the database table it maps to, and the field used for its label. This is the fundamental setup for any custom content type. ```yaml name: example/my-record-type table: tx_vendor_my_record_type labelField: title fields: - identifier: title type: Text ``` -------------------------------- ### Register Extbase Plugin in TypoScript Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Guides/CreateExtbasePlugin/Index.rst Configures the TypoScript for a specific content element to use an Extbase plugin. Ensure 'extensionName' and 'pluginName' match your setup. The 'templateRootPaths' should point to your Fluid templates. ```typoscript tt_content.vendor_artistslist.20 = EXTBASEPLUGIN tt_content.vendor_artistslist.20 { extensionName = MyExtension pluginName = MyPlugin # If your controller returns a HTML response, set the template path like this: view { templateRootPaths.0 = EXT:site_package/ContentBlocks/ContentElements/artists/templates } } ``` -------------------------------- ### Map Frontend Template to Page Type with TypoScript Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Guides/PageTypeTemplates/Index.rst Use a TypoScript CASE cObject with 'doktype' as the key to render different frontend templates based on the Page Type. This setup expects a specific template file (e.g., Blog.html) in your extension's Resources/Private/Templates folder. This method cannot be used with PAGEVIEW. ```typoscript page = PAGE page { 10 = FLUIDTEMPLATE 10 { templateRootPaths { 0 = EXT:site_package/Resources/Private/Templates/ } templateName = TEXT templateName { cObject = CASE cObject { key.field = doktype default = TEXT default.value = Default 1701284006 = TEXT 1701284006.value = Blog } } } } ``` -------------------------------- ### Backend Preview Template for Page Types Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/API/PageTypes/Index.rst Create a Fluid template for backend previews of custom Page Types. This example shows how to display a custom field like 'author' and link to its editing form using TYPO3's backend view helpers. ```html
Author: {data.author}
``` -------------------------------- ### Generate Frontend and Backend Preview Templates via CLI Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/ChangeLog/2.4/Index.rst Use the content-blocks:generate:frontend and content-blocks:generate:backend-preview CLI commands to create starter Fluid templates. The --force option can be used to overwrite existing files. ```bash vendor/bin/typo3 content-blocks:generate:frontend example/my-block ``` ```bash vendor/bin/typo3 content-blocks:generate:backend-preview example/my-block ``` -------------------------------- ### Display Help for Make Content Block Command Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Commands/Make/Index.rst Use the --help option to see all available arguments and options for the `make:content-block` command. ```bash vendor/bin/typo3 make:content-block --help ``` -------------------------------- ### Render Documentation Locally Source: https://github.com/friendsoftypo3/content-blocks/blob/main/README.md Commands to render and test the project's documentation locally. Docker is required for the 'make docs' command. ```bash make docs make test-docs ``` -------------------------------- ### Money Field Type Example Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/DeveloperCorner/ExtendFieldTypes/Index.rst An example implementation of a custom 'Money' field type extending AbstractFieldType. It demonstrates how to handle settings and generate TCA configuration. ```php setCommonProperties($settings); $default = $settings['default'] ?? $self->default; $self->default = (float)$default; $self->required = (bool)($settings['required'] ?? $self->required); $self->nullable = (bool)($settings['nullable'] ?? $self->nullable); return $self; } public function getTca(): array { $tca = $this->toTca(); $config['type'] = $this->getTcaType(); if ($this->default !== 0.0) { $config['default'] = $this->default; } if ($this->required) { $config['required'] = true; } $config['format'] = 'decimal'; $tca['config'] = array_replace($tca['config'] ?? [], $config); ``` -------------------------------- ### XLF Translation for Checkbox Items Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/YamlReference/FieldTypes/Checkbox/Index.rst Example of XLF translation keys for checkbox item labels. The ID follows the pattern 'FIELD_IDENTIFIER.items.n.label'. ```xml Label for first Checkbox item Label for second Checkbox item Label for nth Checkbox item ``` -------------------------------- ### Advanced Radio Field Example Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/YamlReference/FieldTypes/Radio/Index.rst An advanced configuration for a Radio field type, including a default selected value and string-based values for its items. ```yaml name: example/radio fields: - identifier: radioboxes type: Radio default: 'one' items: - label: 'First option' value: 'one' - label: 'Second option' value: 'two' - label: 'Third option' value: 'three' ``` -------------------------------- ### Reuse Common tt_content Fields Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/API/ReuseExistingFields/Index.rst Example of reusing common fields from `tt_content` like 'header', 'bodytext', and 'image'. For 'bodytext', `enableRichtext` can be set. ```yaml name: vendor/content-block-name fields: - identifier: header useExistingField: true - identifier: bodytext useExistingField: true enableRichtext: true - identifier: image useExistingField: true ``` -------------------------------- ### Retrieve LLL Path for Labels Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Templating/Index.rst Use the LanguagePathViewHelper to get the LLL path for the labels.xlf file of the current Content Block. This is useful for translations. ```html ``` -------------------------------- ### Generate Backend Preview Template Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Commands/GenerateEditorPreviewTemplate/Index.rst Generates a backend preview template for the specified Content Block. The template will be created at `templates/backend-preview.fluid.html` within the Content Block's directory. ```bash vendor/bin/typo3 content-blocks:generate:backend-preview example/my-block ``` -------------------------------- ### Advanced Folder Field Configuration with Entry Point and Min Items Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/YamlReference/FieldTypes/Folder/Index.rst This YAML configuration demonstrates advanced settings for a Folder field. It specifies an entry point for the element browser and sets a minimum of one item to be selected. ```yaml name: example/folder fields: - identifier: folder type: Folder elementBrowserEntryPoints: _default: '1:/styleguide/' minitems: 1 ``` -------------------------------- ### Run Content Blocks Folder Structure Migration Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Migrations/ContentBlocks12/Index.rst Execute the migration wizard to rename Content Blocks folders and files to the new structure. Ensure the old extension is loaded before running. ```shell typo3 upgrade:run contentBlocksFolderStructureMigration ``` -------------------------------- ### Specify Configuration Path Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Commands/Make/Index.rst Use the --config-path option to point to a custom YAML file for command configurations. ```shell vendor/bin/typo3 make:content-block --config-path="some-folder/my-config.yaml" ``` -------------------------------- ### Extend All Content Blocks TypoScript Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Guides/ExtendContentBlockTypoScript/Index.rst This TypoScript snippet shows how to extend all content blocks by adding settings, variables, and data processing configurations. It's typically placed in EXT:site_package/Configuration/TypoScript/setup.typoscript. ```typoscript lib.contentBlock { settings { defaultHeaderType = {$styles.content.defaultHeaderType} } variables { demo = TEXT demo { value = some text } } dataProcessing { 200 = menu 200 { special = rootline as = breadcrumb } } } ``` -------------------------------- ### TypoScript for Specific Content Element Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Guides/ExtendContentBlockTypoScript/Index.rst Example of TypoScript for a specific content element, showing how to define template paths. This TypoScript object supports all properties of FLUIDTEMPLATE. ```typoscript tt_content { myvendor_mycontentblockname { file = EXT:site_package/ContentBlocks/ContentElements/content-element-name/templates/frontend.fluid.html layoutRootPaths { 20 = EXT:site_package/ContentBlocks/ContentElements/content-element-name/templates/layouts/ } partialRootPaths { 20 = EXT:site_package/ContentBlocks/ContentElements/content-element-name/templates/partials/ } } } ``` -------------------------------- ### Minimal Select Single Configuration Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/YamlReference/FieldTypes/Select/Index.rst A basic configuration for a 'Select' field using 'selectSingle' render type, displaying a dropdown list of items. ```yaml name: example/select fields: - identifier: select type: Select renderType: selectSingle items: - label: 'The first' value: one - label: 'The second' value: two ``` -------------------------------- ### Styling Hidden Relations in Backend Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/API/BackendPreview/Index.rst Example of how to conditionally style or hide hidden relations, such as Collections, within the backend preview. It iterates through relations and checks for systemProperties.disabled. ```html ``` -------------------------------- ### Include Fluid Partial Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Definition/Templates/Index.rst Use this Fluid partial to include other template components. Ensure partials start with an uppercase letter due to current Fluid restrictions. ```html ``` -------------------------------- ### Include Pre-defined Basics in Content Block Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/API/Basics/Index.rst Add standard Fluid Styled Content tabs like Appearance and Links to your Content Block by listing their identifiers in the 'basics' array. ```yaml name: example/basics basics: - TYPO3/Appearance - TYPO3/Links ``` -------------------------------- ### Generate Frontend Template for Content Block Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Commands/GenerateFrontendTemplate/Index.rst Use this command to generate a frontend Fluid template for a specific Content Block. The `content-block` argument specifies the vendor and name of the block. ```bash vendor/bin/typo3 content-blocks:generate:frontend example/my-block ``` -------------------------------- ### Force Overwrite Backend Preview Template Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Commands/GenerateEditorPreviewTemplate/Index.rst Use the `--force` option to overwrite an existing backend preview template file for the specified Content Block. ```bash vendor/bin/typo3 content-blocks:generate:backend-preview example/my-block --force ``` -------------------------------- ### Enable Icon Display in Select Fields Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/YamlReference/FieldTypes/Select/Index.rst This configuration is necessary to enable the display of icons for select field items, as referenced in the 'Select Field Items with Icons' example. ```yaml fieldWizard: selectIcons: disabled: false ``` -------------------------------- ### Register Content Element Wizard Group (TSconfig) Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Migrations/ContentBlocks12/Index.rst Example of registering a custom content element group using TSconfig, with the group name 'my_group' placed before 'common'. ```typoscript mod.wizards.newContentElement.wizardItems { my_group { header = LLL:EXT:my_package/Resources/Private/Language/Backend.xlf:content_group.my_group before = common } } ``` -------------------------------- ### Remove Mask and Migration Extension Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Migrations/Mask/Index.rst After successful migration, remove the Mask extension and the migration tool to avoid duplicate content element definitions. This command requires Composer to be installed. ```shell composer remove mask/mask nhovratov/mask-to-content-blocks ``` -------------------------------- ### List Content Blocks with Custom Order Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Commands/List/Index.rst Specify a different order for sorting the results, such as by content type. ```bash vendor/bin/typo3 content-blocks:list --order content-type ``` -------------------------------- ### Advanced Category Field Configuration Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/YamlReference/FieldTypes/Category/Index.rst Configure a Category field with specific item limits, starting points for the category tree, and a one-to-one relationship. JavaScript validation enforces the minitems constraint. ```yaml name: example/category fields: - identifier: categories type: Category minitems: 1 treeConfig: startingPoints: 7 relationship: oneToOne ``` -------------------------------- ### Using Asset ViewHelpers for CSS and JavaScript Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Templating/Index.rst Includes CSS and JavaScript assets using the `AssetPathViewHelper` within Fluid templates. Ensure assets are placed in the correct `assets/` directory relative to the Content Block. Identifiers can be used to manage asset inclusion. ```html ``` -------------------------------- ### Directory Structure for Custom Page Type Icons Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/API/PageTypes/Index.rst Illustrates the directory structure for placing custom icons for Page Type states. Supported icons include 'icon-hide-in-menu.svg' and 'icon-root.svg' placed in the assets folder. ```none ├── assets │ │── icon.svg │ │── icon-hide-in-menu.svg │ └── icon-root.svg └── config.yaml ``` -------------------------------- ### Define Content Block Structure with config.yaml Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Definition/ConfigYaml/Index.rst Use this YAML file to define the name and fields for a Content Block. Ensure the 'name' is unique and fields have unique 'identifier's. Existing fields can be reused with 'useExistingField: true'. ```yaml name: vendor/content-block-name fields: - identifier: header useExistingField: true - identifier: my_text_field type: Text max: 10 ``` -------------------------------- ### Set Multiple Display Conditions Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/YamlReference/FieldTypes/Index.rst Combine multiple rules using 'AND' in `displayCond` to enforce several conditions for field visibility. ```yaml displayCond: AND: - 'FIELD:identifier:=:value' - 'FIELD:another_identifier:=:1' ``` -------------------------------- ### Configure Record Security Settings (YAML) Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/YamlReference/ContentTypes/RecordTypes/Index.rst Use the 'security' key to bypass various TYPO3 restrictions. Set specific options like 'ignoreWebMountRestriction' to 'true' to allow access bypassing usual rules. ```yaml security: ignoreWebMountRestriction: true ignoreRootLevelRestriction: true ignorePageTypeRestriction: true ``` -------------------------------- ### File Field: Type Overrides Configuration Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/YamlReference/FieldTypes/File/Index.rst Configures type overrides for the File field to customize how specific file types are handled. This example shows overriding the image type with a custom palette. ```yaml overrideType: image: - identifier: image_overlay_palette type: Palette label: 'LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.imageoverlayPalette' fields: - identifier: alternative useExistingField: true - identifier: description useExistingField: true - type: Linebreak - identifier: link useExistingField: true - identifier: title useExistingField: true - type: Linebreak - identifier: example_custom_field type: Text label: 'My custom Field' - type: Linebreak - identifier: crop useExistingField: true ``` -------------------------------- ### Render Nested Content Elements in Backend Preview Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/API/NestedContentElements/Index.rst Utilize the provided Fluid partial 'PageLayout/Grid' to render backend previews of nested content elements, mimicking the Core page layout. ```html ``` -------------------------------- ### Migrate AssetViewHelper Usage to AssetPathViewHelper Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Migrations/ContentBlocks12/Index.rst Update Fluid templates to use the new AssetPathViewHelper for building asset paths, replacing the custom cb:asset.css ViewHelper. ```html ``` -------------------------------- ### Register Content Element Wizard Group (PHP) Source: https://github.com/friendsoftypo3/content-blocks/blob/main/Documentation/Migrations/ContentBlocks12/Index.rst Register a custom content element group for 'tt_content' table and 'CType' field using PHP. This example adds 'my_group' before the 'default' group. ```php 'Left', 'colPos' => 200], ['name' => 'Right', 'colPos' => 201], ], ] ); $GLOBALS['TCA']['tt_content']['containerConfiguration'][$containerConfiguration->getCType()] = $containerConfiguration->toArray(); ```