TYPO3 Multidomain Website Preview shows only Default Language - typo3

I'm using TYPO3 7.6 with a multidomain and multilanguage Website, you see the links below. I've one page tree and rootpage_id for all three languages!
First language is german (L=0, https://www.renosan.de/)
Second language is english (L=1, https://www.renosan.net/)
Third language is polish (L=2, https://www.renosan.pl/)
For every language I'm using an own top-level domain (de,net,pl). I've also insert the domain records at my root page (TYPO3-Backend List -> Rootpage -> Domain records)
If I'm clicking at the preview button (s. image), the preview opens in a new window with:
English: https://www.renosan.de/index.php?id=1&L=1
Polish: https://www.renosan.de/index.php?id=1&L=2
... but the content is still in the default language (german)! I need to change the TLD to change the Website language manually. It's not useful for my editors, because they aren't seeing the preview with one click.
Can someone explain the behaviour from TYPO3?
I also tried to login into Backend from .net or .pl, nothing happens. It's always the default preview. No special .htaccess entries ...
My TypoScript Setup
### default german
config {
linkVars = L(0-2)
uniqueLinkVars = 1
sys_language_mode = content_fallback
sys_language_overlay = hideNonTranslated
sys_language_uid = 0
language = de
locale_all = de_DE.UTF8
htmlTag_langKey = de
}
### english L=1
[globalString = IENV:HTTP_HOST = *renosan.net]
config {
baseURL = https://www.renosan.net/
sys_language_uid = 1
language = en
locale_all = en_GB.UTF8
htmlTag_langKey = en
}
[GLOBAL]
### polski L=2
[globalString = IENV:HTTP_HOST = *renosan.pl]
config {
baseURL = https://www.renosan.pl/
sys_language_uid = 2
language = pl
locale_all = pl_PL.UTF8
htmlTag_langKey = pl
}
[GLOBAL]
I have locate the problem with my individual realURL-conf. If I try it with the 'autoconf' from Ext:realURLthe preview from Backend works!
Here's my personal realURL-Configuration file:
<?php
$TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT'] = array(
'pagePath' => array(
'type' => 'user',
'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
'spaceCharacter' => '-',
'languageGetVar' => 'L',
'expireDays' => '3',
'rootpage_id' => 1,
'firstHitPathCache'=> 1
),
'init' => array(
'enableCHashCache' => 1,
'respectSimulateStaticURLs' => 0,
'postVarSet_failureMode' => '',
'enableUrlDecodeCache' => 1,
'enableUrlEncodeCache' => 1
),
'preVars' => array(
array(
'GETvar' => 'L',
'valueMap' => array(
//'de' => '0',
'en' => '1',
'pl' => '2'
),
'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' => '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,
),
),
),
'42' => 'newsDetailConfiguration',
'43' => 'newsDetailConfiguration',
),
'postVarSets' => array(
'_DEFAULT' => array(
'controller' => array(
array(
'GETvar' => 'tx_news_pi1[action]',
'noMatch' => 'bypass',
),
array(
'GETvar' => 'tx_news_pi1[controller]',
'noMatch' => 'bypass',
),
),
'tags' => 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' => '-',
),
),
),
),
'seite' => array(
array(
'GETvar' => 'tx_news_pi1[#widget_0][currentPage]',
),
),
// news archive parameters
'archiv' => array(
array(
'GETvar' => 'tx_news_pi1[overwriteDemand][year]',
),
array(
'GETvar' => 'tx_news_pi1[overwriteDemand][month]',
'valueMap' => array(
'january' => '01',
'february' => '02',
'march' => '03',
'april' => '04',
'may' => '05',
'june' => '06',
'july' => '07',
'august' => '08',
'september' => '09',
'october' => '10',
'november' => '11',
'december' => '12',
),
),
),
),
),
);
$TYPO3_CONF_VARS['EXTCONF']['realurl']['_DOMAINS'] = array(
'encode' => array(
array(
'GETvar' => 'L',
'value' => '0',
'useConfiguration' => 'renosan.de',
'urlPrepend' => 'https://www.renosan.de'
),
array(
'GETvar' => 'L',
'value' => '1',
'useConfiguration' => 'renosan.de',
'urlPrepend' => 'https://www.renosan.net'
),
[
'GETvar' => 'L',
'value' => '2',
'useConfiguration' => 'renosan.de',
'urlPrepend' => 'https://www.renosan.pl'
],
),
'decode' => array(
'renosan.de' => array(
'GETvars' => array(
'L' => '0',
),
'useConfiguration' => 'renosan.de'
),
'renosan.net' => array(
'GETvars' => array(
'L' => '1',
),
'useConfiguration' => 'renosan.de'
),
'renosan.pl' => array(
'GETvars' => array(
'L' => '2',
),
'useConfiguration' => 'renosan.de'
),
)
);
?>
Thanks for your help .. I have still no solution for this TYPO3-Problem?! Is it a TYPO3-Bug? Is there a problem with my realURL-Configuration-File?

I think your conditions are wrong and TYPO3 gets so confused that the conditions are ignored completely.
it is not
[global string = ENV: HTTP_HOST = ...
but:
[globalString = ENV:HTTP_HOST = ...
On the other hand I assume your TYPO3 will also gets confused about domains and additional language parameter. For preview you need to be logged in into the BE (cookies are domain dependend). So a preview in another language is possible only with language parameter. Your configuration mixes domains and language parameter: if you start with www.renosan.de?L=1 your baseurl is changed.
My recommandation: Split the handling depending on domain and L-Param.

If you use RealURL: Look at this blog post. Here you can see how to config realURL to watch at the Domains to seperate languages.
After that, you dont need conditions about the domains. You can use the simple [globalVar = GP:L = x] conditions.

Related

RealURL error: wrong "L" parameter value

RealURL gives this error.
My site has only one language, and I have not added any website language in root page.
I tried with config.linkVars = L and config.linkVars = L(0-5) in the setup with no effect.
RealURL Config is auto-generated:
<?php
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'] = array(
'_DEFAULT' => array(
'init' => array(
'appendMissingSlash' => 'ifNotFile,redirect',
'emptyUrlReturnValue' => '/'
),
'pagePath' => array(
'rootpage_id' => '1'
),
'fileName' => array(
'defaultToHTMLsuffixOnPrev' => 0,
'acceptHTMLsuffix' => 1,
'index' => array(
'print' => array(
'keyValues' => array(
'type' => 98
)
)
)
),
'postVarSets' => array(
'_DEFAULT' => array(
'news' => array(
0 => array(
'GETvar' => 'tx_news_pi1[news]',
'lookUpTable' => array(
'table' => 'tx_news_domain_model_news',
'id_field' => 'uid',
'alias_field' => 'title',
'useUniqueCache' => 1,
'useUniqueCache_conf' => array(
'strtolower' => 1,
'spaceCharacter' => '-'
)
)
)
)
)
)
)
);
I think thats a RealURL 2.1.7 problem.
I downgrade to RealURL 2.1.5 and then it works.
EDIT:
Now i add page.theme.language.languageValue = 0 to my template constants
See => https://github.com/dmitryd/typo3-realurl/issues/407
A quick fix for 2.1.7 can be a strict assignment of the configured "uid" integer values
linkVars = L(0-1)
… did the job for me. Instead of L(0-3)

How to omit empty (optional) segment in realurl?

Currently I'm trying to create nice looking URL's for my custom extension.
I am using a plugin on page "Products" (uid: 3) to list all categories.
For example there are the following categories:
Men
Shirts
Sweatshirts
Women
Shoes
Dresses
I'd like to have these corresponding URL's:
www.mydomain.com/products/men.html
www.mydomain.com/products/men/shirts.html
This is, what I get:
www.mydomain.com/products//men.html
www.mydomain.com/products/men/shirts.html
The category "Men" on the first Level does not have a parent category, so this segment remains empty. As soon as there is a parent category, everything is fine.
TYPO3 Version: 7.6.15
realurl Version: 2.1.6
This is my current configuration for fixedPostVars:
'fixedPostVars' => array (
// EXT: productsDb start
'productsDbConfiguration' => array(
array(
'GETvar' => 'tx_productsdb_categories[action]',
'valueMap' => array(
),
'noMatch' => 'bypass'
),
array(
'GETvar' => 'tx_productsdb_categories[controller]',
'valueMap' => array(
),
'noMatch' => 'bypass'
),
array(
'GETvar' => 'tx_productsdb_categories[parent]',
'lookUpTable' => array(
'table' => 'tx_productsdb_domain_model_category',
'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,
),
// 'valueDefault' => '',
),
array(
'GETvar' => 'tx_productsdb_categories[category]',
'lookUpTable' => array(
'table' => 'tx_productsdb_domain_model_category',
'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,
)
),
),
'3' => 'productsDbConfiguration',
// EXT: productsdb end
),
So, here is my question:
Is there a way and what do I need to do, to skip an optional path segment, if it is empty?
Thanks in advance for having a look at it.
here's the code I used for the realurl encodeSpURL_postProc hook:
public function encodeUrl(&$params) {
$originalParameters = $params['pObj']->getOriginalUrlParameters();
if(array_key_exists('tx_productsdb_categories[category]', $originalParameters)===TRUE) {
if (strpos($params['URL'], '//')) {
$encodedSegments = explode('/', $params['URL']);
$modifiedSegments = array_filter($encodedSegments, 'strlen');
$params['URL'] = implode('/', $modifiedSegments);
}
}
}
let me know, if you got any other ideas for improvement.

Get rid of extensionname in realurl

I try to change my generated url from http://www.example.com/page/extensionname/MyArticleNumber/ to http://www.example.com/page/MyArticleNumber/ using Realurl 1.12.8 and TYPO3 6.2.27.
My realurl_conf.php:
'postVarSets' => array(
'_DEFAULT' => array(
'extensionname' => array(
array(
'GETvar' => 'extensionname_plugin[article]',
'lookUpTable' => array(
'table' => 'tx_extensionname_domain_model_article',
'id_field' => 'uid',
'alias_field' => 'CONCAT(short_title, \'-\', juq)',
'addWhereClause' => ' AND NOT deleted',
'useUniqueCache' => 1,
'useUniqueCache_conf' => array(
'spaceCharacter' => '-',
),
),
),
),
),
What and and where do I have to edit to solve this problem?
Thank you in advance.
If you use your extension at one specific page you can use 'fixedPostVars'
'fixedPostVars' => array(
# extension configuration
'extensionname' => array(
array(
'GETvar' => 'extensionname_plugin[article]',
'lookUpTable' => array(
'table' => 'tx_extensionname_domain_model_article',
'id_field' => 'uid',
'alias_field' => 'CONCAT(short_title, \'-\', juq)',
'addWhereClause' => ' AND NOT deleted',
'useUniqueCache' => 1,
'useUniqueCache_conf' => array(
'spaceCharacter' => '-',
),
),
),
),
# PID for extension configurations
'99' => 'extensionname',
),
I have make use of the encodeSpURL_postProc and decodeSpURL_preProc functions of realUrl.
The following code have I added to my realurl_conf.php file:
<?php
$GLOBALS['realURLEncodeSpURLArray'] = array(
'url/by/realurl/' => 'new/url/',
'page/extensionname/' => 'page/'
);
function user_encodeSpURL_postProc(&$params, &$ref)
{
$params['URL'] = str_replace(array_keys($GLOBALS['realURLEncodeSpURLArray']), array_values($GLOBALS['realURLEncodeSpURLArray']), $params['URL']);
}
function user_decodeSpURL_preProc(&$params, &$ref)
{
$params['URL'] = str_replace(array_values($GLOBALS['realURLEncodeSpURLArray']), array_keys($GLOBALS['realURLEncodeSpURLArray']), $params['URL']);
}
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'] = array(
'encodeSpURL_postProc' => array('user_encodeSpURL_postProc'),
'decodeSpURL_preProc' => array('user_decodeSpURL_preProc'),
'_DEFAULT' => array(
...
);
Please ensure that the new/url/should be unique so that there is no conflict.
By example: If you want to map txnews you got an url like mynewspage/details/txnews/article you should replace mynewspage/details/txnews/ with mynewspage/details/. Do not replace txnews/ with /!

TYPO3 7.6 - tx_news 4.2.1 - no detail name in realurl?

The realurl config with tx_news works fine for me, but I have one problem. I dont need the detail-name in the address.
www.domain.org/news-list/news-detail/test-news-name-here/
and now i dont need the "news-detail".
Here the PHP code realurl.php
<?php
$TYPO3_CONF_VARS['FE']['addRootLineFields'].= ',tx_realurl_pathsegment';
$TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT'] = array(
'pagePath' => array(
'type' => 'user',
'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
'spaceCharacter' => '-',
'languageGetVar' => 'L',
'expireDays' => '3',
'rootpage_id' => 1,
'firstHitPathCache'=>1
),
'init' => array(
'enableCHashCache' => TRUE,
'enableCHashCache' => 1,
'respectSimulateStaticURLs' => 0,
'enableUrlDecodeCache' => 1,
'enableUrlEncodeCache' => 1
),
'preVars' => array(
array(
'GETvar' => 'L',
'valueMap' => array(
//'de' => '0',
//'en' => '1',
),
'noMatch' => 'bypass',
),
array(
'GETvar' => 'no_cache',
'valueMap' => array(
'nc' => 1,
),
'noMatch' => 'bypass',
),
),
'fileName' => array(
'index' => array(
'sitemap.xml' => array(
'keyValues' => array(
'type' => 1234,
),
),
),
),
'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' => '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,
),
),
),
'6' => 'newsDetailConfiguration',
// For additional detail pages, add their uid as well
//'13' => 'newsDetailConfiguration',
//'22' => 'newsDetailConfiguration',
//'4' => 'newsTagConfiguration',
//'4' => 'newsCategoryConfiguration',
),
'postVarSets' => array(
'_DEFAULT' => array(
'controller' => array(
array(
'GETvar' => 'tx_news_pi1[action]',
'noMatch' => 'bypass',
),
array(
'GETvar' => 'tx_news_pi1[controller]',
'noMatch' => 'bypass',
),
),
'stadt' => 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' => '-',
),
),
),
),
'tags' => 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' => '-',
),
),
),
),
'seite' => array(
array(
'GETvar' => 'tx_news_pi1[#widget_0][currentPage]',
),
),
// news archive parameters
'archiv' => array(
array(
'GETvar' => 'tx_news_pi1[overwriteDemand][year]',
),
array(
'GETvar' => 'tx_news_pi1[overwriteDemand][month]',
'valueMap' => array(
'january' => '01',
'february' => '02',
'march' => '03',
'april' => '04',
'may' => '05',
'june' => '06',
'july' => '07',
'august' => '08',
'september' => '09',
'october' => '10',
'november' => '11',
'december' => '12',
),
),
),
),
),
// configure filenames for different pagetypes
'fileName' => array(
'defaultToHTMLsuffixOnPrev' => 0,
),
);
?>
I need that typoscript?
plugin.tx_news {
settings {
link {
skipControllerAndAction = 1
}
}
}
In the Detail-Page I check the realurl:
tx_realurl_exclude = 1
You can use detail & list plugin on the same page. Check this url: https://forge.typo3.org/issues/50489
lib.news = USER
lib.news {
userFunc = tx_extbase_core_bootstrap->run
pluginName = Pi1
extensionName = News
controller = News
settings =< plugin.tx_news.settings
persistence =< plugin.tx_news.persistence
view =< plugin.tx_news.view
}
lib.news_list< lib.news
lib.news_list {
action = list
switchableControllerActions.News.1 = list
}
lib.news_detail < lib.news
lib.news_detail {
action = detail
switchableControllerActions.News.1 = detail
}
[globalVar = GP:tx_news_pi1|news > 0]
lib.field_news_single < lib.news_detail
[else]
lib.field_news_list < lib.news_list
[end]
Answer: it is not possible to exclude the current (=last) page from speaking URL.
If you are interested in technical details, you can read more in the RealURL's notes for integrators.
Just an additional followup with another solution:
Use a TypoScript condition to render dynamically the detail plugin at the list page.
[globalVar = GP:tx_news_pi1|news > 0]
page.10 >
page.10 < lib.news
[global]
Of course you can do a lot more fancy stuff if you need to render e.g. other content elements as well!
[globalVar = GP:tx_news_pi1|news > 0]
page.10 >
page.10 = CONTENT
page.10 {
table = tt_content
pidInList = <page ID of your detail page>
orderBy = sorting
}
[global]
This will render you all content elements of the detail page on the list page.
If you want to have list and single view on separate pages then extension singleview at https://github.com/sourcebroker/singleview does exactly what you want.
This extension uses TYPO3 build in feature "Show content from pid" which you can find in page properties. In this extension value for "Show content from pid" field is set dynamically based on $_GET parameter. When TYPO3 renders page with list view then ext:singleview checks if $_GET parameter has single view request. If this is true then it sets "content_from_pid" field with value of single view page uid. This way single view page with its content and layout is shown on list view page.
For TYPO3 7.6 use ext:singlenews version 1.3.

Typo3: RealURL and Ext:news – News URLs are not rewritten

I'm runnning Typo3 6.2.4 with RealURL 1.12.8 and News (tx_news) 3.0.1. Using the automatic configuration from RealURL rewrites the URLs for "normal" pages, but not for news. The generated links look like this:
index.php?id=5&tx_news_pi1%5Bnews%5D=4&tx_news_pi1%5Bcontroller%5D=News&tx_news_pi1%5Baction%5D=detail&cHash=706379a0ef43d4020448c5193f865bf1
This is what automatic configuration gives me. I've just inserted the part from http://docs.typo3.org/typo3cms/extensions/news/Main/Administration/Realurl/Index.html. At the moment I'm not interested in creating a special kind of rewritten URL, I just want to get RealURL rewrite the news URLs. Once that's running, I think I'll get the rest figured out.
<?php
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']=array (
'_DEFAULT' =>
array (
'init' =>
array (
'enableCHashCache' => true,
'appendMissingSlash' => 'ifNotFile,redirect',
'adminJumpToBackend' => true,
'enableUrlDecodeCache' => true,
'enableUrlEncodeCache' => true,
'emptyUrlReturnValue' => '/',
),
'pagePath' =>
array (
'type' => 'user',
'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
'spaceCharacter' => '-',
'languageGetVar' => 'L',
'rootpage_id' => '1',
),
'fileName' =>
array (
'defaultToHTMLsuffixOnPrev' => 0,
'acceptHTMLsuffix' => 1,
'index' =>
array (
'print' =>
array (
'keyValues' =>
array (
'type' => 98,
),
),
),
),
'postVarSets' =>
array (
'_DEFAULT' =>
array (
// EXT:news start
'news' => array(
array(
'GETvar' => 'tx_news_pi1[action]',
),
array(
'GETvar' => 'tx_news_pi1[controller]',
),
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,
),
),
),
// EXT:news end
),
),
),
);
It turned out that my realurl_conf.php was correct, but the TypoScript configuration part was missing. As soon as I put those lines in the template setup of my root page, Typo3 started to rewrite the URLs:
config.absRefPrefix = /
config.tx_realurl_enable = 1
config.uniqueLinkVars = 1
# dont forget to set the allowed range - otherwise anything else could be inserted
config.linkVars = L(0-3)
Source:
http://wiki.typo3.org/Realurl/manual#TypoScript_configuration
http://docs.typo3.org/typo3cms/extensions/realurl/Realurl/Configuration/HandlingRelativeLinksWithSpeakingUrls/Index.html