Actions
Bug #104908
openDocumentation to add a custom fluid template is wrong
Status:
New
Priority:
Should have
Assignee:
-
Category:
Documentation
Target version:
-
Start date:
2024-09-11
Due date:
% Done:
0%
Estimated time:
TYPO3 Version:
11
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:
Description
The recommended TypoScript configuration does not help to override the fluid templates like described in [[https://docs.typo3.org/c/typo3/cms-dashboard/11.5/en-us/Configuration/WidgetTemplate.html#adjust-template-of-widget]] in TYPO3 v11.5. I added the TypoScript configuration via
<?php
defined('TYPO3') or die();
call_user_func(function()
{
$extensionKey = 'mysitepackage';
/**
* Default TypoScript for My SitePackage
*/
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile(
$extensionKey,
'Configuration/TypoScript',
'My SitePackage'
);
});
and in the mysitepackage/Configuration/TypoScript/setup.typoscript.
module.tx_dashboard { view { templateRootPaths { 110 = EXT:my_site_package/Resources/Private/Templates/Dashboard/Widget/ } } }
The file my-site-package/Resources/Private/Templates/Dashboard/Widget/RssWidget.html is not leaded. I cleared the cache in the Backend Module. I tried any method to include this TypoScript method, but I failed.
( [[https://docs.typo3.org/m/typo3/reference-typoscript/11.5/en-us/UsingSetting/AddTypoScriptWithExtensions.html#extdev-add-typoscript]] , [[https://docs.typo3.org/m/typo3/reference-typoscript/11.5/en-us/TopLevelObjects/Module.html#tlo-module]] )
The paths (templateRootPaths, layoutRootPaths) were visible in the TypoScript Object Browser, but the modified html files (template RssWidget.html and layout Widget.html) had no effect.
Instead, one has to override the Factory class from TYPO3\CMS\Dashboard\Views\Factory.php. It is essential to write the own package name into the line
$view->getRenderingContext()->getTemplatePaths()->fillDefaultsByPackageName('mysitepackage');.
The other code can be used like it was.
Additionally, some modifications has to be done in the respective Services.yaml. We need to define a custom view , for example "dashboard.views.mywidget"
dashboard.views.mywidget:
class: 'TYPO3\CMS\Fluid\View\StandaloneView'
public: true
factory: [ 'MyVendor\MySitePackage\Views\Factory', 'widgetTemplate' ]
And in the respective widget (in our case the RSS Widget) we had to set the new custom view "dashboard.views.mywidget"
dashboard.widget.example-rss-feed:
class: 'MyVendor\MySitePackage\Widgets\RssWidget'
arguments:
$view: '@dashboard.views.mywidget'
$buttonProvider: '@dashboard.buttons.example-rss-feed'
$cache: '@cache.dashboard.rss'
$options:
feedUrl: 'https://www.example.de/rss.xml'
refreshAvailable: true
lifeTime: 43200
limit: 6
tags:
-
name: dashboard.widget
identifier: 'example-rss-feed'
groupNames: 'example'
title: 'My Example News'
description: 'Add a list of news items from example webpage'
iconIdentifier: 'content-widget-rss'
height: 'large'
width: 'large'
This caused that we had to provide all used html files in our extension, but at least we were now able to customize them to our needs.
No data to display
Actions