Correcting issue in slug of custom extension in config.yaml - typo3

Error message
(1/1) #1537298284 InvalidArgumentException
Enhancer type cannot be empty
I need to pass more than one argument to next page, how can I add more than more argument in config.yaml
This is my code:
FakteSemilivevideolist:
extension: FakteSemilivevideo
plugin: FakteSemilivevideo
routes:
-
routePath: '/{subuid}/{catuid}'
_controller: 'Videodetails::list'
_arguments:
subuid: subuid
catuid: catuid
defaultController: 'Videodetails::list'
defaults:
subuid: '0'
catuid: '0'
requirements:
subuid: '^[a-zA-Z0-9].*$'
catuid: '^[a-zA-Z0-9].*$'
aspects:
subuid:
type: PersistedAliasMapper
tableName: tx_faktesemilivevideo_domain_model_subcategory
routeFieldName: uid
catuid:
type: PersistedAliasMapper
tableName: tx_faktesemilivevideo_domain_model_category
routeFieldName: uid

in your configuration the type of RouteEnhancer is missing (e.g. type: Extbase). Also says the error message: "Enhancer type cannot be empty".
Your configuration must look like this:
FakteSemilivevideolist:
type: Extbase
extension: FakteSemilivevideo
plugin: FakteSemilivevideo
routes:
-
routePath: '/{subuid}/{catuid}'
_controller: 'Videodetails::list'
_arguments:
subuid: subuid
catuid: catuid
defaultController: 'Videodetails::list'
defaults:
subuid: '0'
catuid: '0'
requirements:
subuid: '^[a-zA-Z0-9].*$'
catuid: '^[a-zA-Z0-9].*$'
aspects:
subuid:
type: PersistedAliasMapper
tableName: tx_faktesemilivevideo_domain_model_subcategory
routeFieldName: uid
catuid:
type: PersistedAliasMapper
tableName: tx_faktesemilivevideo_domain_model_category
routeFieldName: uid
Kay

Related

TYPO3 10 Routing - Parameters are empty

