Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: add optional query parameters #1

Open
bartwttewaall opened this issue May 4, 2021 · 0 comments
Open

Suggestion: add optional query parameters #1

bartwttewaall opened this issue May 4, 2021 · 0 comments

Comments

@bartwttewaall
Copy link

Hi there, thank you for writing this plugin! It's been a great help with routing for multilingual websites.
I'd like to suggest an addition: the same approach for optional query parameters.

routes.php

return [
  'english' => [
    'customer/order/<orderId:\d+>?<status:\w+>&<error:\w+>' => [
      'template' => 'customer/order', 'name' => 'customerOrder'
    ]
  ],
  'dutch' => [
    'klant/bestelling/<orderId:\d+>?<status:\w+>&<error:\w+>' => [
      'template' => 'customer/order', 'name' => 'customerOrder'
    ]
  ]
]

template.twig

{{ craft.namedRoutes.getUrl('customerOrder', { orderId: 1234, status: 'paid', error: null }) }}

This would result to:

  • English: customer/order/1234?status=paid
  • Dutch: klant/bestelling/1234?status=paid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant