Skip to content

Commit

Permalink
Merge branch 'main' into page-meta-attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
brotkrueml authored Oct 11, 2024
2 parents 98846b2 + 0b1891b commit 7a6fb93
Show file tree
Hide file tree
Showing 11 changed files with 115 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
run: |
mkdir -p Documentation-GENERATED-temp \
&& docker run --rm --pull always -v $(pwd):/project \
ghcr.io/typo3-documentation/render-guides:latest --config=Documentation --no-progress --fail-on-log
ghcr.io/typo3-documentation/render-guides:latest --config=Documentation --no-progress --minimal-test
41 changes: 39 additions & 2 deletions Documentation/ContentObjects/Extbaseplugin/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ Properties

.. _cobj-extbaseplugin-examples:

Example
=======
Example: Display an Extbase plugin via TypoScript
=================================================

.. code-block:: typoscript
:caption: EXT:my_extension/Configuration/TypoScript/setup.typoscript
Expand All @@ -62,6 +62,43 @@ Example
page.10.extensionName = MyExtension
page.10.pluginName = MyPlugin
.. _cobj-extbaseplugin-examples-fluid:

Example: Display an Extbase plugin in a Fluid template
======================================================

It is possible to display an Extbase plugin in Fluid using the
:ref:`CObject ViewHelper <f:cObject> <t3viewhelper:typo3-fluid-cobject>`:

.. literalinclude:: _CodeSnippets/_SomeTemplate.html
:caption: EXT:my_extension/Resources/Private/Templates/Pages/SomeTemplate.html

Create a lib object which utilizes the :typoscript:`EXTBASEPLUGIN` into
a :typoscript:`lib` object:

.. literalinclude:: _CodeSnippets/_libMyPlugin.typoscript
:caption: EXT:my_extension/Configuration/TypoScript/setup.typoscript

For `extensionName` and `pluginName` use the names as configured in
:php:`\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin()`:

.. literalinclude:: _CodeSnippets/_configurePlugin.php
:caption: EXT:my_extension/ext_localconf.php
:emphasize-lines: 9,10

If you passed data to the ViewHelper, you can access the data in the controller's
action by getting the currentContentObject from the request:

.. literalinclude:: _CodeSnippets/_MyController.php
:caption: EXT:my_extension/Classes/Controller/MyController.php
:emphasize-lines: 16,17

.. note::
You should treat all data from the
:php-short:`\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer` as
potential user input. Do not use it unescaped and do not trust to receive
certain types.

.. _cobj-extbaseplugin-history:

History
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\Controller;

use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;

class MyController extends ActionController
{
public function listAction(): ResponseInterface
{
/** @var ContentObjectRenderer $contentObject */
$contentObject = $this->request->getAttribute('currentContentObject');
$dataFromTypoScript = $contentObject->data;
$someValue = (int)($dataFromTypoScript['someValue'] ?? 0);
$someSetting = $dataFromTypoScript['someSetting'] ?? '';
// Do something
return $this->htmlResponse();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!-- ... -->
<f:cObject
typoscriptObjectPath="lib.myPlugin"
data="{someValue: page.pageRecord.someValue, someSetting: site.someSetting}"
/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

use MyVendor\MyExtension\Controller\MyController;
use TYPO3\CMS\Extbase\Utility\ExtensionUtility;

defined('TYPO3') || die('Access denied.');

ExtensionUtility::configurePlugin(
'MyExtension',
'MyPlugIn1',
[MyController::class => 'list, show'],
[],
ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT,
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
lib.myPlugin = EXTBASEPLUGIN
lib.myPlugin {
extensionName = MyExtension
pluginName = MyPlugIn1
settings.detailPid = 42
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<f:render partial="Jumbotron" arguments="{jumbotronContent: myContent.jumbotron}"/>
<main>
<f:for each="{myContent.left.records}" as="contentElement">
<h3>{contentElement.data.header}</h3>
<p>{contentElement.data.bodytext -> f:format.html()}</p>
<h3>{contentElement.header}</h3>
<p>{contentElement.bodytext -> f:format.html()}</p>
</f:for>
</main>
<aside>
Expand Down
17 changes: 16 additions & 1 deletion Documentation/Functions/Stdwrap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ formattedDate
.locale
A locale other than the locale of the site language.

.. rubric:: Examples
.. rubric:: Example: Full German output from a date/time value

.. code-block:: typoscript
:caption: EXT:site_package/Configuration/TypoScript/setup.typoscript
Expand All @@ -925,6 +925,8 @@ formattedDate
will result in "Freitag, 17. März 2023 um 03:00:00 Nordamerikanische Westküsten-Sommerzeit".

.. rubric:: Example: Full French output from a relative date value

.. code-block:: typoscript
:caption: EXT:site_package/Configuration/TypoScript/setup.typoscript
Expand All @@ -937,6 +939,19 @@ formattedDate
will result in "dimanche 12 mars 2023 à 11:16:44 heure d’été du Pacifique".

.. rubric:: Example: Custom format from a timestamp

.. code-block:: typoscript
:caption: EXT:site_package/Configuration/TypoScript/setup.typoscript
lib.my_formatted_date = TEXT
lib.my_formatted_date {
value = 1679022000
formattedDate = Y-MM-dd'T'HH:mm:ssZ
}
will return the date in the ISO 8601 format: "2023-03-17T03:00:00+00:00"

.. note::
The timezone will be taken from the setting `date.timezone` in your
:file:`php.ini`.
Expand Down
2 changes: 2 additions & 0 deletions Documentation/TopLevelObjects/Other.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
Reserved top-level objects
==========================

.. contents:: List of the reserved top-level objects
:depth: 1

.. index:: Top-level objects; temp

Expand Down
6 changes: 6 additions & 0 deletions Documentation/TopLevelObjects/Page/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,12 @@ Open Graph meta tags:
2 = de_DE
}
}
article:modified_time {
attribute = property
if.isTrue.field = lastUpdated
field = lastUpdated
formattedDate = Y-MM-dd'T'HH:mm:ssZ
}
}
.. note::
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ docs: ## Generate projects docs (from "Documentation" directory)
test-docs: ## Test the documentation rendering
mkdir -p Documentation-GENERATED-temp

docker run --rm --pull always -v "$(shell pwd)":/project -t ghcr.io/typo3-documentation/render-guides:latest --config=Documentation --no-progress --fail-on-log --output-format=html
docker run --rm --pull always -v "$(shell pwd)":/project -t ghcr.io/typo3-documentation/render-guides:latest --config=Documentation --no-progress --minimal-test

.PHONY: generate
generate: codesnippets command-json ## Regenerate automatic code documentation
Expand Down

0 comments on commit 7a6fb93

Please sign in to comment.