-->

Set TYPO3 extbase storagePageIds / storagePid to c

2019-04-11 20:41发布

问题:

I am using the TYPO3 extension feupload, which relies on extbase. This is my first contact with extbase. But the question is about extbase in general.

I expect TYPO3 to include the usual "IN (current-page)" pid check by default in queries, unless told otherwise - but in extbase that seems to be different. Or at least in my case, it's not working.

In the extension, there is a constants / setup setting, where the storagePid can be set. This works. But we don't want to adapt that parameter manually for each page.

persistence {
       # cat=feupload/persistence; type=integer; label=Storage PID of records
       storagePid =
}

So how do I make extbase get the PID of the current page automatically as expected?

(Sub-question: I've tried to set plugin.tx_pluginname.persistence.storagePid.data = {page:uid} in setup, but that wouldn't work. What would the TS have to look like to work?)

回答1:

Well, what you did should work, but you have to write it like this:

plugin.tx_pluginname.persistence.storagePid.data = page:uid

(the {} is only necessary when you insert a data field in an ordinary wrap)

As others pointed out, you have to make sure you include the extension's configuration in your template.

If the above fails, you can programatically set the storagePid in your controller's initializeAction, like so:

$querySettings = $this->myRepository->createQuery()->getQuerySettings();
$querySettings->setStoragePageIds(array($GLOBALS["TSFE"]->id));
$this->myRepository->setDefaultQuerySettings($querySettings);


回答2:

I just tested on TYPO3 ver. 4.7.x and getText function did the trick:

plugin.tx_test {
  persistence {
    storagePid.data = field:uid
  }
}

Put this in the TS Setup of the main page, and overwrite on subpage(s) if required.



回答3:

Tested on Typo3 6.1.8

plugin.tx_test {
  persistence {
    storagePid.override.cObject = TEXT
    storagePid.override.cObject.field = uid
  }
}


标签: typo3 extbase