2012-05-21 195 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