Speaking urls in Ext:news with multiple plugins - symfony

I have a problem with the site configuration of news when there are two news plugins on one page (TYPO3 v9.5.20). There is a list view and a tag list as navigation for the tags ([screenshot1][1]). In the list view I am able to click on tags and only news with these tags are displayed. This works and the URLs fit. So everything is ok.
But if I activate the tag list plugin I get an error ([screenshot2][2]): The controller "News" is not allowed by plugin "Pi1". Please check for TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin() in your ext_localconf.php.
The site configuration in config.yaml looks like this:
routeEnhancers:
News:
type: Extbase
limitToPages:
- 141
- 142
extension: News
plugin: Pi1
routes:
- 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
[1]: https://i.stack.imgur.com/LsFux.png
[2]: https://i.stack.imgur.com/H2IZn.png

Related

Notice: Undefined index: path in Drupal\Core\Routing\

I made a module in Drupal 8 and after i add the routing i got a notice in log messages telling:
Notice: Undefined index: path in Drupal\Core\Routing\RouteBuilder->rebuild() (line 172 of /home/...
my module routing.yml looks like this:
---
mymodule.mypage:
path: /mypage
defaults:
_controller: Drupal\mymodule\Controller\MyPageController::customPage
_title: My custom page
requirements:
_role: anonymous
Accesing the page i got this message:
Access denied
You are not authorized to access this page.
Looks like wrong indentation to me. And maybe don't check for a role but the access content permission.
mymodule.mypage:
path: '/mypage'
defaults:
_controller: 'Drupal\mymodule\Controller\MyPageController::customPage'
_title: 'My custom page'
requirements:
_permission: 'access content'

Optional text on Symfony router

I'm trying something with the Symfony router but I cannot achieve what I'm aiming to.
Indeed I want to add an optional text to this path, especially for the /page-{page}. So I'm asking if it's possible to have two possibilities for the same router path, like the following ones:
/topic/{id}
/topic/{id}/page-{page}
routing.yml:
utm_forum_forum:
path: /forum/{id}/page-{page}
defaults:
_controller: UTMForumBundle:Forum:forum
page: 1
requirements:
id: \d+
page: \d+
Thanks for reading, and if I'm not clear enough I can re-explain :)
You need to include routes for all possible configurations.
So, if your page slug is optional, your route table should look something like:
utm_forum_forum_default:
path: /forum/{id}
defaults:
_controller: UTMForumBundle:Forum:forum
page: 1
requirements:
id: \d+
utm_forum_forum:
path: /forum/{id}/page-{page}
defaults:
_controller: UTMForumBundle:Forum:forum
requirements:
id: \d+
page: \d+
That should provide a default value of page 1 when the page slug is omitted entirely, or require something in the form page-N after the ID.
utm_forum_forum:
path: /forum/{id}/page-{page}
defaults: { _controller: UTMForumBundle:Forum:forum, page: null }
so if you request for /forum/15/page- will give you null in {page} parameter.
Don't know if its what you need

URL based on locale

Is it possible to change URL when locale is changed?
This is my route:
contact:
path: /{type}
defaults: { _controller: WebPortalBundle:Default:contact }
requirements:
type: kontakty|contact
Is it possible when locale is "en" to display url with type = contact, when russian, czech, slovak, display with type = kontaky ?
Yes, it's possible. We are using https://github.com/BeSimple/BeSimpleI18nRoutingBundle that bundle for doing that.
After installation bundle you need to open config.yml file and add this config.
be_simple_i18n_routing: ~
After that open your main routing.yml file(app/routing.yml) and simply add type "be_simple_i18n". It's shoud be like that.
acme:
resource: "#AcmeBundle/Resources/config/routing.yml"
prefix: /
type: be_simple_i18n
And finally open bundle spesific routing.yml file (in that case AcmeBundle/Resources/config/routing.yml).
acme_contact:
path: /
defaults: { _controller: AcmeBundle:Default:contact }
locales: { en: "/contact", ru: "/kontaky" }

Symfony2 routing - slug with slashes and pagination

I use Symfony2 and have structure of categories and subcategories with articles in them. In the lists I use pagination.
If I call a URL like 'category1-slug/4' it works fine and opens a page 4 of the list with articles in Category 1.
But if I want to use a slug like "category1/subcategory3/4", it returns 404, because it takes the whole string as slug - "category1/subcategory3/4".
How should I configure my routing? I want the last digit to be taken for page number. My current definition is:
app_article_category:
path: /articles/{slug}{trailingSlash}{page}
defaults: { _controller: CmsArticleBundle:AppArticle:showItem, page: 1, trailingSlash:"/"}
requirements:
page: \d+
trailingSlash : "[/]{0,1}"
slug: .*$
adding a new route, before the existing one, should do the job :
app_article_category_subcategory:
path: /articles/{slug_cat}{trailingSlash}{slug_subcat}{trailingSlash}{page}
defaults: { _controller: CmsArticleBundle:AppArticle:showItem, page: 1, trailingSlash:"/"}
requirements:
page: \d+
trailingSlash : "[/]{0,1}"
slug_cat: .*$
slug_cat: .*$

Symfony2 - Parent routes read instead

I am working on Symfony2 project in which a kind of general bundle, let say CoreBundle, is managing all the routes (in this form, first.domain/a-route, second.domain/a-route, third.domain/a-route,...) of the website. Now I have been creating FirstBundle, SecondBundle, ThirdBundle with the idea to "transfer" the management of routes of each subdomain (firt, second, third,...) to the related bundle.
Beginning with the transfer of routes from CoreBundle to FirstBundle by editing /app/config/routing.yml file from:
resource: "#ProjectFirstBundle/Resources/config/routing.yml"
prefix: /
host: "{subdomain}.{domain}"
defaults: { _controller: ProjectFirstBundle:Public:aroute }
domain: %project_domain%
requirements:
domain: "%project_domain%"
subdomain: 'first'
to:
project_first_aroute:
path: /a-route
host: "{subdomain}.{domain}"
defaults: { _controller: ProjectFirstBundle:Public:aroute, domain: "%project_domain%" }
requirements:
domain: "%project_domain%"
subdomain: 'first'
And of course I have created controller and view files using the same schema as CoreBundle (by making an adaptation -- inheritance for .twig files).
Now the problem is only parent route (that is CoreBunble /a-route route) is being read when running the URL first.domain/a-route.
Any suggestions?

Resources