Include extbase plugin via typoscript, when having multiple plugins - typo3

In my extbase extension a have multiple plugins, in my ext_tables.php i have :
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
$_EXTKEY, 'plugin1', 'Services du CSPQ' );
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
$_EXTKEY, 'plugin2', 'plugin2' );
And in my ext_localconf.php :
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'TYPO3.' . $_EXTKEY, 'plugin1', array(
'Test' => 'list, show',
),
// non-cacheable actions
array('Test' => '',) );
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'TYPO3.' . $_EXTKEY,
'plugin2',
array(
'Test' => 'menu',
),
// non-cacheable actions
array(
'Test' => '',
) );
Now, how can i call the plugin2 by typoscript ?
for example, if i try to insert my plugin2 in lib.leftcontent, i tried this
lib.leftcontent < plugin.tx_plugin2
but nothing happens!

lib.leftcontent = USER
lib.leftcontent {
userFunc = tx_extbase_core_bootstrap->run
pluginName = Plugin2
extensionName = MyExtension
vendorName = Vendor
}

You first need to bootstrap your plugin as described in various article here on Stackoverflow, e.g. How do I bootstrap a plugin on TYPO3 CMS 6.0 with extbase?. Start with
lib.leftcontent = USER
lib.leftcontent {
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
...
and add all the other stuff as described in the linked article.

dont forget actions. Like for tx.fe_manager
lib.userview = USER
lib.userview {
userFunc = tx_extbase_core_bootstrap->run
extensionName = Femanager
pluginName = Pi1
vendorName = In2
#controller = Edit
#action = edit
switchableControllerActions {
Edit {
1 = edit
2 = update
3 = delete
4 = confirmUpdateRequest
}
}
}

Related

TYPO3 - TCA in ext_tables.php check and TCA/Overrides for v8

Updated ext_tables.php, TCA and TCA/Overrides for TYPO3 8LTS? I moved the TCA definitions from ext_tables.php to /TCA folder and the query in list view is working again:
ext_tables.php
<?php
if (!defined('TYPO3_MODE')) {die('Access denied.');}
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
$_EXTKEY,
'Code',
'Description'
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr('tx_code_domain_model_code', 'EXT:code/Resources/Private/Language/locallang_csh_tx_code_domain_model_code.xlf');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_code_domain_model_code');
Configuration/TCA/tx_code_domain_model_code.php
... // TCA defintions
Configuration/TCA/Overrides/tt_content.php
<?php
if (!defined('TYPO3_MODE')) {die('Access denied.');}
$_EXTKEY = 'code';
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
$_EXTKEY,
'Code',
'Description'
);
$extensionName = strtolower(\TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase($_EXTKEY));
$pluginName = strtolower('Code');
$pluginSignature = $extensionName.'_'.$pluginName;
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform';
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue($pluginSignature, 'FILE:EXT:'.$_EXTKEY . '/Configuration/FlexForms/flexform_code.xml');
Configuration/TCA/Overrides/tt_content.php
<?php
if (!defined('TYPO3_MODE')) {die('Access denied.');}
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile('code', 'Configuration/TypoScript', 'Description');
It's not compatible.
You should do your TCA definition of tx_code_domain_model_code in:
Configuration/TCA/tx_code_domain_model_code.php
The static template definition in:
Configuration/TCA/Overrides/sys_template.php
And your plugin and flexform definition in: Configuration/TCA/Overrides/tt_content.php
Be aware that the $_EXTKEY variable is not defined in those files so you have to type the extension key yourself.

TYPO3 Extension in Typoscript COA does not recognize Default Controller

I am trying to override a Marker within my Typoscript with content rendered by my custom created extension.
As far as I know It should work like this (Where MENU_PRODUKT_CATEGORIES) is my Marker:
MENU_PRODUKT_CATEGORIES = COA
MENU_PRODUKT_CATEGORIES {
10 = USER
10 {
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
extensionName = MoTimeProducts
pluginName = Products
vendorName = products
controller = Category
action = parentList
}
}
The extensionName and related configurations also seem correct to me. When I var_dump() my ext_localconf.php configuratin this is displayed:
My first Parameter where MoTimeProducts is my extensionName and products my vendorName. Is this correct?
MoTimeProducts.products
The second Parameter should be the pluginName and seems ok, too.
Products
This is how my complete ext_localconf configuration looks like:
<?php
if (!defined('TYPO3_MODE')) {
die('Access denied.');
}
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'MoTimeProducts.' . $_EXTKEY,
'Products',
array(
'Category' => 'list, parentList',
'Product' => 'list, show, filter, ajaxFilter, refList',
'Formular' => 'display'
),
// non-cacheable actions
array(
'Category' => '',
'Product' => 'ajaxFilter, list',
'Formular' => 'display'
)
);
My Controller and Action configuration seems fine also. Below my action within the CategoryController
/**
* action list
*
* #return void
*/
public function parentListAction() {
$this->view->assign('categories', $currentCategory = $this->categoryRepository->getHighestLevelCategories($GLOBALS['TSFE']->sys_language_uid));
}
I also have a flex form for the Backend configuration and inserting plugins could this also be a reason?
Thx for reading.
Oh wow it was
MENU_PRODUKT_CATEGORIES = COA
MENU_PRODUKT_CATEGORIES {
10 = USER
10 {
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
pluginName = Products
extensionName = Products
vendorName = MoTimeProducts
controller = Category
action = list
switchableControllerActions {
Category {
1 = parentList
}
}
}
}
Where vendorName with a combination of lowercased plugin name is the first paramater for the plugin configuration.
Edit: Turns out it is very bad practice to have the same name for the plugin/extension which can lead to confusion and errors. One should avoid doing it like I did at all cost!