TYPO3 9 Routing - the parameter gets overwritten by the defaults - 1 year and 8 months later we are trying to update to TYPO3 10 and after that to TYPO3 11. As you can see, the site-configuration worked für typo3 9 perfectly, but now it won't anymore.
routeEnhancers:
Werbemittelshop:
type: Extbase
extension: Mwwerbemittelshop
plugin: Mwwerbemittelshop
routes:
-
routePath: '/{categoryname}/{categoryname2}/{categoryname3}'
_controller: 'MwWsCategories::category'
_arguments:
categoryname: mwWsCategory
categoryname2: mwWsCategory2
categoryname3: mwWsCategory3
-
routePath: '/{productname}'
_controller: 'MwWsCategories::product'
_arguments:
productname: mwWsProduct
defaults:
categoryname2: ''
categoryname3: ''
defaultController: 'MwWsCategories::category'
aspects:
categoryname:
type: PersistedAliasMapper
tableName: tx_mwwerbemittelshop_domain_model_mwwscategories
routeFieldName: slug
categoryname2:
type: PersistedAliasMapper
tableName: tx_mwwerbemittelshop_domain_model_mwwscategories
routeFieldName: slug
categoryname3:
type: PersistedAliasMapper
tableName: tx_mwwerbemittelshop_domain_model_mwwscategories
routeFieldName: slug
productname:
type: PersistedAliasMapper
tableName: tx_mwwerbemittelshop_domain_model_mwwsproducts
routeFieldName: slug
The "productname" works exactly as expected. It is a readable url like example.de/test123 and it uses the right action of the controller.
"categoryname2" and "categoryname3" are the problems. If I open example.de/category1/ it works but if I add a second or a third parameter my parameters are empty (example.de/category1/category2) and I don't understand it.
/**
* action category
*
* #param \MwWerbemittelshop\Mwwerbemittelshop\Domain\Model\MwWsCategories $mwWsCategory
* #param \MwWerbemittelshop\Mwwerbemittelshop\Domain\Model\MwWsCategories $mwWsCategory2
* #param \MwWerbemittelshop\Mwwerbemittelshop\Domain\Model\MwWsCategories $mwWsCategory3
* #return void
*/
public function categoryAction(
\MwWerbemittelshop\Mwwerbemittelshop\Domain\Model\MwWsCategories $mwWsCategory = null,
\MwWerbemittelshop\Mwwerbemittelshop\Domain\Model\MwWsCategories $mwWsCategory2 = null,
\MwWerbemittelshop\Mwwerbemittelshop\Domain\Model\MwWsCategories $mwWsCategory3 = null
)
{
var_dump($this->request->getArguments());
var_dump($mwWsCategory);
exit;
Can somebody of you find my mistake? I tried so many versions of it and nothing worked. If you have questions or want some more code, just ask for it.
Thanks in advance.
I can't say why, but it's working if you define each case as own route:
one category
two categories
three categories
productsname
...and a default-case without any given parameters (or defaults!):
routeEnhancers:
Werbemittelshop:
type: Extbase
extension: Mwwerbemittelshop
plugin: Mwwerbemittelshop
routes:
-
routePath: '/{productname}'
_controller: 'MwWsCategories::product'
_arguments:
productname: mwWsProduct
-
routePath: '/{categoryname}'
_controller: 'MwWsCategories::category'
_arguments:
categoryname: mwWsCategory
-
routePath: '/{categoryname}/{categoryname2}'
_controller: 'MwWsCategories::category'
_arguments:
categoryname: mwWsCategory
categoryname2: mwWsCategory2
-
routePath: '/{categoryname}/{categoryname2}/{categoryname3}'
_controller: 'MwWsCategories::category'
_arguments:
categoryname: mwWsCategory
categoryname2: mwWsCategory2
categoryname3: mwWsCategory3
defaultController: 'MwWsCategories::category'
aspects:
categoryname:
type: PersistedAliasMapper
tableName: tx_mwwerbemittelshop_domain_model_mwwscategories
routeFieldName: slug
categoryname2:
type: PersistedAliasMapper
tableName: tx_mwwerbemittelshop_domain_model_mwwscategories
routeFieldName: slug
categoryname3:
type: PersistedAliasMapper
tableName: tx_mwwerbemittelshop_domain_model_mwwscategories
routeFieldName: slug
productname:
type: PersistedAliasMapper
tableName: tx_mwwerbemittelshop_domain_model_mwwsproducts
routeFieldName: slug

Typo3 9 Routing config generating 404 error

We have a Typo3 9 server with a number of websites running on it. We also have the news plugin to facilitate the addition of blog posts.
With Typo3 9 the old RealURL system has been depricated in favour of a built in system. This is working for the normal pages but is not working for the news articles.
We have implemented the following YAML confic file which is based off the examples provided by the news plugin and a number of other stack overflow posts. The problem is that while we can confirm that the config is loaded, we get a 404 error:
404 Page not found!
Reason: The requested page does not exist
Current URL: /blog/2020-january/
We then commenced in depth, line by line examinantion of the code to understand what is going wrong. We did manage to render the /blog/2020-january/ page, but it had no content. None of the individual blog pages resolve either.
Are there other configurations that we should look for to enable this functionality? We have had another Typo3 person look at the problem without success.
rootPageId: 156
base: 'https://example.site'
baseVariants: { }
languages:
-
title: English
enabled: true
languageId: '0'
base: /
typo3Language: default
locale: en_AU
iso-639-1: en
navigationTitle: ''
hreflang: ''
direction: ''
flag: au
errorHandling: { }
routes: { }
routeEnhancers:
PageTypeSuffix:
type: PageType
default: '/'
index: '/'
map:
'/': 0
NewsPlugin:
type: Extbase
extension: News
plugin: Pi1
limitToPages:
- 187
- 201
routes:
# Detail view:
- routePath: '/{news_title}'
_controller: 'News::detail'
_arguments: {'news_title': 'news'}
# Categories:
- routePath: '/{category}'
_controller: 'News::list'
_arguments: {'category': 'overwriteDemand/categories'}
# Tags:
- routePath: '/{tag_name}'
_controller: 'News::list'
_arguments: {'tag_name': 'overwriteDemand/tags'}
# Pagination:
- routePath: '/{page}'
_controller: 'News::list'
_arguments: {'page': '#widget_0/currentPage'}
# Archive:
- routePath: '/{localized_archive}/{year}/{month}'
_controller: 'News::archive'
# Date:
- routePath: '/{year}-{month}'
_controller: 'News::list'
_arguments:
year: overwriteDemand/year
month: overwriteDemand/month
defaultController: 'News::list'
defaults:
page: '0'
year: ''
month: ''
requirements:
page: '\d+'
news_title: '^[a-zA-Z0-9].*$'
aspects:
page:
type: StaticRangeMapper
start: '1'
end: '100'
news_title:
type: PersistedPatternMapper
tableName: tx_news_domain_model_news
routeFieldPattern: '^(?P<path_segment>.+)$'
routeFieldResult: '{path_segment}'
category:
type: PersistedAliasMapper
tableName: 'sys_category'
routeFieldName: 'title'
tag_name:
type: PersistedAliasMapper
tableName: 'tx_news_domain_model_tag'
routeFieldName: 'title'
localized_archive:
type: LocaleModifier
default: 'archive'
routeFieldName: 'title'
localeMap:
- languageId: 'de_.*'
value: 'archiv'
- languageId: 'fr_.*'
value: 'archives'
year:
type: StaticRangeMapper
start: '1970'
end: '2099'
month:
type: StaticValueMapper
map:
january: '01'
february: '02'
march: '03'
april: '04'
may: '05'
june: '06'
july: '07'
august: '08'
september: '09'
october: 10
november: 11
december: 12
Please check your code see below code of news_title
routeEnhancers: News: type: Extbase extension: News plugin: Pi1 routes: - routePath: '/{news-title}' _controller: 'News::detail' _arguments: news-title: news aspects: news-title: type: PersistedAliasMapper tableName: tx_news_domain_model_news routeFieldName: path_segment
Remove curly braces from path_segment, remove do it as above or in docs thank you
Please see the official documents https://docs.typo3.org/p/georgringer/news/7.2/en-us/AdministratorManual/BestPractice/Routing/Index.html
After a lot of effort we have success.
Firstly, the final working config:
routeEnhancers:
NewsPlugin:
type: Extbase
extension: News
plugin: Pi1
limitToPages:
- 201
- 187
routes:
-
routePath: '/{news_title}'
_controller: 'News::detail'
_arguments:
news_title: news
-
routePath: '/{category}'
_controller: 'News::list'
_arguments:
category: overwriteDemand/categories
-
routePath: '/{tag_name}'
_controller: 'News::list'
_arguments:
tag_name: overwriteDemand/tags
-
routePath: '/page-{page}'
_controller: 'News::list'
_arguments:
page: '#widget_0/currentPage'
-
routePath: '/{year}/{month}'
_controller: 'News::list'
_arguments:
year: overwriteDemand/year
month: overwriteDemand/month
defaultController: 'News::list'
# defaults:
# page: '0'
# year: ''
# month: ''
requirements:
page: \d+
# news_title: '^[a-zA-Z0-9].*$'
aspects:
page:
type: StaticRangeMapper
start: '1'
end: '100'
news_title:
type: PersistedAliasMapper
tableName: tx_news_domain_model_news
routeFieldName: path_segment
category:
type: PersistedAliasMapper
tableName: sys_category
routeFieldName: title
tag_name:
type: PersistedAliasMapper
tableName: tx_news_domain_model_tag
routeFieldName: title
year:
type: StaticRangeMapper
start: '1970'
end: '2099'
month:
type: StaticRangeMapper
start: '01'
end: '12'
#month:
# type: StaticValueMapper
# map:
# january: '01'
# february: '02'
# march: '03'
# april: '04'
# may: '05'
# june: '06'
# july: '07'
# august: '08'
# september: '09'
# october: 10
# november: 11
# december: 12
The important things:
The pagination path includes the page prefix. There is no ambiguity about what page it is on.
No trailing slashes, additionally, the articles also can't have trailing slashes in the path segment. This can be done in the database and clearing the cache after
No defaults
The different month mapping is due to a requirement to match an existing system
We upgraded from 9.5.15 to 9.5.18. It is not clear if this was required.
In the site package, the default TypoScript template included link.skipControllerAndAction = 1. This needs to be removed to show the friendly urls for the articles in the list view. (See How to properly set url-routing for tx-news in TYPO3 9.5.5?)
Finally, for the date, tag and category filters to work, Disable override demand in List->Plugin->Additional must be unticked.

How to get Speaking URLs for News on Typo3 9.5

How to migrate from realurl in TYPO3 9.5 ?
I have a list view where you can filter by category AND year.
Filter by category only and filter by year only works, but I it doesnt work for a combined filter as with realurl before. (first route see below)
my current url is: events?tx_news_pi1[overwriteDemand][categories]=34&tx_news_pi1[overwriteDemand][year]=2019
my desired url: events/2019/categoryname
routeEnhancers:
News:
type: Extbase
extension: News
plugin: Pi1
limitToPages:
# list and detail page
- 6
- 42
routes:
# this doesn't work for events?tx_news_pi1[overwriteDemand][categories]=34&tx_news_pi1[overwriteDemand][year]=2019
# with realurl the path was: events/2019/categoryname
- routePath: '/{date-year}/{category-name}'
_controller: 'News::list'
_arguments:
category-name: overwriteDemand/categories
date-year: overwriteDemand/year
requirements:
date-year: '\d+'
defaultController: 'News::list'
defaults:
date-year: ''
aspects:
date-year:
type: StaticRangeMapper
start: '2000'
end: '2030'
category-name:
type: PersistedAliasMapper
tableName: sys_category
routeFieldName: slug

TYPO3 9.5 LTS routeEnhancers for news with uid to make path unique

Hello I found the following on a TYPO3 Slack channel as what one person was using. This snip of yaml exists at the /config/my-websitename/config.yaml...
routeEnhancers:
NewsList:
type: Extbase
limitToPages: [2,20,21,22,92]
extension: News
plugin: Pi1
routes:
- routePath: '/p{page}'
_controller: 'News::list'
_arguments: {'page': '#widget_0/currentPage'}
- routePath: '/{news_title}'
_controller: 'News::detail'
_arguments: {'news_title': 'news'}
defaultController: 'News::list'
defaults:
page: '0'
requirements:
page: '\d+'
news_title: '^[a-zA-Z0-9].*$'
aspects:
page:
type: StaticRangeMapper
start: '1'
end: '100'
news_title:
type: PersistedAliasMapper
tableName: 'tx_news_domain_model_news'
routeFieldName: 'path_segment'
The problem
But I noticed that when I have multiple articles with the same title there's not a unique URL.
The question
How can I add the article uid to the path to make it unique or is that a good idea? I found that it was eluded to in the docs but don't know how to get it working to extend what I have already or if there's a better example someone can give me of how to get unique urls for news?
https://docs.typo3.org/typo3cms/extensions/core/latest/Changelog/9.5/Feature-86365-RoutingEnhancersAndAspects.html#persistedpatternmapper
The answer
routeEnhancers:
NewsPlugin:
type: Extbase
extension: 'News'
plugin: 'Pi1'
routes:
- { routePath: '/{news_title}', _controller: 'News::detail', _arguments: {'news_title': 'news'} }
defaultController: 'News::list'
aspects:
news_title:
type: PersistedPatternMapper
tableName: 'tx_news_domain_model_news'
routeFieldPattern: '^(?P<path_segment>.+)-(?P<uid>\d+)$'
routeFieldResult: '{path_segment}-{uid}'

TYPO3 Route Enhancers: converting 'routeFieldName' to lowercase?

Intro: In TYPO3 v9 you're able to set up speaking URLs out-of-the-box without using the RealURL extension. This feature is configured with YAML in a so-called Site Configuration.
The following configuration excerpt extends the speaking URLs for the popular news extension. Below config category_name and tag_name I select the title field in the corresponding database tables.
Q: Is it possible to convert these titles to lowercase letters? The current configuration results in URLs like domain.com/category/TYPO3.
routeEnhancers:
NewsPlugin:
type: Extbase
limitToPages: [17,4]
extension: News
plugin: Pi1
routes:
# Detail view:
- routePath: '/{news_title}'
_controller: 'News::detail'
_arguments: {'news_title': 'news'}
# Categories:
- routePath: '/{category_name}'
_controller: 'News::list'
_arguments: {'category_name': 'overwriteDemand/categories'}
# Tags:
- routePath: '/{tag_name}'
_controller: 'News::list'
_arguments: {'tag_name': 'overwriteDemand/tags'}
defaultController: 'News::list'
aspects:
news_title:
type: PersistedAliasMapper
tableName: 'tx_news_domain_model_news'
routeFieldName: 'path_segment'
category_name:
type: PersistedAliasMapper
tableName: 'sys_category'
routeFieldName: 'title'
tag_name:
type: PersistedAliasMapper
tableName: 'tx_news_domain_model_tag'
routeFieldName: 'title'
It is easy. You can do it as made it in the ext: news
I did it the same for category and tag and it is all working good.
Look at attachment:
More about it here