Typo3 使用 realurl 屏蔽 URL 中的 tx_news_pi1 参数

Typo3 use realurl to mask tx_news_pi1 parameter in URL

我对 typo3 还很陌生。该网站现在已全部设置完毕,我想使用 realurl 使一些人类可读 URLS。

从男孩的角度来看,它的效果很好。但不适用于我的新闻网站。

http://myDomain/news-events/news/Name-of-the-Article/?tx_news_pi1%5Bday%5D=19&tx_news_pi1%5Bmonth%5D=7&tx_news_pi1%5Byear%5D=2017&cHash=6af067caeb037b4de744f6b9e07b73e8

请帮我去掉最后的参数。 得到类似的东西:

http://myDomain/news-events/news/Name-of-the-Article/

这是我的 realurl_conf

[查看更新]

谢谢大家的宝贵时间=)

更新:

所以我按照手册的方式进行了工作。 我从他们那里复制并插入了我的 ID 和东西 这是我的新配置[删除了第一个]

<?php

$GLOBALS['TYPO3_CONF_VARS']['FE']['addRootLineFields'] .= ',tx_realurl_pathsegment';

// Adjust to your needs
$domain = 'http://mydomain.de';
$rootPageUid = 1;
#$rssFeedPageType = 9818; // pageType of your RSS feed page

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'][$domain] = array(
    'pagePath' => array(
            'type' => 'user',
            'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
            'spaceCharacter' => '-',
            'languageGetVar' => 'L',
            'expireDays' => '3',
            'rootpage_id' => $rootPageUid,
            'firstHitPathCache' => 1
    ),
    'init' => array(
            'enableCHashCache' => TRUE,
            'respectSimulateStaticURLs' => 0,
            'appendMissingSlash' => 'ifNotFile,redirect',
            'adminJumpToBackend' => TRUE,
            'enableUrlDecodeCache' => TRUE,
            'enableUrlEncodeCache' => TRUE,
            'emptyUrlReturnValue' => '/',
    ),
    'fileName' => array(
            'defaultToHTMLsuffixOnPrev' => 0,
            'acceptHTMLsuffix' => 1,
            'index' => array(
#                        'feed.rss' => array(
#                                'keyValues' => array(
#                                       'type' => $rssFeedPageType,
#                               )
#                        )
            )
    ),
    'preVars' => array(
            array(
                    'GETvar' => 'L',
                    'valueMap' => array(
#                                'en' => '1',
                    ),
                    'noMatch' => 'bypass',
            ),
            array(
                    'GETvar' => 'no_cache',
                    'valueMap' => array(
                            'nc' => 1,
                    ),
                    'noMatch' => 'bypass',
            ),
    ),
    'fixedPostVars' => array(
            'newsDetailConfiguration' => array(
                array(
                    'GETvar' => 'tx_news_pi1[action]',
                    'valueMap' => array(
                        'detail' => '',
                    ),
                    'noMatch' => 'bypass'
                ),
                array(
                    'GETvar' => 'tx_news_pi1[controller]',
                    'valueMap' => array(
                        'News' => '',
                    ),
                    'noMatch' => 'bypass'
                ),
                array(
                    'GETvar' => 'tx_news_pi1[news]',
                    'lookUpTable' => array(
                        'table' => 'tx_news_domain_model_news',
                        'id_field' => 'uid',
                        'alias_field' => "CONCAT(uid, '-', IF(path_segment!='',path_segment,title))",
                        /** OR ***************/
                        'alias_field' => 'IF(path_segment!="",path_segment,title)',
                        /** OR ***************/
                        'alias_field' => "CONCAT(uid, '-', title)",

                        'addWhereClause' => ' AND NOT deleted',
                        'useUniqueCache' => 1, # 1?
                        'useUniqueCache_conf' => array(
                            'strtolower' => 1,
                            'spaceCharacter' => '-'
                        ),
                        'languageGetVar' => 'L',
                        'languageExceptionUids' => '',
                        'languageField' => 'sys_language_uid',
                        'transOrigPointerField' => 'l10n_parent',
                        'expireDays' => 180,

                    ),
                    #Depends ?  
                    array(
                        'GETvar' => 'tx_news_pi1[day]',
                        'noMatch' => 'bypass',
                    ),
                    array(
                        'GETvar' => 'tx_news_pi1[month]',
                        'noMatch' => 'bypass',
                    ),
                    array(
                        'GETvar' => 'tx_news_pi1[year]',
                        'noMatch' => 'bypass',
                    ),
                ),
                'newsCategoryConfiguration' => array(
                    array(
                        'GETvar' => 'tx_news_pi1[overwriteDemand][categories]',
                        'lookUpTable' => array(
                            'table' => 'sys_category',
                            'id_field' => 'uid',
                            'alias_field' => 'title',
                            'addWhereClause' => ' AND NOT deleted',
                            'useUniqueCache' => 1,
                            'useUniqueCache_conf' => array(
                                'strtolower' => 1,
                                'spaceCharacter' => '-'
                            )
                        )
                    )
                ),
                'newsTagConfiguration' => array(
                    array(
                        'GETvar' => 'tx_news_pi1[overwriteDemand][tags]',
                        'lookUpTable' => array(
                            'table' => 'tx_news_domain_model_tag',
                            'id_field' => 'uid',
                            'alias_field' => 'title',
                            'addWhereClause' => ' AND NOT deleted',
                            'useUniqueCache' => 1,
                            'useUniqueCache_conf' => array(
                                'strtolower' => 1,
                                'spaceCharacter' => '-'
                            )
                        )
                    )
                ),
                #TODO: ID-News Seite Finden
                #'145' => 'newsDetailConfiguration',
                #'147' => 'newsDetailConfiguration', // For additional detail pages, add their uid as well
                #'134' => 'newsDetailConfiguration', // For additional detail pages, add their uid as well
                '148' => 'newsDetailConfiguration', // For additional detail pages, add their uid as well
                '149' => 'newsDetailConfiguration', // For additional detail pages, add their uid as well
                #'71' => 'newsTagConfiguration',
                #'72' => 'newsCategoryConfiguration',
        ),
        'postVarSets' => array(
            '_DEFAULT' => array(
                'controller' => array(
                    array(
                        'GETvar' => 'tx_news_pi1[action]',
                        'noMatch' => 'bypass'
                    ),
                    array(
                        'GETvar' => 'tx_news_pi1[controller]',
                        'noMatch' => 'bypass'
                    )
                ),

                'dateFilter' => array(
                    array(
                        'GETvar' => 'tx_news_pi1[overwriteDemand][year]',
                    ),
                    array(
                        'GETvar' => 'tx_news_pi1[overwriteDemand][month]',
                    ),
                ),
                'page' => array(
                    array(
                        'GETvar' => 'tx_news_pi1[@widget_0][currentPage]',
                    ),
                ),
            ),
        ),
    )
);

