简体   繁体   English

从网址中删除动作和控制器-EXT:news&RealURL

[英]Remove Action & Controller from url - EXT:news & RealURL

I'm having trouble removing /news/story/ from my URL's when using ext:news and real url. 使用ext:news和真实网址时,无法从URL删除/ news / story /。

What I'd like is: 我想要的是:

www.mysite.com/en/news/this-is-my-story-title www.mysite.com/cn/news/this-is-my-story-title

And not: 并不是:

www.mysite.com/en/news/story/this-is-my-story-title www.mysite.com/cn/news/story/this-is-my-story-title

Current page structure: 当前页面结构:

-root(1)
--Home (2)
--News (3)
---Story (4)

This is my manual realurl conf: 这是我的手册realurl conf:

<?php

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

$domain = 'mysite.com';
$rootPageUid = 1;
$rssFeedPageType = 9818; // pageType of your RSS feed page

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'][$domain] = [
    'pagePath' => [
        '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' => [
        'enableCHashCache' => true,
        'respectSimulateStaticURLs' => 0,
        'appendMissingSlash' => 'ifNotFile,redirect',
        'adminJumpToBackend' => true,
        'enableUrlDecodeCache' => true,
        'enableUrlEncodeCache' => true,
        'emptyUrlReturnValue' => '/',
    ],
    'fileName' => [
        'defaultToHTMLsuffixOnPrev' => 0,
        'acceptHTMLsuffix' => 1,
        'index' => [
            'feed.rss' => [
                'keyValues' => [
                    'type' => $rssFeedPageType,
                ]
            ]
        ]
    ],

    'preVars' => array(
        0 => array(
            'GETvar' => 'L',
            'valueMap' => array(
                'en' => 0,
                'cy' => 1,
            ),
            'noMatch' => 'bypass',
        ),
    ),

    'fixedPostVars' => array(
        'newsDetailConfiguration' => array(
            array(
                'GETvar' => 'tx_news_pi1[action]',
                'valueMap' => array(
                    'story' => '',
                ),
                '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' => '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,
                )
            )
        ),
        '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' => '-'
                    )
                )
            )
        ),

        '4' => 'newsDetailConfiguration', // ID of the page with the news plugin detail view

    ),

    'postVarSets' => [
        '_DEFAULT' => [
            'controller' => [
                [
                    'GETvar' => 'tx_news_pi1[action]',
                    'noMatch' => 'bypass'
                ],
                [
                    'GETvar' => 'tx_news_pi1[controller]',
                    'noMatch' => 'bypass'
                ]
            ],

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

];

Using TYPO3 v8.7.15,RealURL 2.3 and News v7.0.4 使用TYPO3 v8.7.15,RealURL 2.3和News v7.0.4

RealUrl is set to use my manual conf file also. RealUrl设置为也使用我的手动conf文件。

Thanks again T3 community 再次感谢T3社区

realUrl Provide pretty nice option to exclude a page from URL segment. realUrl提供一个不错的选项,可将页面从URL段中排除。 For that go to Page-> property->General . 为此,转到Page-> property->General You will find an option Exclude from speaking URL check this Screenshot . 您会发现一个选项,“ Exclude from speaking URL请检查此屏幕截图

In your case go to story page and exclude this from URL 就您而言,请转到story页面并将其从URL中排除

-root(1)
--Home (2)
--News (3)
---Story (4) // Exclude from realUrl

That's it, this what you're actually looking for! 就是这样,这就是您真正要寻找的!

Greetings! 问候!

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM