[英]TYPO3: How to use storage pid from pagetree in backend module?
我使用Extension Builder創建了一個擴展,並在Web部分下包含了一個后端模塊。 在生成的代碼中,存儲pid有兩個常量:一個用於插件,一個用於模塊。
現在我喜歡我的模塊使用來自pagetree中所選頁面或文件夾的存儲pid,如頁面,列表或模板模塊。 如何在后端模塊中使用來自pagetree的存儲pid而不是使用常量?
要從后端模塊中的頁面樹中獲取所選頁面,一種方法是簡單地獲取id
參數,最好是在初始化程序中。
由於extbase從您的模塊(或前端插件)設置中讀取存儲pid,因此您可以覆蓋storagePid
部分,這樣您就不必為每個查詢設置pid /否則在您的存儲庫中。
以下應該有效。 但是,我在CommandController中使用它,而不是在后端使用的控制器中。 我沒有更改任何內容,因為存儲庫自動將記錄范圍限定到所選頁面。
class Tx_MyExt_Controller_BackendController extends Tx_Extbase_MVC_Controller_ActionController {
/**
* @var Tx_Extbase_Configuration_ConfigurationManagerInterface
* @inject
*/
protected $configurationManager;
/**
* @var int Current page
*/
protected $pageId;
/**
* Action initializer
*
* @return void
*/
protected function initializeAction()
{
$this->pageId = (int)t3lib_div::_GP('id');
$frameworkConfiguration = $this->configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
$persistenceConfiguration = array('persistence' => array('storagePid' => $this->pageId));
$this->configurationManager->setConfiguration(array_merge($frameworkConfiguration, $persistenceConfiguration));
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.