Skip to content

Commit

Permalink
[TASK] Use lowercase partials and layouts for previews / docs
Browse files Browse the repository at this point in the history
  • Loading branch information
nhovratov committed Sep 21, 2024
1 parent abf7c7e commit bc6f6c4
Show file tree
Hide file tree
Showing 44 changed files with 56 additions and 41 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file datatype="plaintext" original="Labels.xlf" source-language="en" date="2024-01-29T13:43:08+00:00" product-name="example/accordion">
<file datatype="plaintext" original="labels.xlf" source-language="en" date="2024-09-20T23:35:32+00:00" product-name="example/accordion">
<header/>
<body>
<trans-unit id="title" resname="title">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
data-namespace-typo3-fluid="true"
>

<f:asset.css identifier="cbAccordionCssFrontend" href="{cb:assetPath()}/Frontend.css"/>
<f:asset.script identifier="cbAccordionJsFrontend" src="{cb:assetPath()}/Frontend.js"/>
<f:asset.css identifier="cbAccordionCssFrontend" href="{cb:assetPath()}/frontend.css"/>
<f:asset.script identifier="cbAccordionJsFrontend" src="{cb:assetPath()}/frontend.js"/>

<div class="cb-accordion">
<f:for each="{data.accordion_item}" as="item">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
data-namespace-typo3-fluid="true"
>

<f:asset.css identifier="cbAccordionCssBackend" href="{cb:assetPath()}/EditorPreview.css"/>
<f:asset.css identifier="cbAccordionCssBackend" href="{cb:assetPath()}/preview.css"/>

<div class="cb-accordion">
<f:for each="{data.accordion_item}" as="item">
<be:link.editRecord uid="{item.uid}" table="{item.tableName}">
<be:link.editRecord uid="{item.uid}" table="{item.mainType}">
<div class="accordion-item">
{item.text}
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file datatype="plaintext" original="Labels.xlf" source-language="en" date="2024-01-29T13:43:08+00:00" product-name="example/card-group">
<file datatype="plaintext" original="labels.xlf" source-language="en" date="2024-09-20T23:35:32+00:00" product-name="example/card-group">
<header/>
<body>
<trans-unit id="title" resname="title">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
data-namespace-typo3-fluid="true"
>

<f:asset.css identifier="cbCardGroupCssFrontend" href="{cb:assetPath()}/Frontend.css"/>
<f:asset.css identifier="cbCardGroupCssFrontend" href="{cb:assetPath()}/frontend.css"/>

<div class="cb-card-group">
<f:if condition="{data.card_group_item}">
Expand All @@ -16,7 +16,7 @@
<f:if condition="{item.image.0}">
<div class="card-img-top">
<f:render partial="LinkWrap" arguments="{link: item.link, link_title: item.title}" contentAs="content">
<f:image src="{item.image.0.uid}" treatIdAsReference="1"/>
<f:image image="{item.image.0}"/>
</f:render>
</div>
</f:if>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
data-namespace-typo3-fluid="true"
>

<f:asset.css identifier="cbCardGroupCssBackend" href="{cb:assetPath()}/EditorPreview.css"/>
<f:asset.css identifier="cbCardGroupCssBackend" href="{cb:assetPath()}/preview.css"/>

<div class="cb-card-group">
<f:if condition="{data.card_group_item}">
<div class="card-group-element card-group-element-align-{data.settings.alignment} card-group-element-columns-{data.settings.row_items}">
<f:for each="{data.card_group_item}" as="item" iteration="iteration">

<div class="card-group-element-item">
<be:link.editRecord uid="{item.uid}" table="{item.tableName}">
<be:link.editRecord uid="{item.uid}" table="{item.mainType}">
<div class="card">
<f:if condition="{item.image.0}">
<div class="card-img-top">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file datatype="plaintext" original="Labels.xlf" source-language="en" date="2024-01-29T15:36:43+00:00" product-name="example/cta">
<file datatype="plaintext" original="labels.xlf" source-language="en" date="2024-09-20T23:35:32+00:00" product-name="example/cta">
<header/>
<body>
<trans-unit id="title" resname="title">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
data-namespace-typo3-fluid="true"
>

