Reputation: 11
I´m currently working on a project which uses the news-extension on various pages. To get rid of cryptic URLs, i added the following code to my config.yaml
:
routeEnhancers:
News:
type: Extbase
extension: News
plugin: Pi1
routes:
- routePath: '/{news_title}'
_controller: 'News::detail'
_arguments:
news_title: news
defaultController: 'News::detail'
aspects:
news_title:
type: PersistedAliasMapper
tableName: tx_news_domain_model_news
routeFieldName: path_segment
This gives me the result i want for some pages but for others, it throws a FE-Error:
(1/1) Symfony\Component\Routing\Exception\InvalidParameterException
Parameter "tx_news_pi1__news" for route "tx_news_pi1_0" must match ".+" ("" given) to generate a corresponding URL.
This error appears on some pages, which include the news-plugin and should show a list view. The weird part is, that as this is a regular page, it should have a regular URL which perfectly works without the code mentioned above. Even more weird is the fact, that i can reach the news-detail page when manually entering the desired speaking-URL. So URL-rewriting for news detail views works on every page but it breaks other list view pages´ URLs that have worked before.
I spent a few hours trying to figure out where the error comes from and found out:
settings.categoryConjunction
from OR
to AND
, the list view works but logically shows wrong resultssettings.categories
i.e when i add a complete category instead of a subcategoryClick me to see backend configuration
Conclusion:
myproject.local/somepagewithnews
worksmyproject.local/somepagewithnews/detail/articleWithSpeakingUrl
worksmyproject.local/anotherpagewithnews
doesnt workmyproject.local/anotherpagewithnews/articleWithSpeakingUrl
works. Note that there appears no /detail/
in between. Adding it will result in a Page does not exist
-Error.Without the code, every page and every news article works with the difference that the article (not the pages with list views) have cryptic URLs.
I hope my issue is understandable and someone here can help me as this is driving me nuts. Thanks in advance!!
Upvotes: 1
Views: 755
Reputation: 31
(1/1) Symfony\Component\Routing\Exception\InvalidParameterException Parameter "tx_news_pi1__news" for route "tx_news_pi1_0" must match ".+" ("" given) to generate a corresponding URL.
The exception says the parameter to generate URL is empty "". You have configured the YAML file to get value from path_segment field to generate url.
news_title: type: PersistedAliasMapper tableName: tx_news_domain_model_news routeFieldName: path_segment
Means some of the records have an empty path_segment/slug. That's why exception keeps occurring in some pages only. Check if all the news records has value in path_segment field.
Upvotes: 3
Reputation: 31
Got the same issue.
It seams the problem is
link {
skipControllerAndAction = 1
}
in the tx_news configuration. Simply remove it.
Found this solution here: TYPO3 News routing not working properly...
Upvotes: 0
Reputation: 2272
You can add the route for list view:
routes:
- routePath: '/'
_controller: 'News::list'
In the documentation of EXT:news you can find all about the configuration of routes: https://docs.typo3.org/p/georgringer/news/8.5/en-us/AdministratorManual/BestPractice/Routing/Index.html?highlight=routeenhanc
Full configuration from doc:
routeEnhancers:
News:
type: Extbase
extension: News
plugin: Pi1
routes:
- routePath: '/'
_controller: 'News::list'
- routePath: '/page-{page}'
_controller: 'News::list'
_arguments:
page: '@widget_0/currentPage'
- routePath: '/{news-title}'
_controller: 'News::detail'
_arguments:
news-title: news
- routePath: '/{category-name}'
_controller: 'News::list'
_arguments:
category-name: overwriteDemand/categories
- routePath: '/{tag-name}'
_controller: 'News::list'
_arguments:
tag-name: overwriteDemand/tags
defaultController: 'News::list'
defaults:
page: '0'
aspects:
news-title:
type: PersistedAliasMapper
tableName: tx_news_domain_model_news
routeFieldName: path_segment
page:
type: StaticRangeMapper
start: '1'
end: '100'
category-name:
type: PersistedAliasMapper
tableName: sys_category
routeFieldName: slug
tag-name:
type: PersistedAliasMapper
tableName: tx_news_domain_model_tag
routeFieldName: slug
Upvotes: 0
Reputation: 796
This configuration means that EVERY page of your site must have news item title. You need to limit to a detail page pid by using limitToPages
:
routeEnhancers:
News:
limitToPages: [10]
Upvotes: 0