TYPO3 9.5: Replace RealURL-code with Advanced Routing Configuration - typo3

How do I get this code from RealURL into the TYPO3 9.5 'Advanced Routing Configuration'?
With 'aspects' type 'PersistedAliasMapper', you can only map to the UID.
But I want to map to another field!
In my case over the 'event_id' field.
array(
'GETvar' => 'tx_extension_search[eventid]',
'lookUpTable' => array(
'table' => 'tx_extension_domain_model_event',
'id_field' => 'event_id',
'alias_field' => 'title_alias',
'useUniqueCache' => 0,
'useUniqueCache_conf' => array(
'strtolower' => 1,
'spaceCharacter' => '-'
)
),
),

I would suggest to add a slug field. With this the editor can handle the url segment of every record.
Here are the needed changes:
SQL:
CREATE TABLE tx_extension_domain_model_event (
slug varchar(1024) DEFAULT '' NOT NULL
);
TCA of tx_extension_domain_model_event
'slug' => [
'exclude' => true,
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:pages.slug',
'config' => [
'type' => 'slug',
'size' => 50,
'generatorOptions' => [
'fields' => ['title'],
'replacements' => [
'/' => '-'
],
],
'fallbackCharacter' => '-',
'default' => ''
]
],
The configuration in your config.yaml, with e.g. showAction to show the details of an event:
routeEnhancers:
YourPlugin:
type: Extbase
extension: ExtensionKey
plugin: Search
limitToPages: [Put your detailPagePid here]
routes:
- { routePath: '/event/{event}', _controller: 'Event::show', _arguments: {'event': 'event'}}
defaultController: 'Event::show'
aspects:
event:
type: PersistedAliasMapper
tableName: 'tx_extension_domain_model_event'
routeFieldName: 'slug'

Related

Problem with file upload TCA after upgrading to TYPO3 10

On typo3v9 i had working file upload field with this TCA configuration:
'image' => [
'exclude' => 0,
'label' => 'image upload',
'config' => [
'type' => 'group',
'internal_type' => 'db',
'uploadfolder' => 'uploads/folder',
'show_thumbs' => 1,
'size' => 5,
'allowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],
'disallowed' => '',
],
],
i get this result:
but after migration to typo3v10 it does not work properly and give this result:
Someone have working solution for single file upload field?
I guess you mean internal_type=file ? That's deprecated. Here an example for image upload. However you can allow other types here too, I am sure you can find more info on that.
'photos' => [
'exclude' => true,
'label' => 'LLL:EXT:xxx/Resources/Private/Language/locallang_db.xlf:tx_xxx_domain_model_activity.photos',
'config' =>
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
'photos',
[
'appearance' => [
'createNewRelationLinkTitle' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:images.addFileReference'
],
'foreign_types' => [
'0' => [
'showitem' => '
--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
--palette--;;filePalette'
],
\TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [
'showitem' => '
--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
--palette--;;filePalette'
]
],
'maxitems' => 30
],
$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
),
],

Handling of parameters which can be empty with RealURL

