Is there any way to create AJAX calls in Extbase extension without using of page typeNum?
相关问题
- Access fluidpage configuration in template
- How to install an extension to TYPO3 using compose
- TYPO3 Ajax Page Configuration
- Extbase query to compare two fields in same table
- TYPO3: Set more than one storage pid for one exten
相关文章
- How to get TYPO3 settings in the utility files?
- “Controller does not exist. Reflection failed.” TY
- How can i have different translations for action c
- Typo3 LTS9 Routing: ReUse config.YAML
- TYPO3 Extbase: How to sort child objects
- How to add custom wizards in typo3 7 TCA?
- Typo3 eID, how to access config
- How to access properties of a FileReference Object
For TYPO3 6.2 change the following line:
to
Edit:
Helmut Hummel, a member of the TYPO3 CMS team, measured that using EID with Extbase is slower than using the typeNum approach. But since the typeNum approach is cumbersome to configure, there is a third way developed by him.
The extension typoscript_rendering provides a way to call Extbase actions directly without additional configuration. It contains a ViewHelper that generates such links and can be used like this in a Fluid template:
This generates an URI that calls the action "listByCompetition" of my "ParticipationController". You can pass arguments normally.
The only downside is that for security reasons, the extension uses the cHash to validate the request arguments. The cHash is submitted by GET but you cannot pass additional arguments by GET at the same time because it would invalidate the cHash. So if you want to pass form data in such a request, you need to mix GET (for a valid AJAX call) and POST (for submitting user data):
(Of course this is only a very basic example. You might post whole models etc.)
The EID way:
Yes, you can use the EID (Extension ID) mechanism for that. There is no official statement which way (pageType or eID) should be used for Extbase AJAX calls and it seems to be just a matter of taste.
There is a nice tutorial that can be found here and I copy the source code in here:
Have a look at the "usage of this script" section that explains how to register the eID. The script works with TYPO3 6.1 and higher.
For Test Extension.
Include EID in the ext_localconf.php file
Create directory in classes – Classes/Ajax/EidDispatcher.php
Call From Script
I used a quick and probably dirty way without typeNum. I used jQuery ajax call the common way. My target action ended with the following.
The createHeader Method
The output is the template of the called action. This can be html, json or whatever u need.
I had to change the first 0 of the
makeInstance
to the id of the page for it to work.