<f:asset.css identifier="cbCtaCssFrontend" href="{cb:assetPath()}/Frontend.css"/>
<f:asset.css identifier="cbCtaCssFrontend" href="{cb:assetPath()}/frontend.css"/>

<div class="cb-cta">
<f:if condition="{data.background_image}">
<f:variable name="backgroundUrl">{f:uri.image(src:'{data.background_image.0.uid}', treatIdAsReference:1)}</f:variable>
<f:variable name="backgroundUrl">{f:uri.image(image: data.background_image.0)}</f:variable>
<f:variable name="elementBgId">cb-cta-bg-{data.uid}</f:variable>
<f:variable name="backgroundImageStyles">{elementBgId} { background-image: url({backgroundUrl});}</f:variable>
<f:asset.css identifier="cb-cta-bg-{data.uid}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
data-namespace-typo3-fluid="true"
>

<f:asset.css identifier="cbCtaCssBackend" href="{cb:assetPath()}/EditorPreview.css"/>
<f:asset.css identifier="cbCtaCssBackend" href="{cb:assetPath()}/preview.css"/>

<div class="cb-cta">
<h2>{data.header}</h2>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file datatype="plaintext" original="Labels.xlf" source-language="en" date="2024-05-01T19:02:23+00:00" product-name="example/icon-group">
<file datatype="plaintext" original="labels.xlf" source-language="en" date="2024-09-20T23:35:32+00:00" product-name="example/icon-group">
<header/>
<body>
<trans-unit id="title" resname="title">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
data-namespace-typo3-fluid="true"
>

<f:asset.css identifier="cbIconGroupCssFrontend" href="{cb:assetPath()}/Frontend.css"/>
<f:asset.css identifier="cbIconGroupCssFrontend" href="{cb:assetPath()}/frontend.css"/>

<div class="cb-icon-group">
<f:if condition="{data.icon_group_item}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
data-namespace-typo3-fluid="true"
>

<f:asset.css identifier="cbIconGroupCssBackend" href="{cb:assetPath()}/EditorPreview.css"/>
<f:asset.css identifier="cbIconGroupCssBackend" href="{cb:assetPath()}/preview.css"/>

<div class="cb-icon-group">
<f:if condition="{data.icon_group_item}">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file datatype="plaintext" original="Labels.xlf" source-language="en" date="2024-01-29T13:43:08+00:00" product-name="example/imageslider">
<file datatype="plaintext" original="labels.xlf" source-language="en" date="2024-09-20T23:35:32+00:00" product-name="example/imageslider">
<header/>
<body>
<trans-unit id="title" resname="title">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<f:asset.css identifier="cbImagesliderCssSwiffySlider" href="{cb:assetPath()}/Library/SwiffySlider/swiffy-slider.min.css"/>
<f:asset.script identifier="cbImagesliderJsSwiffySlider" src="{cb:assetPath()}/Library/SwiffySlider/swiffy-slider.min.js"/>
<f:asset.css identifier="cbImagesliderCssFrontend" href="{cb:assetPath()}/Frontend.css"/>
<f:asset.css identifier="cbImagesliderCssFrontend" href="{cb:assetPath()}/frontend.css"/>

<div class="cb-imageslider">
<div class="swiffy-slider slider-item-ratio slider-item-ratio-16x9 slider-nav-animation slider-nav-animation-fadein slider-item-first-visible" id="swiffy-animation">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
data-namespace-typo3-fluid="true"
>

<f:asset.css identifier="cbImagesliderCssBackend" href="{cb:assetPath()}/EditorPreview.css"/>
<f:asset.css identifier="cbImagesliderCssBackend" href="{cb:assetPath()}/preview.css"/>

<div class="cb-imageslider">
<f:for each="{data.assets}" as="asset">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file datatype="plaintext" original="Labels.xlf" source-language="en" date="2024-01-29T13:43:08+00:00" product-name="example/tabs">
<file datatype="plaintext" original="labels.xlf" source-language="en" date="2024-09-20T23:35:32+00:00" product-name="example/tabs">
<header/>
<body>
<trans-unit id="title" resname="title">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
data-namespace-typo3-fluid="true"
>