I have a generated path with different categories and products made with an own extension. There can be one, two or three categories, plus a product below the second or third category.
Examples of URLs that should work:
/mainCategory/
/mainCategory/secondCategory/
/mainCategory/secondCategory/product-title
/mainCategory/secondCategory/thirdCategory/
/mainCategory/secondCategory/thirdCategory/product-title
The problem now is the not required thirdCategory to show the product.
My configuration:
'fixedPostVars' =>
[
'produkt' =>
[
0 =>
[
'GETvar' => 'tx_vendor_plugin[mainCategory]',
'lookUpTable' =>
[
'table' => 'sys_category',
'id_field' => 'uid',
'alias_field' => 'title',
'languageGetVar' => 'L',
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l10n_parent',
'useUniqueCache' => 1,
'useUniqueCache_conf' =>
[
'strtolower' => 1,
'spaceCharacter' => '-',
],
],
],
1 =>
[
'GETvar' => 'tx_vendor_plugin[subCategory]',
'lookUpTable' =>
[
'table' => 'sys_category',
'id_field' => 'uid',
'alias_field' => 'title',
'languageGetVar' => 'L',
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l10n_parent',
'useUniqueCache' => 1,
'useUniqueCache_conf' =>
[
'strtolower' => 1,
'spaceCharacter' => '-',
],
],
],
2 =>
[
'GETvar' => 'tx_vendor_plugin[thirdCategory]',
'lookUpTable' =>
[
'table' => 'sys_category',
'id_field' => 'uid',
'alias_field' => 'title',
'languageGetVar' => 'L',
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l10n_parent',
'useUniqueCache' => 1,
'useUniqueCache_conf' =>
[
'strtolower' => 1,
'spaceCharacter' => '-',
],
],
],
3 =>
[
'GETvar' => 'tx_vndor_plugin[product]',
'lookUpTable' =>
[
'table' => 'tx_vendor_domain_model_product',
'id_field' => 'uid',
'alias_field' => 'title',
'languageGetVar' => 'L',
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l10n_parent',
'useUniqueCache' => 1,
'useUniqueCache_conf' =>
[
'strtolower' => 1,
'spaceCharacter' => '-',
],
],
],
],
When I add noMatch => bypass to the thirdCategory, it doesn't show up any third category. Every third category cannot be accessed.
When I use it without noMatch => bypass, there is an empty path parameter in the URL for products without third category: /mainCategory/secondCategory//product-title
Who can help me with that?
This was asked and answered by Dmitry in the TYPO3 Slack a while ago:
In other words: you can;t have optional parameters in the beginning or middle of the postVar.
Thus the verdict is that this is impossible with RealURL.
An example:
/mainCategory/secondCategory/product-title/
/mainCategory/secondCategory/thirdCategory/
How should RealURL know what to decode product-title and thirdCategory here? It's ambiguous since it could be a product or a category. That's why RealURL uses empty path segments for anything which can be optional in the beginning/middle.

Where to influence in which languages an extbase record can be translated?

In a custom built TYPO3 extension, records are only available in language -1 in the backend. That was specified as such, but should now be changed so records can be translated.
Something is missing. I thought this would be in TCA, but the definitions look quite normal:
'columns' => [
'sys_language_uid' => [
'exclude' => true,
'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.language',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'special' => 'languages',
'items' => [
[
'LLL:EXT:lang/locallang_general.xlf:LGL.allLanguages',
-1,
'flags-multiple'
]
],
'default' => 0,
],
],
'l10n_parent' => [
'displayCond' => 'FIELD:sys_language_uid:>:0',
'exclude' => true,
'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.l18n_parent',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'items' => [
['', 0],
],
'foreign_table' => 'tx_myext_domain_model_item',
'foreign_table_where' => 'AND tx_myext_domain_model_item.pid=###CURRENT_PID### AND tx_myext_domain_model_item.sys_language_uid IN (-1,0)',
],
],
Also, when I change TCA, for example change config as such:
'config' => array(
'type' => 'select',
'renderType' => 'selectSingle',
'foreign_table' => 'sys_language',
'foreign_table_where' => 'ORDER BY sys_language.title',
'items' => array(
array('LLL:EXT:lang/locallang_general.xlf:LGL.allLanguages', -1),
array('LLL:EXT:lang/locallang_general.xlf:LGL.default_value', 0)
),
),
It's still the same: only language -1 (ALL) is selectable.
Of course, the sysfolder those records are on is translated in multiple languages. Also, the columns for sys_language_uid, l10n_parent and l10n_diffsource are present in the database.
Are the other languages maybe disabled somewhere? Where else could I look?
Or which element could be missing else to make records translateable?
Thanks for any hint.

how to use the extension RealURL

