Comments (11)
I guess I've figured this out now. The "problem" was, as you mentioned, that the root is a generic node, and not a Route node. With a custom initializer it is possible to change that. At the moment I've just added a home action to my default controller, which reads out the home content document, but I will try that more elegant solution also. Huge thanks for the help, and I think that a lot of people will learn from this conversation.
from routing.
i agree that this should be supported.
looking at https://github.com/symfony-cmf/Routing/blob/master/Candidates/Candidates.php#L84-L95 i wonder if there even is anything missing to do that. what are you missing exactly? a listener that sets the locale to a default locale if the route is not under one of the locales? see also https://github.com/symfony-cmf/Routing/blob/master/Candidates/Candidates.php#L19-L20
from routing.
@Aaike ping
from routing.
yes sry :) have had a lot of work lately.
This question came up the last time (and first time) i tried playing with the symfony cmf.
i think i was following this document : http://symfony.com/doc/current/cmf/book/handling_multilang.html
it was probably the routing-auto-bundle that was adding the locale prefixes for every language, and i couldn't find an option to exclude the default language from the url.
i had to drop the cmf in my project because i couldn't configure it all in time according to the client's specifications.
anyway please leave this issue at the moment. i will try to really look at it again after this project is done :)
Should i close the issue for now ? or can i leave it open until i got some time to get back to it ?
from routing.
i'd say we leave it open. i appreciate if you can re-visit that and test
it and provide feedback, maybe improve the doc or have an improvement
for RoutingAutoBundle
from routing.
@dbu What is status of this feature?
from routing.
i am not aware of anything having been done. i think its mainly a documentation topic. the candidates strategy that looks for routes looks for both routes with and without the locale: https://github.com/symfony-cmf/Routing/blob/master/Candidates/Candidates.php#L89-L92
symfony will set the default locale if no locale comes out of the routing. so i would assume that nothing is missing. if it does not already work, please open a new issue and describe what you try to do and what does not work. (ah, if you try to make this happen with RoutingAuto i guess you would need something more - that would be an issue for https://github.com/symfony-cmf/RoutingAuto )
from routing.
@dbu Do you have some additional info on this one? I'm not sure is this a RoutingAuto issue or not, just found this open issue, probably it is related to my problem: symfony-cmf/routing-auto#77
Basically I would want to achieve this:
somedomain.com - get homepage for default locale, without redirecting to somedomain.com/en
somedomain.com/about - get about page for default locale, without redirecting to somedomain.com/en/about
somedomain.com/de - get homepage for german locale
Maybe it's just a config issue, but I really don't know how to put all the pieces together...
from routing.
hi @nandorstanko, symfony-cmf/routing-auto#77 has nothing to do with what you are asking. it seems to be a limitation of the routing auto pattern. with the cmf router itself, / will find the root node of the routes tree. if that itself is a valid route, it works just fine.
for your question, i think all that is needed is storing the routes in the right location. the url is translated to a repository path. if you have routes at /cms/routes, /cms/routes/about and /cms/routes/de your scenario should work.
are you using the routing auto or creating routes in an admin interface or with custom scripts? see also https://github.com/symfony-cmf/Routing/blob/master/Candidates/Candidates.php#L89-L92 for how potentially matching routes are loaded.
from routing.
Hi @dbu! First, thank you for the response.
I'm creating the routes in an admin interface, basically the same way as in cmf-sandbox. I've figured out how to solve the routes for /about and /de/about, but still don't know how to get the route for the homepage content. In the cmf routing admin I can only add routes to some named nodes, like /en or /home. In the sandbox routing config there is a locale switcher which automatically redirects the / path to /en, but this is not the right way for me...
https://github.com/symfony-cmf/cmf-sandbox/blob/master/app/config/routing.yml#L10-L16
Probably there is some routing config combo where I can proxy the / to my /home route, but no success for me yet. I guess there is a simple solution for this, so if you have an idea, please share it with me :) Thanks!
from routing.
/
is the root node of the routes. if you configure nothing in routing.yml, you can use the document that is in phpcr. the routing bundle by default uses an initializer to place a generic node at the route root so that you can use that in sonata admin: https://github.com/symfony-cmf/routing-bundle/blob/master/src/Resources/config/initializer-phpcr.xml
i think the easiest way is to set enable_initializer: false
in the routing bundle configuration and provide your own initializer to create a Route document that you store at the route root instead. i think that will also make the root route node show up in sonata.
from routing.
Related Issues (20)
- Create content_on_method enhancer HOT 28
- Issues with conditional enhancer HOT 4
- No Deprication HOT 5
- New File Structure
- Upgrade File
- The router fails to match unicode uri HOT 5
- Attempted to load interface "ChainedRouterInterface" from namespace "Symfony\Cmf\Component\Routing". HOT 5
- Candidates::determineLocale regex matches wrongly HOT 4
- Does dynamic router works on application redirects? HOT 2
- Print dynamic routes on router:debug HOT 2
- Uninitialised requestContext leads to "Call to a member function setParameter() on null -- in LocaleListener.php" HOT 1
- fix latest 1.x HOT 1
- Wrong type hint for ChainRouter::generate HOT 3
- Redirect routes with trailing slash HOT 7
- Symfony Route is not loaded from dumped file HOT 2
- User Deprecated: Since symfony/event-dispatcher 5.1: Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy is deprecated, use the event dispatcher without the proxy. HOT 3
- split into symfony-cmf/chain-router and symfony-cmf/dynamic-router HOT 4
- simplify the dynamic router HOT 4
- TypeError for LazyRouteCollection::all() when inner route provider returns generator from getRoutesByNames() HOT 1
- Potential security issue HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from routing.