<f:asset.css identifier="cbTabsCssFrontend" href="{cb:assetPath()}/Frontend.css"/>
<f:asset.script identifier="cbTabsJsFrontend" src="{cb:assetPath()}/Frontend.js"/>
<f:asset.css identifier="cbTabsCssFrontend" href="{cb:assetPath()}/frontend.css"/>
<f:asset.script identifier="cbTabsJsFrontend" src="{cb:assetPath()}/frontend.js"/>

<div class="cb-tabs">
<div class="tab">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file datatype="plaintext" original="Labels.xlf" source-language="en" date="2024-01-30T18:23:22+00:00" product-name="example/text">
<file datatype="plaintext" original="labels.xlf" source-language="en" date="2024-09-20T23:35:32+00:00" product-name="example/text">
<header/>
<body>
<trans-unit id="title" resname="title">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file datatype="plaintext" original="Labels.xlf" source-language="en" date="2024-01-29T13:43:08+00:00" product-name="example/example-page-type">
<file datatype="plaintext" original="labels.xlf" source-language="en" date="2024-09-20T23:35:32+00:00" product-name="example/example-page-type">
<header/>
<body>
<trans-unit id="title" resname="title">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file datatype="plaintext" original="Labels.xlf" source-language="en" date="2024-01-29T13:43:08+00:00" product-name="hov/notype">
<file datatype="plaintext" original="labels.xlf" source-language="en" date="2024-09-20T23:35:32+00:00" product-name="hov/notype">
<header/>
<body>
<trans-unit id="title" resname="title">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file datatype="plaintext" original="Labels.xlf" source-language="en" date="2024-01-29T13:43:08+00:00" product-name="hov/record1">
<file datatype="plaintext" original="labels.xlf" source-language="en" date="2024-09-20T23:35:32+00:00" product-name="hov/record1">
<header/>
<body>
<trans-unit id="title" resname="title">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file datatype="plaintext" original="Labels.xlf" source-language="en" date="2024-01-29T13:43:08+00:00" product-name="hov/record2">
<file datatype="plaintext" original="labels.xlf" source-language="en" date="2024-09-20T23:35:32+00:00" product-name="hov/record2">
<header/>
<body>
<trans-unit id="title" resname="title">
Expand Down
4 changes: 2 additions & 2 deletions Classes/Backend/Preview/PageLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ protected function createView(ContentTypeInterface $contentTypeDefinition, int $
protected function getContentBlocksPartialRootPaths(string $contentBlockPrivatePath, int $pageUid): array
{
$partialRootPaths = $this->rootPathsSettings->getContentBlocksPartialRootPaths($pageUid);
$partialRootPaths[] = $contentBlockPrivatePath . '/Partials/';
$partialRootPaths[] = $contentBlockPrivatePath . '/partials/';
return $partialRootPaths;
}

Expand All @@ -114,7 +114,7 @@ protected function getContentBlocksPartialRootPaths(string $contentBlockPrivateP
protected function getContentBlocksLayoutRootPaths(string $contentBlockPrivatePath, int $pageUid): array
{
$partialRootPaths = $this->rootPathsSettings->getContentBlocksLayoutRootPaths($pageUid);
$partialRootPaths[] = $contentBlockPrivatePath . '/Layouts';
$partialRootPaths[] = $contentBlockPrivatePath . '/layouts';
return $partialRootPaths;
}

Expand Down
4 changes: 2 additions & 2 deletions Classes/Backend/Preview/PreviewRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ protected function getContentBlocksPartialRootPaths(string $contentBlockPrivateP
'EXT:backend/Resources/Private/Partials/',
'EXT:content_blocks/Resources/Private/Partials/',
...$contentBlockPartialRootPaths,
$contentBlockPrivatePath . '/Partials/',
$contentBlockPrivatePath . '/partials/',
];
return $partialRootPaths;
}
Expand All @@ -116,7 +116,7 @@ protected function getContentBlocksPartialRootPaths(string $contentBlockPrivateP
protected function getContentBlocksLayoutRootPaths(string $contentBlockPrivatePath, int $pageUid): array
{
$layoutRootPaths = $this->rootPathsSettings->getContentBlocksLayoutRootPaths($pageUid);
$layoutRootPaths[] = $contentBlockPrivatePath . '/Layouts/';
$layoutRootPaths[] = $contentBlockPrivatePath . '/layouts/';
return $layoutRootPaths;
}
}
2 changes: 1 addition & 1 deletion Classes/Builder/ContentBlockBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ protected function createFrontendHtml(LoadedContentBlock $contentBlock, string $
protected function createExamplePublicAssets(string $publicPath): void
{
GeneralUtility::writeFile(
$publicPath . '/editor-preview.css',
$publicPath . '/preview.css',
'/* Created by Content Blocks */'
);
GeneralUtility::writeFile(
Expand Down
2 changes: 1 addition & 1 deletion Classes/Generator/HtmlTemplateCodeGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function generateEditorPreviewTemplate(LoadedContentBlock $contentBlockCo
$package = $contentBlockConfiguration->getName();
$vendor = $contentBlockConfiguration->getVendor();

$defaultContent[] = '<f:asset.css identifier="content-block-' . $vendor . '-' . $package . '-be" href="{cb:assetPath()}/editor-preview.css"/>';
$defaultContent[] = '<f:asset.css identifier="content-block-' . $vendor . '-' . $package . '-be" href="{cb:assetPath()}/preview.css"/>';
$defaultContent[] = '';
$defaultContent[] = 'Preview for Content Block: ' . $contentBlockConfiguration->getName() . '<br>';
$defaultContent[] = 'Header: {data.header}';
Expand Down
2 changes: 1 addition & 1 deletion Documentation/Definition/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ named **assets**, **templates** and **language**.
│ └── labels.xlf
├── templates
| ├── partials
| | └── component.html
| | └── Component.html
│ ├── preview.html
│ └── frontend.html
└── config.yaml
Expand Down
21 changes: 18 additions & 3 deletions Documentation/Definition/Source/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,33 @@ You can access your fields by the variable :html:`{data}`.

Learn more about :ref:`templating <cb_templating>`.

Partials
partials
========

For larger Content Elements, you can divide your **frontend.html** template into
smaller chunks by creating separate partials here.

Partials are included as you normally would in any Fluid template.

.. note::

Due to current Fluid restrictions, partials have to start with an uppercase
letter. This restriction might be lifted in later Fluid versions (v5 or above).


.. code-block:: html

<f:render partial="component" arguments="{_all}"/>
<f:render partial="Component" arguments="{_all}"/>

See also:

* Learn how to :ref:`share Partials <cb_extension_partials>` between Content Blocks.
* Learn how to :ref:`share partials <cb_extension_partials>` between Content Blocks.

layouts
=======

You can also add layouts to your Content Block if needed.

.. code-block:: html

<f:layout name="MyLayout">
4 changes: 2 additions & 2 deletions Documentation/Guides/ExtendContentBlockTypoScript/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ Example:
myvendor_mycontentblockname {
file = EXT:site_package/ContentBlocks/ContentElements/content-element-name/templates/frontend.html
layoutRootPaths {
20 = EXT:site_package/ContentBlocks/ContentElements/content-element-name/templates/Layouts/
20 = EXT:site_package/ContentBlocks/ContentElements/content-element-name/templates/layouts/
}
partialRootPaths {
20 = EXT:site_package/ContentBlocks/ContentElements/content-element-name/templates/Partials/
20 = EXT:site_package/ContentBlocks/ContentElements/content-element-name/templates/partials/
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Documentation/Migrations/Mask/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Templates

This is the easy part. Simply copy the Mask template into **frontend.html** and
you are done. That said, if you didn't use any partials or layouts. If so, move
these to the according **templates/partials** and **templates/Layouts** folder in your
these to the according **templates/partials** and **templates/layouts** folder in your
Content Block.

Icon
Expand Down

0 comments on commit bc6f6c4

Please sign in to comment.