I've upgraded Typo3 from version 4 to version 7 and the ajax endpoint isn't working anymore, is anyone know if there are undocumented changes in the usage of the simple ajax endpoint definition in typoscript? Or can it be that the requesting URL is different now?
The original definition looks like this:
tx_courses_ajax = PAGE
tx_courses_ajax {
typeNum = 1337
10 = USER
10 {
#userFunc = tx_extbase_core_bootstrap->run
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
extensionName = courses
pluginName = calendar
switchableControllerActions {
Seminars {
1 = getEvent
2 = calendar
3 = getEvents
}
}
settings =< plugin.tx_courses.settings
persistence =< plugin.tx_courses.persistence
view =< plugin.tx_courses.view
}
config {
disableAllHeaderCode = 1
xhtml_cleaning = 0
admPanel = 0
debug = 1
no_cache = 1
tx_realurl_enable = 0
additionalHeaders = Content-type: application/json
}
10 < tt_content.list.20.tx_courses_ajax
}
The controller is looking like this in a simplified version:
class Tx_Kurse_Controller_SeminareController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
public function calendarAction() {
$calenderCgf = '...';
file_put_contents($docroot.'uploads/jquery.fullcalendar-mini.js', $calenderCgf);
}
/**
* @return void
*/
public function getEventAction() {
$requestParams = $this->request->getArguments();
print_r($requestParams);
}
/**
* @param string $start Y-M-D H:i:s
* @param string $end Y-M-D H:i:s
*
* @return string $seminarText
*/
public function getEventsAction($start, $end) {
$start = new DateTime($start);
$end = new DateTime($end);
$seminars = $this->seminarsRepository->findEventsInPeriod($start, $end);
$requestParams = $this->request->getArguments();
print_r($requestParams);
}
/**
* @param int $seminar
* @return void
*/
public function bindingAction($seminar) {
$seminars = $this->seminareRepository->findByUid($seminar);
$this->view->assign('seminars', $seminars);
}
}
The original request-url is:
index.php?id=176&no_cache=1&tx_courses_calendar[controller]=Seminars&tx_courses_calendar[action]=binding&tx_courses_calendar[start]=2017-01-01%2000:00:00&tx_courses_calendar[end]=2017-12-30%2023:59:59&type=1337
I only get as request result in debug mode:
<!-- Parsetime: 42ms -->
So it seems that the typoscript definition is working, but something seems to be wrong :(
UPDATE: I've found the solution:
10 < tt_content.list.20.tx_courses_ajax
Must be removed because it's not doing the same as in version 4 (and it's also not necessary anymore) and after that did i've received a response with an error message. The message has said that the wanted actions are not available for this controller. After that i've digged deeper and the Extension-Name must be configured in uppercase for the first letter, otherwise it won't work.
仅凭猜测,但配置中可能缺少vendorName
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.