在我的扩展中,我想按标题查找页面。 我尝试:
/**
* PageRepository
*
* @var \TYPO3\CMS\Frontend\Page\PageRepository
* @inject
*/
protected $pageRepository = NULL;
然后
$this->pageRepository->findByTitle('my title');
我收到错误:
Oops, an error occurred: Call to undefined method TYPO3\CMS\Frontend\Page\PageRepository::findByTitle()
如何按标题查找页面?
最佳答案
方法findByTitle()
不是由 pageRepository
提供。您可以使用getPage()
使用页面Uid
的方法像下面这样。
$this->pageRepository = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Page\PageRepository::class);
$page = $this->pageRepository->getPage($pageId, false);
关于typo3 - 在扩展名中按标题查找页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44643565/