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:
- if i change
settings.categoryConjunctionfromORtoAND, the list view works but logically shows wrong results - same thing happens when i change
settings.categoriesi.e when i add a complete category instead of a subcategory
Click me to see backend configuration
Conclusion:
myproject.local/somepagewithnewsworksmyproject.local/somepagewithnews/detail/articleWithSpeakingUrlworksmyproject.local/anotherpagewithnewsdoesnt workmyproject.local/anotherpagewithnews/articleWithSpeakingUrlworks. Note that there appears no/detail/in between. Adding it will result in aPage 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!!
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: