DEPRECATION WARNING

This documentation is not using the current rendering mechanism and will be deleted by December 31st, 2020. The extension maintainer should switch to the new system. Details on how to use the rendering mechanism can be found here.

# RealURL configuration¶

This section will show you how you can rewrite the urls using the extension RealURL.

## Basic setup¶

The most simple example is the following one. You can just add the section with copy&paste to the postVarSets/_DEFAULT section:

    // EXT:news start
'a' => [
[
'GETvar' => 'tx_news_pi1[action]',
],
[
'GETvar' => 'tx_news_pi1[controller]',
],
[
'GETvar' => 'tx_news_pi1[news]',
'lookUpTable' => [
'table' => 'tx_news_domain_model_news',
'id_field' => 'uid',
'alias_field' => 'IF(path_segment!="",path_segment,title)',
'addWhereClause' => ' AND NOT deleted',
'useUniqueCache' => 1,
'languageGetVar' => 'L',
'languageExceptionUids' => '',
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l10n_parent',
'expireDays' => 180,
'enable404forInvalidAlias' => true
]
]
],
// EXT:news end


This example is advanced and works best with one single view page. It hides the controller and action name by using fixedPostVars. Here is a full RealURL configuration with the explanation below.

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142  [ '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' => [ [ 'GETvar' => 'L', 'valueMap' => [ 'en' => '1', ], 'noMatch' => 'bypass', ], ], 'fixedPostVars' => [ 'newsDetailConfiguration' => [ [ 'GETvar' => 'tx_news_pi1[action]', 'valueMap' => [ '' => 'detail', ], 'noMatch' => 'bypass' ], [ 'GETvar' => 'tx_news_pi1[controller]', 'valueMap' => [ '' => 'News', ], 'noMatch' => 'bypass' ], [ 'GETvar' => 'tx_news_pi1[news]', 'lookUpTable' => [ 'table' => 'tx_news_domain_model_news', 'id_field' => 'uid', 'alias_field' => 'IF(path_segment!="",path_segment,title)', 'addWhereClause' => ' AND NOT deleted', 'useUniqueCache' => 1, 'languageGetVar' => 'L', 'languageExceptionUids' => '', 'languageField' => 'sys_language_uid', 'transOrigPointerField' => 'l10n_parent', 'expireDays' => 180, 'enable404forInvalidAlias' => true ] ] ], 'newsCategoryConfiguration' => [ [ 'GETvar' => 'tx_news_pi1[overwriteDemand][categories]', 'lookUpTable' => [ 'table' => 'sys_category', 'id_field' => 'uid', 'alias_field' => 'title', 'addWhereClause' => ' AND NOT deleted', 'useUniqueCache' => 1, 'enable404forInvalidAlias' => true ] ] ], 'newsTagConfiguration' => [ [ 'GETvar' => 'tx_news_pi1[overwriteDemand][tags]', 'lookUpTable' => [ 'table' => 'tx_news_domain_model_tag', 'id_field' => 'uid', 'alias_field' => 'title', 'addWhereClause' => ' AND NOT deleted', 'useUniqueCache' => 1, 'enable404forInvalidAlias' => true ] ] ], '70' => 'newsDetailConfiguration', '701' => 'newsDetailConfiguration', // For additional detail pages, add their uid as well '71' => 'newsTagConfiguration', '72' => 'newsCategoryConfiguration', ], '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]', ], ], ], ], ]; 

Explanation

The configuration of newsDetailConfiguration is used for the single view. Its name is not that important but the same name has to be used in line 108 where the uid of the single view page is set. In this example it is 70. Of course you need to set the uid of your single view page.

The same happens for a single view of categories and tags by using newsCategoryConfiguration and newsTagConfiguration.

Because of using fixedPostVars, the arguments can be removed in the postVarSets section.

## Removing controller and action arguments from URL¶

If you got a separate page to display the single view it is possible to skip the arguments. This is not necessary if you use the Advanced realUrl configuration from above.

&tx_news_pi1[controller]=News
&tx_news_pi1[action]=detail


If you want that, you need to activate the following setting in your TypoScript:

plugin.tx_news {
settings {
skipControllerAndAction = 1
}
}
}


## Removing controller and action arguments from URL (II)¶

An alternative way to get rid of the arguments controller and action is to add those dynamically by the core if needed. All you need is this TypoScript:

[globalVar = GP:tx_news_pi1|news > 0]
config.defaultGetVars {
tx_news_pi1 {
controller=News
action=detail
}
}
[global]


This snippet will set &tx_news_pi1[controller]=News&tx_news_pi1[action]=detail if any news uid is provided in the URL.

If you want to have human readable dates inside the URL which means having URLs like domain.tld/fo/bar/article/31/01/2011/this-is-the-news-title.html you need 3 things.

1st: EXT:news version 1.1.0+ 2nd: Enable the configuration in TypoScript

plugin.tx_news.settings.link {
hrDate = 1
hrDate {
day = j
month = n
year = Y
}
}


You can configure each argument (day/month/year) separately by using the configuration of PHP function date, (see http://www.php.net/date).

3rd: Add following RealURL configuration to 'fixedPostVars' => 'newsDetailConfiguration' section

[
'GETvar' => 'tx_news_pi1[day]',
'noMatch' => 'bypass',
],
[
'GETvar' => 'tx_news_pi1[month]',
'noMatch' => 'bypass',
],
[
'GETvar' => 'tx_news_pi1[year]',
'noMatch' => 'bypass',
],


## alias_field Variations¶

Every news record got a field called Speaking URL path segment which can be used to build the URL of the news record.

The following snippet shows how to use this field:

[
'GETvar' => 'tx_news_pi1[news]',
'lookUpTable' => [
'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,
'languageGetVar' => 'L',
'languageExceptionUids' => '',
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l10n_parent',
'expireDays' => 180,
'enable404forInvalidAlias' => true
]
]


As you can see, it is possible to combine any of the fields of the record.

If you need to add an additional property (like the category title) to the URL, you can do so by adding the property with the typolink configuration additionalParams.

<n:link newsItem="{newsItem}" settings="{settings}" title="{newsItem.title}" configuration="{additionalParams:'&tx_news_pi1[category]={newsItem.firstCategory.uid}'}">
{newsItem.title}


[
'GETvar' => 'tx_news_pi1[category]',
'lookUpTable' => [
'table' => 'sys_category',
'id_field' => 'uid',
'alias_field' => 'title',
'addWhereClause' => ' AND NOT deleted',
'useUniqueCache' => 1,
'enable404forInvalidAlias' => true
],
],


## Auto configuration¶

If the auto configuration is enabled in EXT:realurl, news provides a configuration for that as well.

In case you want to provide your own configuration (e.g. in your sitepackage extension), you can unset the configuration by using the following code in your ext_localconf.php:

unset(\$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/realurl/class.tx_realurl_autoconfgen.php']['extensionConfiguration']['news']);