Giter Site home page Giter Site logo

Comments (11)

nandorstanko avatar nandorstanko commented on July 17, 2024 1

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.

dbu avatar dbu commented on July 17, 2024

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.

dbu avatar dbu commented on July 17, 2024

@Aaike ping

from routing.

Aaike avatar Aaike commented on July 17, 2024

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.

dbu avatar dbu commented on July 17, 2024

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.

hason avatar hason commented on July 17, 2024

@dbu What is status of this feature?

from routing.

dbu avatar dbu commented on July 17, 2024

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.

nandorstanko avatar nandorstanko commented on July 17, 2024

@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.

dbu avatar dbu commented on July 17, 2024

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.

nandorstanko avatar nandorstanko commented on July 17, 2024

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.

dbu avatar dbu commented on July 17, 2024

/ 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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.