How to configure more than 1 plugin in one extension in typo3 - typo3

ext_localconf.php code
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'ABC',
'Soapi',
[
oneController::class => 'fetchTopUser',
],
// non-cacheable actions
[
oneController::class => 'fetchTopUser',
]
);
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'ABC',
'CategoryList',
[
secondController::class => 'list',
],
// non-cacheable actions
[
secondController::class => 'list',
]
);
Throw error
(1/1) #1316104317 TYPO3\CMS\Extbase\Mvc\Exception
The default controller for extension "ABC" and plugin "CategoryList" can not be determined. Please check for TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin() in your ext_localconf.php.

Class names in TYPO3 are in UpperCamelCasing and try to put the complete class names with their namespaces.
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'ABC',
'Soapi',
[
\Vendor\ExtensionName\Controller\OneController::class => 'fetchTopUser',
],
// non-cacheable actions
[
\Vendor\ExtensionName\Controller\OneController::class => 'fetchTopUser',
]
);
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'ABC',
'CategoryList',
[
\Vendor\ExtensionName\Controller\SecondController::class => 'list',
],
// non-cacheable actions
[
\Vendor\ExtensionName\Controller\SecondController::class => 'list',
]
);
~

Hi Your Code looks Correct (apart from the missing Namespaces to the Classes.
i would suspect that one of two thing might be happening here:
the namespace does not resolve. please use fully Qualified namespaces. as suggested by Mohsin Khan
or you forgot to register the second plugin in your_extension/Configuration/TCA/Overrides/tt_content.php (\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin)

Related

TYPO3 10.4.20 and b13/containers

I have installed b13/container extension on a typo3 10.4.20 composer installation. I want to replace grid elements with containers. Based on the documentation you can register a new Content Element by making a PHP call to TCA Registry. But after following all the steps it doesn't add a “Container” tab to the New Content Element Wizard.
Here is my tt_content.php
<?php
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTcaSelectItem(
'tt_content',
'CType',
[
'Great',
'examples_newcontentelement',
'content-text',
],
'textmedia',
'after'
);
// Configure the default backend fields for the content element
$GLOBALS['TCA']['tt_content']['types']['eftmg_categorizedpages'] = [
'showitem' => '
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
--palette--;;general,
--palette--;;headers,
selected_categories,
category_field,
--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.appearance,
--palette--;;frames,
--palette--;;appearanceLinks,
--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.accessibility,
--palette--;;menu_accessibility,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language,
--palette--;;language,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,
--palette--;;hidden,
--palette--;;access,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:categories,
categories,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:notes,
rowDescription,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:extended,
',
'columnsOverrides' => [
'selected_categories' => [
'config' => [
'minitems' => 1,
]
],
'category_field' => [
'config' => [
'itemsProcConfig' => [
'table' => 'pages'
]
]
]
]
];
// Configure containers
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\B13\Container\Tca\Registry::class)->configureContainer(
(
new \B13\Container\Tca\ContainerConfiguration(
'b13-3col-container', // CType
'3 Columns', // label
'Some Description of the Container', // description
[
[
['name' => 'left', 'colPos' => 200],
['name' => 'middle', 'colPos' => 201],
['name' => 'right', 'colPos' => 202]
]
] // grid configuration
)
)
->setIcon('EXT:tourismus/Resources/Public/Icons/b13-3col-container.svg')
);
Maybe I have to downgrade my version to TYPO3 10.4.18?
You may take a look at https://github.com/b13/container-example which provides an example container with 2-columns using TCA to add it into the NewContentElement-Wizard.
I'm also running on 10.4.20 and it works fine, might be your TCA for the container.. didn't test it but you should be good taking a look into the upper mentioned example.

TYPO3 V10 - EXT:news custom type and persistence mapping

