2012-05-21 109 views
3

我需要得到實際的「一般記錄存儲頁面ID」。我發現了以下snipplet,但即使在頁面上設置了storagePid,變量也是空的。TYPO3 Extbase storagePid

$config = $this->configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK); 
var_dump($config['persistence']['storagePid']); 

任何幫助,將不勝感激

回答

9

我不太清楚,你到底得到。段,您提供的獲取沒有問題的storagePid集常量爲您的擴展,與此相同的代碼從setup.txt

plugin.tx_yourext { 
    persistence { 
     storagePid = {$plugin.tx_yourext.persistence.storagePid} 
    } 
} 

,如果你有獲得與提供的片段您storagePid問題,還可以修改setup.txt並確保該值也將被傳播到settings範圍:

plugin.tx_yourext { 
    persistence { 
     storagePid = {$plugin.tx_yourext.persistence.storagePid} 
    } 
    settings { 
     storagePid = {$plugin.tx_yourext.persistence.storagePid} 
    } 
} 

然後在你的控制器,你可以用簡單的代碼捕獲它:

$myStoragePid = $this->settings['storagePid']; 

如果它不適用於您,這意味着您沒有在Constants中爲YourExt設置適當的值並且/或者沒有清除BE中的緩存。

順便說一句:也許如果你會更具體我可以發送更好的答案。

+0

非常感謝!修改後的設置有竅門。 – netcase