我已经做了tx_news几个扩展:extbase行动始终显示错误的流体模板
1)我已经添加了三个新的行动,以newscontroller。前两项行动按预期工作。动作eventDetail显示一个表单。这样做的流体代码
<f:form class="form-horizontal" noCacheHash="true" pageUid="30" action="createApplication" name="newApplication" object="{newApplication}" arguments="{news : newsItem, currentPage: 0, application: newApplication}" enctype="multipart/form-data">
<f:form.textfield class="form-control" property="name" size="40" required="required" />
<f:form.hidden name="newsItem" value="{newsItem}" />
<f:form.submit class="btn btn-primary" value="{f:translate(key:'submitApplyJob')}submit" />
</f:form>
行动createApplication:
/**
* action createApplication
*
* @param \FalkRoeder\DatedNews\Domain\Model\Application $newApplication
* @param \GeorgRinger\News\Domain\Model\News $news news item
* @return void
*/
public function createApplicationAction(\GeorgRinger\News\Domain\Model\News $news, $currentPage = 1, \FalkRoeder\DatedNews\Domain\Model\Application $newApplication) {
if (is_null($news)) {
$previewNewsId = ((int)$this->settings['singleNews'] > 0) ? $this->settings['singleNews'] : 0;
if ($this->request->hasArgument('news_preview')) {
$previewNewsId = (int)$this->request->getArgument('news_preview');
}
if ($previewNewsId > 0) {
if ($this->isPreviewOfHiddenRecordsEnabled()) {
$GLOBALS['TSFE']->showHiddenRecords = true;
$news = $this->newsRepository->findByUid($previewNewsId, false);
} else {
$news = $this->newsRepository->findByUid($previewNewsId);
}
}
}
if (is_a($news,
'GeorgRinger\\News\\Domain\\Model\\News') && $this->settings['detail']['checkPidOfNewsRecord']
) {
$news = $this->checkPidOfNewsRecord($news);
}
if (is_null($news) && isset($this->settings['detail']['errorHandling'])) {
$this->handleNoNewsFoundError($this->settings['detail']['errorHandling']);
}
$newApplication->setTitle($newsItem->getTitle()." - ".$newApplication->getName() . ', ' . $newApplication->getSurname());
$this->applicationRepository->add($newApplication);
$persistenceManager = GeneralUtility::makeInstance("TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager");
$persistenceManager->persistAll();
$newsItem->addApplication($newApplication);
$this->newsRepository->update($newsItem);
$demand = $this->createDemandObjectFromSettings($this->settings);
$demand->setActionAndClass(__METHOD__, __CLASS__);
$assignedValues = [
'newsItem' => $news,
'currentPage' => (int)$currentPage,
'demand' => $demand,
'newApplication' => $newApplication
];
$assignedValues = $this->emitActionSignal('NewsController', self::SIGNAL_NEWS_CREATEAPPLICATION_ACTION, $assignedValues);
$this->view->assignMultiple($assignedValues);
}
的问题是,它会显示与PID 30的正确页面提交表单后,但它显示的流体模板的内容动作eventDetail。应用程序数据不存储在数据库中。第二个奇怪的是,如果我从表单中删除了参数currentPage,我得到一个错误,说明缺少该参数,因为它在动作的定义中需要它。这告诉我需要正确的操作。
我不明白这个问题。只需要执行该操作并显示名为CreateApplication.html的流体模板。
如果需要更多信息,我会添加。
UPDATE: 如果我添加一个初始化方法为我的行动,它会被调用,参数的正确性调试:
public function initializeCreateApplicationAction(){
\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($this->request->getArguments(),'NewsController:139');
}
但还是切换到错误的流体模板即可。
谢谢。改编。但不会改变我的主要问题。 – Falk
您可以在typo3/sysext/fluid/Classes/View/TemplateView.php的方法getTemplatePathAndFilename()中进行调试,例如,通过使用调试器或者只是在那里添加一些写入日志文件。这可能有助于了解提供了哪些参数以及尝试了哪些模板文件。 – Claudia