但还是有 tx_news_pi1[日]、tx_news_pi1[月]、tx_news_pi1[年] 和 cHash URL 中的参数。 请帮助我摆脱它们。

那是我的配置:

<?php
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']=array (
    '_DEFAULT' => array (
        'init' => array (
            'appendMissingSlash' => 'ifNotFile,redirect',
             'emptyUrlReturnValue' => '/',
        ),
        'pagePath' => array (
            'rootpage_id' => '2',
        ),
        'fileName' => array (
            'defaultToHTMLsuffixOnPrev' => 0,
            'acceptHTMLsuffix' => 1,
            'index' => array (
                'print' => array (
                    'keyValues' => array (
                        'type' => 98,
                     ),
                 ),
             ),
        ),
        'preVars' => array(
            array(
                'GETvar' => 'L',
                'valueMap' => array(
                    'en' => '1',
                ),
                'noMatch' => 'bypass',
            ),
            array(
                'GETvar' => 'no_cache',
                'valueMap' => array(
                    'nc' => 1,
                ),
                'noMatch' => 'bypass',
            ),
        ),
        'fixedPostVars' => array(
            // config for single/detail news: 
            'newsDetailConfiguration' => array(
                array(
                    'GETvar' => 'tx_news_pi1[action]',
                    'valueMap' => array(
                        'detail' => '',
                    ),
                    'noMatch' => 'bypass'
                ),
                array(
                    'GETvar' => 'tx_news_pi1[controller]',
                    'valueMap' => array(
                        'News' => '',
                    ),
                    'noMatch' => 'bypass'
                ),
                array(
                    'GETvar' => 'tx_news_pi1[news]',
                    'lookUpTable' => array(
                        'table' => 'tx_news_domain_model_news',
                        'id_field' => 'uid',
                        'alias_field' => 'concat(uid,\'_\',title)',
                        'addWhereClause' => ' AND NOT deleted',
                        'useUniqueCache' => 1,
                        'useUniqueCache_conf' => array(
                            'strtolower' => 1,
                            'spaceCharacter' => '-'
                        ),
                        'languageGetVar' => 'L',
                        'languageExceptionUids' => '',
                        'languageField' => 'sys_language_uid',
                        'transOrigPointerField' => 'l10n_parent',
                        'autoUpdate' => 1,
                        'expireDays' => 180,
                    )
                )
            ),
            // config for category selection: 
            'newsCategoryConfiguration' => array(
                array(
                    'GETvar' => 'tx_news_pi1[overwriteDemand][categories]',
                    'lookUpTable' => array(
                        'table' => 'sys_category',
                        'id_field' => 'uid',
                        'alias_field' => 'title',
                        'addWhereClause' => ' AND NOT deleted',
                        'useUniqueCache' => 1,
                        'useUniqueCache_conf' => array(
                            'strtolower' => 1,
                            'spaceCharacter' => '-'
                        )
                    )
                )
            ),
            // configuration for tag selection:
            'newsTagConfiguration' => array(
                array(
                    'GETvar' => 'tx_news_pi1[overwriteDemand][tags]',
                    'lookUpTable' => array(
                        'table' => 'tx_news_domain_model_tag',
                        'id_field' => 'uid',
                        'alias_field' => 'title',
                        'addWhereClause' => ' AND NOT deleted',
                        'useUniqueCache' => 1,
                        'useUniqueCache_conf' => array(
                            'strtolower' => 1,
                            'spaceCharacter' => '-'
                        )
                    )
                )
            ),
            // add your page uids where you have detail view of news:
            '70' => 'newsDetailConfiguration',
            //'701' => 'newsDetailConfiguration', // For additional detail pages, add their uid as well
            /connect page uid for further views: tag-selection, category-selection"
            '71' => 'newsTagConfiguration',
            '72' => 'newsCategoryConfiguration',
        ),
        'postVarSets' => array(
            '_DEFAULT' => array(
                'controller' => array(
                    array(
                        'GETvar' => 'tx_news_pi1[action]',
                        'noMatch' => 'bypass'
                    ),
                    array(
                        'GETvar' => 'tx_news_pi1[controller]',
                        'noMatch' => 'bypass'
                    )
                ),

                'dateFilter' => array(
                    array(
                        'GETvar' => 'tx_news_pi1[overwriteDemand][year]',
                    ),
                    array(
                        'GETvar' => 'tx_news_pi1[overwriteDemand][month]',
                    ),
                ),
                'page' => array(
                    array(
                        'GETvar' => 'tx_news_pi1[@widget_0][currentPage]',
                    ),
                ),
            ),
        ),
    ),
);

