International in Country Switcher

Created on 14 March 2025, about 1 month ago

Problem/Motivation

It's probably more like a feature request. What is the current suggested way to use the international feature? The Country Switcher doesn't allow to select the "international" country, only the specific ones. I suppose the correct way would be to add a config checkbox to the switcher block that allows it to automatically prepend "International" to the existing countries and make it point to the path without the prefix?

I'd probably add this myself and offer up as a PR, of course, if you think this is a viable approach in the long run.

Feature request
Status

Active

Version

1.0

Component

User interface

Created by

🇭🇺Hungary djg_tram

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @djg_tram
  • 🇭🇺Hungary djg_tram

    First, quick attempt but it seems to work for me now. Could you take a look before I create a MR?

  • 🇩🇪Germany simonbaese Berlin

    Yes, this could be added to the block configuration.

    I also see a CountryChangeEvent in your branch. This probably would not make it into the module. The idea is that the current country is set very early during the request (see CountryEventSubscriber) and then is immutable. If you have sound reasoning for this, please describe the use case.

  • 🇭🇺Hungary djg_tram

    Yes, I actually added that too because I created it in the meantime but feel free to pick.

    My actual use case is to issue a redirect to a specific page when the user changes the country (practically to go to the starting page of that country rather than staying on the same page but with a different country setting. I use a correct middleware redirect approach so it doesn't get executed immediately but gets stored in the kernel and is executed when the current request actually finishes.

    But, actually, I can achieve the same effect with using a different Country Switcher, a modified copy of yours that creates the URLs according to my specific needs. And this probably is a cleaner approach, anyway.

  • 🇩🇪Germany simonbaese Berlin

    The first approach sounds wrong. The CountryChangeEvent would fire on every request regardless of the user action. As you mentioned, I think it is better to change the block. You can extend the existing block or maybe even use hook_block_build_BASE_BLOCK_ID_alter (I haven't tried the hook).

    Can you please open a "clean" merge request with the changes regarding the International option?

  • 🇭🇺Hungary djg_tram

    I was hoping for a git revert to function but it doesn't. :-) I'll start all over again.

  • Merge request !14Resolve #3512984 "International" → (Open) created by djg_tram
  • 🇭🇺Hungary djg_tram

    I hope I didn't screw up, I'm much less familiar with this Drupal Git than with GitHub. :-))

  • Pipeline finished with Failed
    28 days ago
    Total: 170s
    #453162
Production build 0.71.5 2024