0
我如何重定向到使用重定向或轉發功能的不同動作?我的解決方案似乎不工作TYPO3 extbase轉發,重定向動作
public function listAction() {
$products = $this->productRepository->findAll();
$this->view->assign('products', $products);
}
public function showAction() {
$var = $this->request->getArgument('searchProduct');
$foundProd = new \MyVendor\Inventory\Domain\Model\Product($var);
$prod = $this->productRepository->getProduct($foundProd);
\TYPO3\CMS\Core\Utility\DebugUtility::debug($prod);
$this->view->assign('test',$prod);
$this->redirect('list',NULL,NULL,array(''));
// $this->forward('list',NULL, NULL, $this->request->getArguments());
}
在視圖中,我試圖展現foundProduct在同一個頁面(而不是建立一個新文件show.html)
<f:widget.paginate objects="{products}" as="paginatedProducts"
configuration="{itemsPerPage: 10, insertAbove: 0, insertBelow: 1, maximumNumberOfLinks: 10}">
<f:for each="{paginatedProducts}" as="productx">
<tr>
<td align="top">{productx.uid}</td>
<td align="top">{productx.name}</td>
<td align="top"><f:format.crop maxCharacters="100">{productx.description}</f:format.crop></td>
<td align="top">{productx.quantity}</td>
</tr>
</f:for>
</f:widget.paginate>
</table>
</div>
<div class="col-sm-5">
<f:form method="post" controller="Inventory" action="show" name="searchProduct" object="{searchProduct}">
<label> Product Name <span class="required"></span><br />
<f:form.textfield property="name" /></label><br />
<f:form.submit class="submit" value="Submit"/>
<div>
<f:for each ="{test}" as ="p">
<P>Numele produsului : {p.name}</P>
<p>Descriere : {p.description}</p>
<p>Cantitate : {p.quantity} </p>
</f:for>
</div>
</div>
提到的模板。那是你想要做的嗎? –
我希望這兩個動作都在同一頁面(.html文件)上執行。 Typo3有點迫使我爲每個動作創建一個不同的.html文件,在我的例子中是list.html和show.html。我不希望創建show.html,而是希望showAction在list.html中執行。 –
我無法理解它背後的想法。 'showAction'應該顯示一些內容,主要是新聞擴展中的細節視圖等記錄的細節。我使用重定向的唯一時間是當我例如更新記錄並在保存更改後返回列表。你應該過度考慮你的行爲以及在那裏做些什麼。 –