简体   繁体   English

Typo3 8.7.x / Extbase:如何获取页面的 sys_category

[英]Typo3 8.7.x / Extbase: How to get the sys_category of a page

can somebody tell me how to get the sys_category of a page at my controller of my extension?有人可以告诉我如何在我的扩展程序的控制器上获取页面的 sys_category 吗?

public function listAction()
{
//get the sys categories of (a) page
???

Thanks谢谢

Now I wrote a solution with QueryBuilder.现在我用 QueryBuilder 写了一个解决方案。 Maybe it could help someone else:也许它可以帮助别人:

In my extension->controller在我的扩展->控制器中

/**
 * pagesRepository
 *
 * @var \TYPO3\CMS\Frontend\Page\PageRepository
 * @inject
 */
protected $pageRepository = null;

In my extension->controller->someaction:在我的扩展->控制器->某个动作中:

    foreach ($GLOBALS['TSFE']->rootLine as $page) {

        $pageObject = $this->pageRepository->getPage($page['uid']);

        if ($pageObject['categories']) {
            $queryBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class)->getQueryBuilderForTable('sys_category');
            $query = $queryBuilder->select('sys_category.uid', 'sys_category.title')->from('sys_category');
            $query->join(
                'sys_category',
                'sys_category_record_mm',
                'mm',
                $queryBuilder->expr()->andX(
                    $queryBuilder->expr()->eq('mm.uid_local', $queryBuilder->quoteIdentifier('sys_category.uid')),
                    $queryBuilder->expr()->in('mm.uid_foreign', $page['uid']),
                    $queryBuilder->expr()->eq('mm.tablenames', $queryBuilder->quote('pages')),
                    $queryBuilder->expr()->eq('mm.fieldname', $queryBuilder->quote('categories'))
                )
            );

            $result = $query->execute()->fetchAll();

            break;
        }
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TYPO3 8.7.x / Extbase:如何获取flexform选择树视图值? - TYPO3 8.7.x / Extbase: How to get flexform select treeview values? Typo3 8.7.x / Extbase:在自己的扩展中扩展RealUrl - Typo3 8.7.x / Extbase: Extend RealUrl in own extension Typo3 8.7.x / Extbase / Realurl:为生成的html页面添加前缀 - Typo3 8.7.x / Extbase / Realurl: Add prefix for generated html page Typo3 8.7.x / Extbase / Typoscript:使用RECORDS时如何移除锚定包裹 - Typo3 8.7.x / Extbase / Typoscript: How to remove the anchor wrap when using RECORDS TYPO3:如何根据 sys_category 获取文件/图像 - TYPO3 : how to get files/images based on sys_category Typo3 8.7.x / Typoscript:获取找到的TEXT的页面uid - Typo3 8.7.x / Typoscript: Get page uid of the TEXT which was found Typo3 8.7.x / Extbase / Typoscript:如何设置用于将新的自定义对象添加到tt_content(mm关系)的storagePid - Typo3 8.7.x / Extbase / Typoscript: How to set the storagePid for adding new custom object to tt_content (mm relation) TYPO3 8.7.x / Typoscript:扩展ajax调用,从插入特定页面的插件中获取设置 - TYPO3 8.7.x / Typoscript: Extension ajax call, get settings from plugin inserted on specific page Typo3 8.7.x / Typoscript:无法在表格页面中添加字段 - Typo3 8.7.x / Typoscript: Can't get added field in table pages Typo3 8.7.x / Typoscript:无法从根页获取数据,幻灯片在根页之前停止 - Typo3 8.7.x / Typoscript: Can't get data from rootpage, slide stops before rootpage
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM