TYPO3 4.7.2 include extbase plugin via typoscript - plugins

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
}
}
}

Related

TYPO3 extbase, the php based views do not work when migrating from 9 to 10 version

I have developed a custom TYPO3 extbase extension that was perfectly worked on 8 and 9 version of TYPO3.
Recently I upgraded my installation to TYPO3 10 version but the php based views of my TYPO3 extbase extension do not work anymore.
The error that is displayed is:
Sorry, the requested view was not found.
The technical reason is: No template was found. View could not be resolved for action "getIcal" in class "Luc\Lucevents2\Controller\EventController"
I have read the instructions in the page
https://docs.typo3.org/m/typo3/book-extbasefluid/10.4/en-us/8-Fluid/9-using-php-based-views.html, but there is nothing different from what I have already done in my extension.
So, I am very confused because there is no explanation why the code stopped to work, the above link doesn't include any instructions about deprecated code or possible changes after migration!!
Could you give me any help?
Thank you very much!
George
I hit this problem today. The documentation for "php based views" seems to be outdated.Below is a description of my setup and the solution for TYPO3 10
What I had:
My situation was that I had a Controller with a showAction() action method.
In typoscript, I had setup a new format through the type parameter. Something like
rss = PAGE
rss {
typeNum = 58978
10 =< tt_content.list.20.skevents_eventfeeds
}
For this type (parameter type=58978) I had setup a class named View\EventFeeds\ShowRss with a render() method.
TYPO3 automatically resolved this class based on the type (rss) and the action name (show). This does not work any more.
What solves this issue:
in order for TYPO3 to find the correct class with the render method, it is sufficient to set the defaultViewObjectName variable of the Controller to the correct class name for the specific action. This can be done in the controller with the following new method
public function initializeShowAction()
{
$this->defaultViewObjectName = \Skar\Skevents\View\EventFeeds\ShowRss::class;
}
So now, before calling the showAction method, defaultViewObjectName is set to my ShowRss class which produces the output.
Please note that my ShowRss class extends \TYPO3\CMS\Extbase\Mvc\View\AbstractView . According to https://docs.typo3.org/m/typo3/book-extbasefluid/master/en-us/8-Fluid/9-using-php-based-views.html this is deprecated in TYPO3 11 and will have to change for TYPO3 12
the static template is already included and all the other operations of the extension are working very well except the php based views. The ext_localconf.php looks as follows: <?php
defined('TYPO3_MODE') || die('Access denied.');
$boot = function () {
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'Luc.Lucevents2',
'Luceventsdisplay',
[
'Event' => 'list, show, delete, edit, monthview, test, ajax, deleteConfirm, showRss, getIcal, addForm, add, editForm, importeventtoforum',
'Channel' => 'list, show',
'Tag' => 'filter, show'
],
// non-cacheable actions
[
'Event' => 'list, show, delete, edit, monthview, test, ajax, deleteConfirm, showRss, getIcal, addForm, add, editForm, importeventtoforum',
'Channel' => 'list, show',
'Tag' => 'filter, show'
]
);
};
$boot();
unset($boot);
The action is registered in EventController.php and looks as follows:
/**
* action geticalaction
*
* #param \Luc\Lucevents2\Domain\Model\Event $event
* #return void
*/
public function getIcalAction(\Luc\Lucevents2\Domain\Model\Event $event = NULL)
{
$base_url = $this->request->getBaseUri();
$channel=$this->settings['channel_for_simple_users'];
if($this->request->hasArgument('duration'))
{
if ($this->request->getArgument('duration')=='6month') {
$duration=$this->request->getArgument('duration');
}
else
{
$duration='month';
}
$events = $this->eventRepository->get_events_for_rss_and_ical($duration,$channel);
$eventsarray= array();
foreach ($events as $obj){
$this->uriBuilder->setCreateAbsoluteUri(true);
$uri = $this->controllerContext->getUriBuilder()
->setUseCacheHash(false)
->uriFor('show', array("event" => $obj->getUid()));
$eventsarray[] = array($obj->getTitle(), $obj->getDescription(), $obj->getStartdatetime(),$obj->getEnddatetime(), $obj->getBuildingid(), $obj->getRoomid(), $obj->getPlace(), $obj->getCrdate(), $uri, $obj->getUid());
}
$this->view->assign('events', $eventsarray);
$this->view->assign('baseurl', $base_url);
}
else
{
$this->uriBuilder->setCreateAbsoluteUri(true);
$uri = $this->controllerContext->getUriBuilder()
->setUseCacheHash(false)
->uriFor('show', array("event" => $event->getUid()));
$this->view->assign('event', $event);
$this->view->assign('baseurl', $base_url);
$this->view->assign('uri', $uri);
}
}
Thank you very much!

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!

TYPO3-6.2 Extbase custom content type -> invalid value

I made an extbase Extension for custom content elements. Since this is my first extension I started with a simple "hello_world_ce". This are my files:
ext_tables.php
<?php
$TCA['tt_content']['types']['hello_world_ce']['showitem'] = '--palette--;LLL:EXT:hello_world/Resources/Private/Language/locallang_mod.xlf:content_element.hello_world.general;general, --palette--;LLL:EXT:hello_world/Resources/Private/Language/locallang_mod.xlf:content_element.hello_world.header;header';
ext_localconf.php
<?php
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:'.$_EXTKEY.'/Configuration/TypoScript/ModWizards.ts">');
ModWizards.ts
mod.wizards {
newContentElement {
wizardItems {
hello_world {
header = LLL:EXT:hello_world/Resources/Private/Language/locallang_mod.xlf:content_tab_header
elements {
hello_world_ce {
icon = gfx/c_wiz/regular_header.gif
title = LLL:EXT:hello_world/Resources/Private/Language/locallang_mod.xlf:content_element.hello_world
description = LLL:EXT:hello_world/Resources/Private/Language/locallang_mod.xlf:content_element.hello_world.description
tt_content_defValues {
CType = hello_world_ce
}
}
}
}
show = *
}
}
}
In the TYPO3 Backend I see my content element and can add it to a page but the dropdown menu for the content type says INVALID VALUE ("hello_world_ce")
What am I missing?
EDIT: I found the missing part. I needed to add my content type to the CType array
ext_tables.php
$backupCTypeItems = $GLOBALS['TCA']['tt_content']['columns']['CType']['config']['items'];
$GLOBALS['TCA']['tt_content']['columns']['CType']['config']['items'] = array(
array(
'LLL:EXT:'.$_EXTKEY.'/Resources/Private/Language/locallang_mod.xlf:content_tab_header',
'--div--'
),
array(
'LLL:EXT:'.$_EXTKEY.'/Resources/Private/Language/locallang_mod.xlf:content_element.hello_world',
'hello_world_ce',
'i/tt_content_header.gif'
)
);
foreach($backupCTypeItems as $key => $value){
$GLOBALS['TCA']['tt_content']['columns']['CType']['config']['items'][] = $value;
}
The question was edited, but I think there is a better way to achieve the solution.
Only to be clear about the problem:
The content element hello_world_ce was not added to the "types" dropdown by adding a new content element.
The hint in the question is correct it was not defined for the CType field.
But instead of manipulating the array you could use a core function:
// Adds the content element to the "Type" dropdown
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(
array(
'LLL:EXT:your_extension_key/Resources/Private/Language/locallang_mod.xlf:content_element.hello_world',
'hello_world_ce',
'i/tt_content_header.gif'
),
'CType',
'your_extension_key'
);
Here is a very good example of how to add your own content element in the version TYPO3 7.6.
Note: This function is accessible in TYPO3 6.2 as well.

Include extbase plugin via typoscript, when having multiple plugins

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
}
}
}

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