SysFolder Icons with TYPO3 Icon-API

Till TYPO3 CMS 6.2 i've been using the following code in extTables.php to provide sysfolder icons:
$TCA['pages']['columns']['module']['config']['items'][] = array('Templates', 'templates', '/fileadmin/icons/application_side_list.png');
\TYPO3\CMS\Backend\Sprite\SpriteManager::addTcaTypeIcon('pages', 'contains-templates', '/fileadmin/icons/application_side_list.png');
As since 7.6 the code is obsolete and icons are provided by the Icon-API. Am I right? So my question is, if it's still possible to provide sysfolder icons to the backend using BitmapIconProvider, SvgIconProvider or the FontawesomeIconProvider?
Yes, this should work using the IconRegistry core class:
ext_localconf.php:
if (TYPO3_MODE === 'BE') {
/** #var \TYPO3\CMS\Core\Imaging\IconRegistry $iconRegistry */
$iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class);
$iconRegistry->registerIcon(
'apps-pagetree-folder-contains-templates',
\TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider::class,
['source' => 'EXT:myext/Resources/Public/Icons/application_side_list.png']
);
}
ext_tables.php:
if (TYPO3_MODE === 'BE') {
$GLOBALS['TCA']['pages']['columns']['module']['config']['items'][] = [
0 => 'Templates',
1 => 'templates',
2 => 'apps-pagetree-folder-contains-templates'
];
}
The TYPO3 extension must be modified to fit the needs of TYPO3 7.5 and higher. Replace myextkey by the extension key of your extension.
ext_localconf.php:
if (TYPO3_MODE == 'BE') {
$pageType = 'myext10'; // a maximum of 10 characters
$icons = array(
'apps-pagetree-folder-contains-' . $pageType => 'apps-pagetree-folder-contains-myextkey.svg'
);
/** #var \TYPO3\CMS\Core\Imaging\IconRegistry $iconRegistry */
$iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class);
foreach ($icons as $identifier => $filename) {
$iconRegistry->registerIcon(
$identifier,
$iconRegistry->detectIconProvider($filename),
array('source' => 'EXT:' . $_EXTKEY . '/Resources/Public/Icons/' . $filename)
);
}
}
Configuration/TCA/Overrides/pages.php:
<?php
if (!defined ('TYPO3_MODE')) {
die ('Access denied.');
}
// add folder icon
$pageType = 'myext10'; // a maximum of 10 characters
$iconReference = 'apps-pagetree-folder-contains-' . $pageType;
$addToModuleSelection = TRUE;
foreach ($GLOBALS['TCA']['pages']['columns']['module']['config']['items'] as $item) {
if ($item['1'] == $pageType) {
$addToModuleSelection = false;
break;
}
}
if ($addToModuleSelection) {
$GLOBALS['TCA']['pages']['ctrl']['typeicon_classes']['contains-' . $pageType] = $iconReference;
$GLOBALS['TCA']['pages']['columns']['module']['config']['items'][] = array(
0 => 'LLL:EXT:myextkey/locallang.xml:pageModule.plugin',
1 => $pageType,
2 => $iconReference
);
}
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerPageTSConfigFile(
$pageType,
'Configuration/TSconfig/Page/folder_tables.txt',
'EXT:myextkey :: Restrict pages to myextkey records'
);
locallang.xml:
<label index="pageModule.plugin">My Extension: Table names of my extension</label>
Resources/Public/Icons/apps-pagetree-folder-contains-myextkey.svg:
vector graphic image file for your extension tables
see https://github.com/TYPO3/TYPO3.Icons for working example SVG icons.
Configuration/TSconfig/Page/folder_tables.txt:
Insert the table names of your extension.
mod.web_list.allowedNewTables = tx_myextkey_tablename1, tx_myextkey_tablename2, tx_myextkey_tablename3

Assign plugin in typoscript

I have a plugin http://typo3.org/extensions/repository/view/aw_consume
I'm using it as a content element it's working
When I try to assign to a subpart in my typoscript nothing shows up
LOGOUT < plugin.tx_awconsume.widgets.menu
this plugin was created with the extension_builder extension installed on TYPO3 6.1.4
update 3
plugin.tx_awconsume {
view {
templateRootPath = {$plugin.tx_awconsume.view.templateRootPath}
partialRootPath = {$plugin.tx_awconsume.view.partialRootPath}
layoutRootPath = {$plugin.tx_awconsume.view.layoutRootPath}
}
persistence {
storagePid = {$plugin.tx_awconsume.persistence.storagePid}
}
features {
# uncomment the following line to enable the new Property Mapper.
# rewrittenPropertyMapper = 1
}
widgets {
menu = USER
menu {
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
pluginName = FeAwConsume
extensionName = AwConsume
controller = ConsumerItem
action = list
vendorName = Alexweb
}
}
}
ext_tables.php
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
$_EXTKEY,
'FeAwConsume',
'fe_awconsume'
);
ext_localconf.php
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'Alexweb.' . $_EXTKEY,
'FeAwConsume',
array(
'ConsumerItem' => 'list, show, new, create, delete',
),
// non-cacheable actions
array(
'ConsumerItem' => 'create, delete',
)
);
I have updated the code snippets according to #lorenz answer but im still getting no output
I have also pushed the latest version in TER 0.1.5
update 4
I did manage to get the expected output only after adding
plugin.tx_awconsume.widgets {
menu = USER
menu {
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
pluginName = FeAwConsume
extensionName = AwConsume
controller = ConsumerItem
action = list
vendorName = Alexweb
}
}
To the template typoscript file from \typo3conf\ext\aw_consume\Configuration\TypoScript\setup.txt
Where it was originally placed by the extension_builder extension however I got a feeling that this is not really a good idea
If you have a close look at your ext_localconf.php, you will notice that you use a vendor name. The vendor name should start with Uppercase so your ext_localconf.php should read:
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'Alexweb.' . $_EXTKEY,
'MyPlugin',
array(
'ConsumerItem' => 'list, show, new, create, delete',
),
array(
'ConsumerItem' => 'create, delete',
)
);
Your ext_tables.php should look like this:
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
$_EXTKEY,
'MyPlugin',
'Speaking name of my plugin'
);
The TypoScript object of your plugin should include the vendor name (the property is vendorName, not vendor):
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
pluginName = MyPlugin
extensionName = AwConsume
vendorName = Alexweb
controller = ConsumerItem
action = list
Keep in mind that your classes also must include the vendor name/make use of the correct namespace:
namespace Alexweb\AwConsume\Controller;
class ConsumerItemController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
}
Then you should be fine.
The extension name is the UpperCamelCase variant of your extension key, so if your extension key is "aw_consume", your extension name is "AwConsume". This name is used in the classes
The plugin name is the name of a particular plugin that is part of your extension. Since there can be many plugins in an extension, you should choose a fitting name for it. The plugin name should also be UpperCamelCase. You can have multiple plugins for the same controllers, therefore the plugin doesn't have to be named like the controller.
See also http://forge.typo3.org/projects/typo3v4-mvc/wiki/FAQ#What-is-the-Extension-Name

TYPO3 4.7.2 include extbase plugin via typoscript

I wrote an extension and the implementation of the Plugin via backend does everything correctly.
But when I try to implement my extension via typoscript I got this error everytime:
Oops, an error occurred!
The default controller can not be determined. Please check for
Tx_Extbase_Utility_Extension::configurePlugin() in your
ext_localconf.php.
and I don't know why.. I have tried different implementations (per tx_extbase_core_bootstrap->run or tx_extbase_dispatcher->dispatch and with additional information and without) and the current typoscript looks like this:
plugin.tx_graphichmenu {
settings {
menuUid = 1
}
}
lib.tx_graphichmenu = USER
lib.tx_graphichmenu {
userFunc = tx_extbase_core_bootstrap->run
extensionName = Graphichmenu
pluginName = Graphicmenu
controller = MenuController
action = showAction
}
temp.mainTemplate.subparts.stickyfooter < lib.tx_graphichmenu
i double- and triple-checked everything and i found not a single fault...
tried it without the "action" and "controller" part and nothing changed
my configurePlugin part in the ext_localconf.php looks like this:
Tx_Extbase_Utility_Extension::configurePlugin(
$_EXTKEY,
'Graphicmenu',
array(
'Menu' => 'show',
),
// non-cacheable actions
array(
'Menu' => '',
)
);
The "show" action got no parameters. in there I load the ts settings from where I take the Uid of the object to display
PS: after every change i have cleared the cache and deleted the "temp_CACHED_..." files in typo3conf
You need to modify your bootstrap, there's a general syntax:
lib.foo = USER
lib.foo {
userFunc = tx_extbase_core_bootstrap->run
extensionName = YourExtension
pluginName = YourPlugin
vendorName = YourVendor
switchableControllerActions {
Standard {
1 = action2
2 = action3
}
}
}
Note: CamelCase in extensionName value is important! (Thanks to Kai for confirmation) so if extkey is: kai_some_extension it has to be written as KaiSomeExtension
So in your case it should be something like:
lib.foo = USER
lib.foo {
userFunc = tx_extbase_core_bootstrap->run
extensionName = GraphicHmenu
pluginName = Graphicmenu
switchableControllerActions {
Menu {
1 = show
}
}
}