-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Backport 12.4] [TASK] Add example: Display an Extbase plugin in a Fl…
…uid template (#1352) * [TASK] Add example: Display an Extbase plugin in a Fluid template Releases: main, 12.4 * [TASK] Add example: Display an Extbase plugin in a Fluid template Releases: main, 12.4 * [TASK] Add example: Display an Extbase plugin in a Fluid template Releases: main, 12.4 * Use $contentObject->data * Update Documentation/ContentObjects/Extbaseplugin/Index.rst --------- Co-authored-by: lina.wolf <lwolf@w-commerce.de> Co-authored-by: Lina Wolf <48202465+linawolf@users.noreply.github.com>
- Loading branch information
1 parent
de08264
commit 7dc3836
Showing
5 changed files
with
87 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
23 changes: 23 additions & 0 deletions
23
Documentation/ContentObjects/Extbaseplugin/_CodeSnippets/_MyController.php
This file contains 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,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(); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
Documentation/ContentObjects/Extbaseplugin/_CodeSnippets/_SomeTemplate.html
This file contains 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,5 @@ | ||
<!-- ... --> | ||
<f:cObject | ||
typoscriptObjectPath="lib.myPlugin" | ||
data="{someValue: page.pageRecord.someValue, someSetting: site.someSetting}" | ||
/> |
14 changes: 14 additions & 0 deletions
14
Documentation/ContentObjects/Extbaseplugin/_CodeSnippets/_configurePlugin.php
This file contains 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,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, | ||
); |
6 changes: 6 additions & 0 deletions
6
Documentation/ContentObjects/Extbaseplugin/_CodeSnippets/_libMyPlugin.typoscript
This file contains 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,6 @@ | ||
lib.myPlugin = EXTBASEPLUGIN | ||
lib.myPlugin { | ||
extensionName = MyExtension | ||
pluginName = MyPlugIn1 | ||
settings.detailPid = 42 | ||
} |