簡體   English   中英

網址生成中跳過控制器和操作

[英]Skip controller and action in url generation

TYPO3版本是7.6.0。

產生連結:

<f:link.action action="single" class="title" pageUid="{settings.pidDetails}" additionalParams="{unid: '{unid}'}" noCacheHash="true">Link text</f:link.action>

結果:

http://example.com/property/flats/?unid=12345&tx_ext_extp1%5Baction%5D=single&tx_ext_extyp1%5Bcontroller%5D=Ext

需要:跳過網址生成過程中的控制器和操作-http: http://example.com/property/flats/?unid=12345

您可以將realurl擴展名用於干凈的url。 安裝后,編輯typo3conf文件夾中的realurl_autoconf.php文件。

function user_encodeSpURL_postProc(&$params, &$ref) {
    $params['URL'] = str_replace('blog/post/article/', 'blog/post/', $params['URL']);
}
function user_decodeSpURL_preProc(&$params, &$ref) {
    $params['URL'] = str_replace('blog/post/', 'blog/post/article/', $params['URL']);
}
$GLOBALS['TYPO3_CONF_VARS']['FE']['addRootLineFields'].= ',tx_realurl_pathsegment';
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'] = array (
    '_DEFAULT' => array (
        'init' => array (
            'enableCHashCache' => '1',
            'appendMissingSlash' => 'ifNotFile',
            'enableUrlDecodeCache' => '1',
            'enableUrlEncodeCache' => '1'
        ),
        'redirects' => array (
        ),
        'preVars' => array (
            '0' => array (
                'GETvar' => 'no_cache',
                'valueMap' => array (
                    'nc' => '0'
                ),
                'noMatch' => 'bypass',
            ),
            '1' => array (
                'GETvar' => 'L',
                'valueMap' => array (
                    'de' => '0',
                    'en' => '1'
                ),
                'noMatch' => 'bypass'
            ),
            '2' => array (
                'GETvar' => 'cHash',
                'noMatch' => 'bypass',
            ),
        ),
        'pagePath' => array (
            'type' => 'user',
            'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
            'spaceCharacter' => '-',
            'languageGetVar' => 'L',
            'rootpage_id' => '1' // your root UID
        ),
        'fixedPostVars' => array(

        ),
        'postVarSets' => array(
            '_DEFAULT' => array(
                'controller' => array(
                    array(
                        'GETvar' => 'tx_news_pi1[action]',
                        'noMatch' => 'bypass'
                    ),
                    array(
                        'GETvar' => 'tx_news_pi1[controller]',
                        'noMatch' => 'bypass'
                    )
                ),
                'authentication' => array(
                        array(
                                'GETvar' => 'tx_eventmanagementtool_ext1[action]',
                        ),
                ),
                '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]',
                    ),
                ),

            ),
        ),
        'fileName' => array (
            //'defaultToHTMLsuffixOnPrev' => '.html',
            'acceptHTMLsuffix' => 1,
            'index' => array (
                'rss.xml' => array (
                    'keyValues' => array (
                        'type' => '100'
                    ),
                ),
                'rss091.xml' => array (
                    'keyValues' => array (
                        'type' => '101'
                    ),
                ),
                'rdf.xml' => array (
                    'keyValues' => array (
                        'type' => '102'
                    ),
                ),
                'atom.xml' => array (
                    'keyValues' => array (
                        'type' => '103'
                    ),
                ),
                'sitemap.xml' => array (
                    'keyValues' => array (
                        'type' => '776'
                    ),
                ),              
            ),
        ),
    )
);

您可以使用繞過方法從網址中刪除控制器和操作,例如:

'controller' => array(
    array(
        'GETvar' => 'tx_news_pi1[action]',
        'noMatch' => 'bypass'
    ),
    array(
        'GETvar' => 'tx_news_pi1[controller]',
        'noMatch' => 'bypass'
    )
)

轉到您的擴展程序文件夾。

在配置–> TypoScript –> setup.txt中,編寫以下代碼:

plugin.tx_[your_extensionname].features.skipDefaultArguments = 1

警告 :僅當您在flexform中不使用switchableControllerActions時,此方法才有效。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM