【问题标题】:Typo3 use realurl to mask tx_news_pi1 parameter in URLTypo3 使用 realurl 来屏蔽 URL 中的 tx_news_pi1 参数
【发布时间】:2017-10-31 21:42:33
【问题描述】:

我对typo3很陌生。该网站现在已经全部设置好,我想使用 realurl 来制作一些人类可读的 URL。

在男孩之外,它运作良好。但不适用于我的新闻网站。

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/

这是我的真实url_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[day]、tx_news_pi1[month]、tx_news_pi1[year] 和 cHash URL 中的参数。 请帮助我摆脱它们。

【问题讨论】:

  • 是的,我之前找到了该文档,但我猜我不太明白。我的意思是我把那个数据放在哪里,有这么多数组。
  • 为什么要在根行字段中添加tx_realurl_pathsegment? (第二行)
  • 高级示例中。

标签: php typo3 realurl tx-news


【解决方案1】:

这是我的配置:

<?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]',
                    ),
                ),
            ),
        ),
    ),
);

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

【讨论】:

  • 试过你的。并让它工作,但参数仍然存在。
  • 旧的 url 仍然是已知的并且在缓存中。因此,如果您希望所有 url 都是干净的,则需要清除所有缓存和所有生成的 url。除了通常的缓存清除之外,您还必须使用 realurl BE 模块中的“刷新所有数据(有害!)”按钮。
【解决方案2】:

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

这里解释了 3 种方式:

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

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

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

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

处于同一级别

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

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

【讨论】:

  • 感谢您解释示例。我也拿了 2. 一个并插入了具体的东西 [News-Detail UID, $Domain etc.] 语言提示很好,但我现在没有任何语言。 skipControllerAndAction = 1 在我的 setup.ts
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-08-11
  • 1970-01-01
  • 2015-11-06
相关资源
最近更新 更多