2

在 TYPO3 6.1.7 上使用扩展生成器构建的 extbase 扩展中,我没有通过 Typoscript 设置任何 storagePid。

但是我在插件中设置了“记录存储页面”:

在此处输入图像描述

我希望它现在只能从此页面获取记录。但它没有,它只是返回该表中的所有项目。

如何使扩展程序识别插件中的设置?或者(如果它应该开箱即用)我如何找出它为什么不这样做?

4

3 回答 3

16

当我的扩展程序的前端插件(TYPO3 7.6.4)拒绝使用插件的“页面”字段(“记录存储页面”)时,我做了很多研究,所以我想分享我的发现:

我的扩展名是'tx_dhsnews',我的插件名是'infobox'

  1. setRespectStoragePage 必须设置为 true(默认):$query->setRespectStoragePage(TRUE)

  2. 在打字稿设置中,插件特定的 storagePid plugin.tx_dhsnews_infobox.persistence.storagePid绝对不能出现!不是具有空值的事件!否则“页面”字段将不被尊重!

就这样。Extensions Builder 刚刚创建了一个打字稿设置,并将特定插件“信息框”的 storagePid 设置为空。这导致插件不尊重“页面” - 字段。

在扩展级别设置 storagePid 没有问题(例如'tx_dhsnews..persistence.storagePid'),该值将与'pages'(“记录存储页面”)中给出的值合并,但尽快特定于插件的 tx_[extension]_[plugin].persistence.storagePid 存在于打字稿中,它将覆盖其他所有内容!

希望这会帮助某人节省一些时间+紧张

于 2016-04-08T00:23:59.100 回答
8

将以下代码添加到您的存储库

namespace <Vendor>\<Extkey>\Domain\Repository;

class ExampleRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {

    // Example for repository wide settings
    public function initializeObject() {
        /** @var $defaultQuerySettings \TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings */
        $defaultQuerySettings = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Typo3QuerySettings');
        // add the pid constraint
        $defaultQuerySettings->setRespectStoragePage(TRUE);
}

    // Example for a function setup changing query settings
    public function findSomething() {
        $query = $this->createQuery();
        // add the pid constraint
        $query->getQuerySettings()->setRespectStoragePage(TRUE);
        // the same functions as shown in initializeObject can be applied.
        return $query->execute();
    }
}

您将在此页面http://forge.typo3.org/projects/typo3v4-mvc/wiki/Default_Orderings_and_Query_Settings_in_Repository找到更多信息

于 2014-01-15T22:48:00.323 回答
1

我实际上修改了我的 MVC 控制器,以根据实际页面(storagePid==page.id)实现记录过滤。看起来像这样:

use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;

class MyMVCController extends ActionController {
protected function initializeAction() {
    parent::initializeAction();
    //fallback to current pid if no storagePid is defined
    $configuration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
    if (empty($configuration['persistence']['storagePid'])) {
        $currentPid['persistence']['storagePid'] = GeneralUtility::_GP('id');
        $this->configurationManager->setConfiguration(array_merge($configuration, $currentPid));
    }
[..]

我使用了http://wiki.t3easy.de/的解决方案并修改了 storagePid 的值,因为我开发了一个后端模块。他的 tscript 示例对我不起作用。Thomas Deuling 的一篇文章对该主题也很有趣。

但我仍然没有把整个联系都放在我的脑海里……想回到 symfony xD

编辑:对于回购查询的修改,这篇文章看起来也很有趣: https ://forge.typo3.org/projects/typo3v4-mvc/wiki/Default_Orderings_and_Query_Settings_in_Repository

于 2014-07-18T16:01:25.340 回答