Search code examples
phptypo3realurltx-news

Typo3 use realurl to mask tx_news_pi1 parameter in URL


I am pretty new to typo3. The Website is all set up now i want to use realurl to make some human readable URLS.

Out of the boy it works pretty well. But not for my news sites.

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

Please help me to get rid of the last Parameters. to get something like:

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

Here is my realurl_conf

[ See Update]

Thank you all for your time =)

Update:

So i worked my way through the manual. I copied from them and inserted my IDs and Stuff this is my new Configuration [ Deleted the first one ]

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

But still there are the tx_news_pi1[day], tx_news_pi1[month], tx_news_pi1[year] and cHash Parameters in the URL. Please Help me to get rid of them.


Solution

  • thats my configuration:

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

    look for the right insertion in the array. For that have a clean indention!