Typo3 9.5 : Multifunctional Extension - typo3-9.x

Is it possible to register more than one controller in one Extension oder more than one action in one controller by any chance?
If not, why is this an array?
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'T395',
'T395Base',
[
'item' => 'list'
],
// non-cacheable actions
[
'item' => ''
]
);
I think there is something I didn't get after reading the first extension Guide on Typo3 official pages and supportpages for controller, flow and view. Are there any examples for having multifunctional controllers or multicontroller extensions? Maybe I'm searching with wrong keywords?

At least you can have multiple actions, which can be found in multiple extensions.
If you want it very basic: use the EXT:extension_builder and build a small data model where you can add the actions: list, show, edit, delete, create and inspect the resulting code.

Thank you for your answer. After some more trial and error, I found that there can be several controller in one extension - you have to register everyone as an own plugin in the extension in ext_localconf.php and tt_content.php.

Related

TYPO3 error «action is not allowed by this plugin»

I'm trying to make an Ajax-call to my Controller.
I placed a hidden link in my form like this:
<f:link.action action="ajaxCheckEmailExistsFE" controller="Profiles" class="hidden" id="checkEmailExistsAjaxLink"></f:link.action>
In my Javascript, I extract the href from this link:
var target = $('#checkEmailExistsAjaxLink').attr('href');
And then send my request with jQuery's $.post method.
When the link is called, I get the infamous error
The action \"ajaxCheckEmailExistsFE\" (controller \"Profiles\") is not allowed by this plugin. Please check TYPO3\\CMS\\Extbase\\Utility\\ExtensionUtility::configurePlugin() in your ext_localconf.php
But the action is clearly set in ext_localconf.php!
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'MyVendor.MyExt',
'MyPlugin',
[
'Profiles' => 'editFE, showFE, updateFE, ajaxCheckEmailExistsFE'
],
// non-cacheable actions
[
'Profiles' => 'editFE, showFE, updateFE, ajaxCheckEmailExistsFE'
]
);
The same workflow works perfectly in BE-Mode.
I had the same problem with the updateFE-Action. When the form was submitted, I got the same error like above. I had to add it to the switchable-controller-actions in my flexform (-> <numIndex index="1">Profiles->editFE;Profiles->updateFE</numIndex>) - which is equally odd.
Why is this happening???
This is TYPO3 9.5
[Edit] For the time being, I ended up adding the action to the switchable-controller-actions just like I did for the updateFE-Action.
This is VERY cumbersome, though, since I have to set the plugin-action on the page every time I add a new action.
If anybody has a better solution, I'd be extremely thankful!
Indeed, this IS cumbersome, but it is also the only working way for switchable actions in TYPO3 extbase controllers. This check is intended to ensure that specific actions are only callable when you are in the "correct" plugin, as you may have several plugins inside one extension, which then may utilize different actions. So in the end, this feature prevents one plugin to call an action which should only be callable inside another plugin of the same extension.
If you do not need the editor to switch action sets of your plugins though, you can remove this config part from your flexform, which will solve the need to edit this for new actions.
As a famous example, take a look into the config of the news extension. There is one plugin which allows list+detail view, and different ones for just list or just detail view. So as an admin, you have to choice of structuring your website (routing and templates) for different news setups.
Even in the TYPO3 community, there are voices to get rid of this feature, so maybe it will be solved in future versions.

How to Call Captcha Action in Yii Framework to create image

I have app in Yii framework and i want to add Captcha in it and i don't want use Yii defaults .. long story short , i found one which works fine without framework so i created an action and i put image creation function in it, but when i call that action i get broken link.
yii/mycontroller/createcaptchaimage
What is wrong in my solution ?
the captha code is in this link .
There is nothing wrong in your solution. You Obviously have some Routing issue . Did you checked your main.php or .htaccess ?
I found this captcha-extended extension more beautiful than CCapthcha. Here is the link:
http://www.yiiframework.com/extension/captcha-extended/
You call it just like normal CCaptcha widget from any view/layout file:
<?php $this->widget('CCaptcha'); ?>
This will look for controller action "captcha" which is defined in array of actions.
public function actions(){
return array(
'captcha'=>array(
'class'=>'CaptchaExtendedAction',
// if needed, modify settings
'mode'=>CaptchaExtendedAction::MODE_MATH,
),
);
}

How to access a view once you have generated it with GII (via YII)?

I've managed to create several forms using YII and GII, but I'll be honest, I don't understand it perfectly. If anyone can explain this to me, I'd really appreciate it.
Basically, I create accessed the form creator here:
index.php/gii/form
I then filled in:
Model Class: Product
View Name: createProduct
View Path: application.views (default)
Scenario: createProduct
When I generate the code, I end up with a file called "createProduct.php" located at:
protected\views\createProduct.php
How do I access this view? I figured something like this should work: http://mysite.com/createProduct (but it doesn't)
What do I do if I want to change the link to be: http://mysite.com/admin/products/createProduct
Any help would be greatly appreciated!
Gii tells you to modify your controller. It shows the code you should insert after generating process. When you do this you'll be able to access your form by http://yoursite.com/controller/action
You can manage your urls using UrlManager. Look this article in docs - http://www.yiiframework.com/doc/guide/1.1/en/topics.url

Rails 3, menu in layout

i have some controllers, i want to put categories names into layout, like menu, what i could see in all pages. Is there a easy sollution to do this?
Use : render :layout => 'yourcustomlayout'
in your specific action.
Use general layout for whole application. You can specify one layout for an application and even override it wherever required.
See here for details and near exact example for your case.

yii access control filter rules in controllers

When writing rules for access control in yii controllers, possible parameters to be set
for a rule are 'action' - sets to which action the rule applies; 'users', 'roles', etc.
Now, both the yii guide (pdf) and reference (I have chm file) say that it's possible to set,
also, a controller id for the controller the rule should apply to.
Now, if we are already putting these rules in a controller class/file, how would we be able
to put some other controller (other than the current one) as the parameter here, meaning
how would some other controller whose id we mention here - how would it know there is a rule that applies to it, since it's written in a completely other controller class/file?
How would the controller be aware of a rule that mentions it, if it's written outside of it,
in a completely different controller?
You can hook into CWebApplication::beforeControllerAction() to apply filters before the controller even gets the request.
~thinkt4nk
One case where you could use this is if you set some rules in a base controller and extend it. Maybe you have some admin-only controllers, then you can save a little code by just adding these rules into a base Controller that all other controllers extend?
Also, this might be used if you are attaching Behaviors to the controller?
I've never used this rule though, I'm just hypothesizing. :)
Dear Friend,
Yii give us 3 type of user groups
(*)- for All(guest),
(#)- for registered,
(admin)- for super user we can use it from Controller / public function accessRules()
add if you wanna custom user rights than u can also use
1)ttp://www.yiiframework.com/extension/yii-user-management/
and u can also use "Yii-Rights" which is best for customization
2)http://www.yiiframework.com/forum/index.php?/topic/10556-extension-rights/page_p_51869#entry51869
Regard,
Bhavik Chauhan