在数组中寻找正确的插入。对于那个有一个干净的缩进!

已经提到的 link 非常有用并且包含详细信息: https://docs.typo3.org/typo3cms/extensions/news/AdministratorManual/BestPractice/Realurl/Index.html

那里解释了 3 种方式:

  1. 一个基本的,仍然将动作和控制器名称显示为 URL 路径段
  2. 高级示例(Bernd Wilke 也在他的示例中使用的示例)
  3. 避免在 URL
  4. 中使用控制器和动作名称的 TypoScript 解决方案

选项 2 只有在您为控制器配置预设和特殊页面 (uid) 的操作名称时在专用页面(列表和详细视图的单独页面)上显示详细新闻时才能使用 - 您的新闻详情视图。

选项 3 基本上与选项 2 相同,但在 TypoScript 级别上,它可以用于列表和详细信息视图在一个页面上的情况。 这两个选项可以/应该与设置 skipControllerAndAction = 1.

结合使用

如果您想使用基本设置。 postVarSets 与 fixedPortsVarspreVars

处于同一级别

补充提示: 您是否使用 DE 或 EN 以外的任何其他语言作为您的默认语言?如果是这样,您的默认语言的 sys 语言 uid 为 0,因此一切都很好。 默认语言通常有 0 的 sys 语言 uid。如果你不需要默认语言路径段,你将它留在我们真正的 url 配置中,这样它就会被绕过。 有关语言设置的更多信息:https://github.com/dmitryd/typo3-realurl/wiki/Notes-for-Integrators#configuring-languages

RealUrl 文档: https://github.com/dmitryd/typo3-realurl/wiki