I wanted to use the extension RealURL in my website,I installed it in the extensions, and this is my configuration file:
<?php
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'] = array (
'_DEFAULT' => array (
'init' => array (
'enableCHashCache' => '1',
'appendMissingSlash' => 'ifNotFile',
'enableUrlDecodeCache' => '1',
'enableUrlEncodeCache' => '1',
'emptyUrlReturnValue' => '/',
),
'redirects' => array (
// 'de/aerzte.html' => '/?id=51&L=3',
'support.html' => 'go/support-active'
),
'preVars' => array (
'0' => array (
'GETvar' => 'no_cache',
'valueMap' => array (
'nc' => '1',
),
'noMatch' => 'bypass'
),
'1' => array (
'GETvar' => 'L',
'valueMap' => array (
'de' => '3',
'en' => '0',
'fr' => '6',
// '_DEFAULT' => '0',
),
'noMatch' => 'bypass',
),
),
'pagePath' => array (
'type' => 'user',
'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
'spaceCharacter' => '-',
'languageGetVar' => 'L',
'expireDays' => '7',
'rootpage_id' => 3,
),
'fixedPostVars' => array (
),
'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
),
),
'fileName' => array (
//
// if you don't want .html-URLs set the following to "false" (e.g. 'defaultToHTMLsuffixOnPrev' => false,)
// then you get http://www.yourdomain.com/imprint/ instead of http://www.yourdomain.com/imprint.html
//
'defaultToHTMLsuffixOnPrev' => false,
'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',
),
),
),
),
),
);
$domains = array(
'_DEFAULT' => '3',
);
foreach ($domains as $domain=>$pid) {
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'][$domain] = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DEFAULT'];
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'][$domain]['pagePath']['rootpage_id'] = $pid;
}
//$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['www.****.com']['pagePath']['rootpage_id'] = 3;
?>
I excluded the pages i don't want in the url, and i deleted all the entries, i noticed the urls were changed, but the pages are not openeing anymore.
I flushed the three caches.
Thank you in advance.
edit: this was my url
https://www..com/en/blog/blog/article/
i went to the first blog and exluded it from speaking url
and the second one i set it to override the whole page path
and in article i excluded it also from speaking URL
then i went to articles entries and deleted all of them
then this link worked fine:
https://www..com/en/blog/article/
but this not:
https://www.***.com/en/blog
I got this in the extension in both blog pages :
URL conflict detected: 'en/blog/' is also used on page(s): 865 (/Home/Blog)
URL conflict detected: 'de/blog/' is also used on page(s): 722 (/Home/Blog/Blog)
For use TYPO3 RealURL extension you need to use below configuration.
add below typoscript in setup.ts.
config.simulateStaticDocuments = 0
config.tx_realurl_enable = 1
If .htaccess file not present in your root directory then add it.
check your apache configuration and if mod_rewrite is not enable then enable it.
Enable mod_rewrite use below command for linux.
a2enmod rewrite
service apache2 restart
Use Below realURL configuration.
'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',
'expireDays' => 180,
)
)
),
'blog-page-id' => 'newsDetailConfiguration',
),

Extbase: configure controller and action in realURL for detail

I'm going nuts with realURL and extbase.
Is there a simple solution for a list/detail extension to display URLs that are at least orderly, maybe in the form of
/show/detail/title-of-the-item
"show" and "detail" being action and controller, e.g.
I've been trying to remove controller and action, for example as suggested in RealURL: Remove Controller and Action from URL - but there's always something not working. Crazy.
It's not even removing the cHash.
My realurl_conf at the moment is:
<?php
$TYPO3_CONF_VARS['EXTCONF'] ['realurl'] ['_DEFAULT'] = getRealURL('1');
function getRealURL($root)
{
return array(
'init' => array(
'appendMissingSlash' => 'ifNotFile',
'enableUrlDecodeCache' => 1,
'enableCHashCache' => 1,
'enableUrlEncodeCache' => 1,
'respectSimulateStaticURLs' => 0,
'postVarSet_failureMode'=>'redirect_goodUpperDir',
),
'redirects_regex' => array (
),
'preVars' => array(
array(
'GETvar' => 'L',
'valueMap' => array(
'de' => '0',
'fr' => '1',
),
'valueDefault' => 'de',
'noMatch' => 'bypass',
),
array(
'GETvar' => 'no_cache',
'valueMap' => array(
'no_cache' => 1,
),
'noMatch' => 'bypass',
),
),
'pagePath' => array(
'type' => 'user',
'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
'spaceCharacter' => '-',
'languageGetVar' => 'L',
'expireDays' => 7,
'rootpage_id' => 1,
),
'postVarSets' => array(
'_DEFAULT' => array(
'wb' => array(
array(
'GETvar' => 'tx_weiterbildung_pi1[item]' ,
'lookUpTable' => array(
'table' => 'tx_weiterbildung_domain_model_item',
'id_field' => 'uid',
'alias_field' => 'kurs_titel',
'addWhereClause' => ' AND NOT deleted',
'useUniqueCache' => 1,
'useUniqueCache_conf' => array(
'strtolower' => 1,
'spaceCharacter' => '-',
),
),
),
),
),
),
'fileName' => array(
'defaultToHTMLsuffixOnPrev'=>0,
'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,
),
),
),
),
);
}
/**********************************
REALURL end
***********************************/
?>
Not quite simple, but at least working...
In EVERY of my ext I DO NOT use f:link.action VH, instead f:link.page so you can genearte links like
?id=123&tx_yourext_foo=bar
Without controller and action params, of course as you can see most probably you'll need to modify your FE plugins, to read these params with GeneralUtility::_GP('tx_yourext_foo'), especially if this plugin uses more than on mode (action) depending on params