Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Page manager should allow variants selection depending on current language
Proposed resolution
Add language context to reuse language module provided condition
Remaining tasks
Add tests
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#25 | 2633052-pm-22.patch | 4.42 KB | andypost |
#25 | interdiff.txt | 4.09 KB | andypost |
#18 | issue-2633052-2.patch | 5.17 KB | dkarso |
Comments
Comment #2
andypostThat should be enough
Comment #4
andypostComment #5
andypostComment #6
swentel CreditAttribution: swentel commentedWorks fine here - RTBC for me.
Comment #7
tim.plunkettUnfortunately we just changed PageManagerContextEvent, delete the "Executable" part.
Comment #8
tim.plunkettAlso please add tests
Comment #9
andypostfixed patch, but looking at
\Drupal\Tests\page_manager\Unit\CurrentUserContextTest
no idea how to write test properlyComment #10
tim.plunkettWe have no mechanism to reuse core context providers yet, but why duplicate their code anyway? We could just do this.
Or make this a more generic issue to reuse all core context providers instead of waiting for #2511568: Create "context stack" service where available contexts can be registered
Comment #11
andypostIt would be great to have all core contexts available but please keep scope of language, cos this is a blocker for multilingual sites
nice idea, but there's no cache dependencies set...
Comment #12
tim.plunkettTaking my suggestions to #2511596: Switch from EventSubscribers to core-style ContextProviders.
Can you explain the differences between the core CurrentLanguageContext and this one?
Comment #13
tim.plunkettComment #14
Wim LeersCurrent interface language? Content language? URL language?
i.e.
\Drupal\Core\Language\LanguageInterface::TYPE_INTERFACE
vs\Drupal\Core\Language\LanguageInterface::TYPE_CONTENT
vs\Drupal\Core\Language\LanguageInterface::TYPE_URL
See
\Drupal\Core\Cache\Context\LanguagesCacheContext
which also needs to make this distinction.Comment #15
fluxline CreditAttribution: fluxline commentednot trying to hyjak the issue, but trying to solve the issue of language and path. please let me know if i should open another issue.
using as is, the path is given for the entire page entity. if 2 variants are created based on language, and a variant is selected based on role/url/content, the path is still fixed to one the one entered for the page. could the variant set the path? it will still be an issue for menus only having 1 path regardless if there is a translation or not, but that is less wok to solve.
still new to d8 so maybe i'm missing something.
Comment #16
dkarso CreditAttribution: dkarso as a volunteer commentedContinued from issue#2770653 to get this change request moving.
My patch holds the context class LanguageInterfaceContext event subscriber and loads the language_interface context from the LazyContextRepository.
The patch also contains a unit test for the LanguageInterfaceContext class.
@fluxline. We set the panels page path to a node id (eg: /node/503) and the node is translatable, and the page variant condition based on language (not path). The alias of the node gets requested and the variant gets loaded based on the node. We compose a single wegpage with node content with page variant content this way.
Comment #17
dkarso CreditAttribution: dkarso as a volunteer commentedComment #18
dkarso CreditAttribution: dkarso as a volunteer commentedProper patch file now. Other patch holds wrong paths.
Comment #19
criscomPatch in #18 works for me. Thanks!
Comment #20
andypostAnd covered with tests
Comment #21
japerryhmm I'm having trouble getting this patch to show up. Applies cleanly, but is not showing up in the selection criteria. Has this been tested on recent head?
Comment #23
sylus CreditAttribution: sylus commentedThis applied and worked for me correctly ^_^.
Additionally recent head is currently the stable tag 1.0-alpha4.
Possible to check again?
Comment #24
andypostpatch applies cleanly and works
Comment #25
andypostClean-up code to follow code styles
Btw this issue should wait for #2511596: Switch from EventSubscribers to core-style ContextProviders
Comment #26
DamienMcKennaComment #28
japerryI've been using this in production for a while and it works well. Because #2511596: Switch from EventSubscribers to core-style ContextProviders is fairly stalled, gonna commit this now.
Comment #30
SKAUGHTlinking