i'm trying to upgrade a extension for TYPO3 10.4 which add a custom type to tx_news (Doc).
I did the migration based on this example: Breaking: #87623
Classes/Controller/NewsController.php
return [
\Xyz\Extendnews\Domain\Model\Team::class => [
'tableName' => 'tx_news_domain_model_news',
'recordType' => 3,
],
But wenn I debug the entry in the Fluid-Template the default model is still used.
Did I miss something or does someone have a working example.
Thanks for any help.
Update:
I want to create a new type, explained in Georg Ringer´s manual
I have created a small extension, everything works fine with TYPO3 9.5, but not with TYPO3 10.4.
DEMO EXT
With TYPO3 10.4 the prototype is not MxnTeam\Domain\Model\Team
Update 29.06.2020:
tobenschmidt from the TYPO3 Slack channel ( post ) help me out.
return [
\Mexan\MxnTeam\Domain\Model\Team::class => [
'tableName' => 'tx_news_domain_model_news',
'recordType' => \Mexan\MxnTeam\Domain\Model\Team::class,
],
\Mexan\MxnTeam\Domain\Model\Client::class => [
'tableName' => 'tx_news_domain_model_news',
'recordType' => \Mexan\MxnTeam\Domain\Model\Client::class,
],
\GeorgRinger\News\Domain\Model\News::class => [
'tableName' => 'tx_news_domain_model_news',
//'recordType' => 0,
'subclasses' => [
\Mexan\MxnTeam\Domain\Model\Team::class,
\Mexan\MxnTeam\Domain\Model\Client::class,
]
],
];
This works fine, even with 2 custom types.
but unfortunately the default news are no longer loaded
but if I add recordType => 0, then only normal news and my custom types are visible, but not the type 1 and 2 (Internal and external)
I updated the extension:
mxn_team
is there a way to prevent this?
This works for me...
Implement your news type as described in https://docs.typo3.org/p/georgringer/news/8.5/en-us/DeveloperManual/ExtendNews/AddCustomType/Index.html
but instead of the described TypoScript add following file to your extension:
ext_name/Configuration/Extbase/Persistence/Classes.php
<?php
return [
\GeorgRinger\News\Domain\Model\News::class => [
'subclasses' => [
3 => \Vendor\ExtName\Domain\Model\MyCustomNewsType::class
]
],
Vendor\ExtName\Domain\Model\MyCustomNewsType::class => [
'tableName' => 'tx_news_domain_model_news',
'recordType' => 3,
],
];
The way using TypoScript (config.tx_extbase.persistence.classes) was removed in TYPO3 v10
You write "Classes/Controller/NewsController.php" but you have to create a file here
extendnews/Configuration/Extbase/Persistence/Classes.php
and put your code in there. After that, do not forget to clear all cache.
Complete file "Classes.php" should look like
<?php
declare(strict_types = 1);
return [
\Xyz\Extendnews\Domain\Model\Team::class => [
'tableName' => 'tx_news_domain_model_news',
'recordType' => \Xyz\Extendnews\Domain\Model\Team::class,
],
To use the new model follow Georg Ringer´s manual
manual on typo3.org
And a working example here

Backend module: Link to another backend module in TYPO3 9

Let's say I have to different extensions with two different backend modules. Registered like:
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule(
'Vendor.ext',
'ext',
'controller1',
'',
[
'Controller1' => 'any1',
],
[
'access' => 'user,group',
'icon' => '...',
'labels' => '...',
]
);
And in the second extension also like:
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule(
'Vendor.ext2',
'ext2',
'controller2',
'',
[
'Controller2' => 'any2',
],
[
'access' => 'user,group',
'icon' => '...',
'labels' => '...',
]
);
How can I build a link from ext1 in the module to ext2?
What did I tried before in FLUID was:
<f:link.action action="any2" controller="Controller2" extensionName="ext">click me</f:link.action>
or
<f:be.link route="/ext/Ext2Controller2/">click me</f:be.link> (by copying the route that's available via GET parameter)
No luck yet - any ideas? Or how to get the correct route if be.link would be the correct function?
Finally I found the reason.
It's simply possible to use the existing viewhelper like <f:be.link route="lux_LuxLeads">click me</f:be.link>
But the route must be the key and not the path. The key can be picked in the backend module configuration and backendroutes

How to add custom wizards in TYPO3 9 TCA?

Related to How to add custom wizards in typo3 7 TCA? how can costum wizards in TYPO3 9 be implemented? I've added my entry to the Routes.php
return [
'tx_csseo_preview' => [
'path' => '/wizard/tx_csseo/preview',
'target' => \Clickstorm\CsSeo\UserFunc\PreviewWizard::class . '::render'
],
'tx_csseo_permalink' => [
'path' => '/wizard/tx_csseo/permalink',
'target' => \Clickstorm\CsSeo\UserFunc\PermalinkWizard::class . '::render'
]
];
How can I add them now to my TCA field?
'tx_csseo_title' => [
'label' => 'LLL:EXT:cs_seo/Resources/Private/Language/locallang_db.xlf:pages.tx_csseo_title',
'exclude' => 1,
'config' => [
'type' => 'input',
'max' => $extConf['maxTitle'],
'eval' => 'trim',
'fieldWizard' => [
'tx_csseo_preview' => [
'disabled' => false,
]
]
]
],
This does not work. What do I miss? Thanks in advance.
Related to your kind of wizard the registration-process is different and extensive explained here. You can leave the entries in Routes.php away (perhaps even the whole file if nothing else is inside).
Registration is done in ext_localconf.php:
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1485351217] = [
'nodeName' => 'importDataControl',
'priority' => 30,
'class' => \T3G\Something\FormEngine\FieldControl\ImportDataControl::class
];
Then reference the new wizard in TCA:
'somefield' => [
'label' => $langFile . ':pages.somefield',
'config' => [
'type' => 'input',
'eval' => 'int, unique',
'fieldControl' => [
'importControl' => [
'renderType' => 'importDataControl'
]
]
]
],
Then finally the class with the "magic"
declare(strict_types=1);
namespace T3G\Something\FormEngine\FieldControl;
use TYPO3\CMS\Backend\Form\AbstractNode;
class ImportDataControl extends AbstractNode
{
public function render()
{
$result = [
'iconIdentifier' => 'import-data',
'title' => $GLOBALS['LANG']->sL('LLL:EXT:something/Resources/Private/Language/locallang_db.xlf:pages.importData'),
'linkAttributes' => [
'class' => 'importData ',
'data-id' => $this->data['databaseRow']['somefield']
],
'requireJsModules' => ['TYPO3/CMS/Something/ImportData'],
];
return $result;
}
}
In the linked example there is still an Ajax Route with corresponding files, including a special defined route, but that's not required to get the basic wizard shown.
Concerning the registration in ext_localconf.php there is above the number 1485351217 as array-key shown. For an own registered node just calculate once the current time as unix-timestamp and enter that instead. So it's unique and can't be mistaken with other definitions of any registered nodes.
In contrast to the linked example I used slightly different descriptions, so I call the process in ext_localconf.php registering, and the inclusion in TCA referencing. Perhaps this small difference makes it a bit more clear.
Icons
Concerning Icons there is still a difference to earlier TYPO3 versions, they have to be registered now too and in TCA they are only referenced too by the registered name. Here in the TCA-file is no icon referenced but the class below makes usage of it. Here is an example how an icon has to be registered in ext_tables.php:
$systemIconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class);
$systemIconRegistry->registerIcon(
'imagemapwizard_link_edit',
\TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider::class,
[
'source' => 'EXT:imagemap_wizard/Resources/Public/Icons/link_edit.png'
]
);
The new icon registry is implemented starting with TYPO3 version 7.5
Don't forget the configuration in YourExtension/Configuration/Backend/AjaxRoutes.php. See the documentation

Yii2 advanced change views default path (theming)

I would like for my application to automatically change template
so i created this structure frontend/web/themes/myTheme
following http://www.yiiframework.com/doc-2.0/guide-output-theming.html i added this code in frontend/config/main.php
'components' => [
'view' => [
'theme' => [
'basePath' => '#app/themes/myTheme',
'baseUrl' => '#web/themes/myTheme',
'pathMap' => [
'#app/views' => '#app/themes/myTheme',
],
],
],
],
however i kept getting the error that " /var/www/html/myProject/app/frontend/views/site/index.php" The view file does not exist???
i also tried to put this function inside the controller based on How to change default view path in Yii2?
public function getViewPath()
{
return Yii::getAlias('#web/themes/myTheme/site');
}
so my question is:
1. how can I change the views default path?
2. how can i do it automatically since i can not change the common/config/main.php settings during a session?
site controller
class SiteController extends Controller
{
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'actions' => ['index'],
'allow' => true,
'roles' => ['?'],
],
[
'actions' => ['index'],
'allow' => true,
'roles' => ['#'],
],
],
],
];
}
public function actions()
{
return [
'error' => [
'class' => 'yii\web\ErrorAction',
],
'captcha' => [
'class' => 'yii\captcha\CaptchaAction',
'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
],
];
}
/**
* Displays homepage.
*
* #return mixed
*/
public function actionIndex()
{
$searchModel = new ProductSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
}
I think you are configuring the wrong file.Don't configure themes in the common/config
Try this:
in frontend/config/main.php
'components' => [
'view' => [
'theme' => [
'pathMap' => [
'#frontend/views'=>'#frontend/themes/myTheme',
],
],
],
],
if you need to configure the backend then in the backend/config/main.php
'components' => [
'view' => [
'theme' => [
'pathMap' => [
'#backend/views'=>'#backend/themes/myTheme',
],
],
],
],
The common folder is has to contain the files that are required by both
frontend and backend.
Hope this helps.
First question:
I think than you have a common mistake in yii when used advanced app: the alias #app references root directory of frontend, backend, or common depending on where you access it from View documentation here.
You would used the solution proposed by ovicko.
Second question:
You can change the theme configuration dynamically in controller through view object:
$this->view->theme->pathMap =['#app/views' => '#app/themes/myTheme/',];
EDIT
According to Documentation:
Theming is a way to replace a set of views with another without the need of touching the original view rendering code.
What means that the original view file must exist and theming simply replace it in during rendering. So you must create a file in /var/www/html/myProject/app/frontend/views/site/index.php (a empty file is valid) in order to theming works.
This sounds quite ridiculous, I Know, but it works.
But I think that is much better and easier the use of differents layouts, again, to change dinamically the layout in your controller:
$this->layout = 'route/yourlayout';