Problem
Creating a multilingual site where the client would like a separate panels page for each individual language is not currently possible. Clicking on translate page and adding a translation is not working. Creating a page variant with language condition is also not possible.
Solution
Add the current interface language as a selection condition to the panels variant (via issue #2765587) . This way you can create a panels page with different variants with a selection condition for each language.
The patch adds the language_interface context to the page variant when the onPageContext event fires. So the patch works only when creating new page variants and not editing old variants. You also need to add a "Language" Selection critera with the correct language selected.
Possible issue
This patch works with the EventSubscribers but the move to ContextProviders issue #2511596 could invalidate this patch. But the need for multilingual panels pages is large enough to warrant quick patching. When the move to ContextProviders is done, a new patch should be created asap.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | issue-2770653.patch | 3.23 KB | dkarso |
Comments
Comment #2
dkarso commentedComment #3
criscomApplying the patch makes page_manager unusable (WSOD).
Uncaught PHP Exception Symfony\\Component\\DependencyInjection\\Exception\\ServiceNotFoundException: "You have requested a non-existent service "page_manager.context_mapper"." at /core/lib/Drupal/Component/DependencyInjection/Container.php line 157, referer: http://dev.local/de/admin/structure/page_managerUsing page_manager 8.x-1.0-alpha23+13-dev and panels 8.x-3.0-beta4+45-dev
Obviously I am crashing into ContextProviders issue #2511596
Comment #4
criscomAgainst what dev version of page_manager does this patch apply?
Comment #5
laravz commentedThe patch applies to the 8.x-1.0-alpha23 version.
Comment #6
berdirPatches have to apply to the latest dev, otherwise they can't be committed. You can keep using the old patch if you use that with composer/drush make, but it needs a reroll then.
Comment #7
criscomI managed to apply your patch. I can also see a Language reference context (but no language interface). Not sure what string to insert into "Set a context value". Therefore I am also not able to add a "Language" Selection critera with the correct language selected in the "Selection criteria" settings.
Obviously I am screwing things up here. Could you elaborate on how to create a multilingual panel?
Comment #8
criscomHoly cow - clearing cache fixed it. I can see now a Language item under Selection criteria.
Comment #9
criscomYour patch works great! No issues so far. For anyone applying the patch, clear cache!!!
Comment #10
laravz commentedAre you using the latest dev versions of page_manager and panels? If so, then the patch may actually be added to the module.
Comment #11
sylus commentedThe patch applies to master the same as it applies to 8.x-1.0-alpha23 version in that it just creates a new folder with files.
Setting back to needs review. ^_^
Comment #12
dkarso commentedThe patch works in the current page_manager 8.x-1.x-dev branch with Panels 8.x-3.x-dev and Ctools 8.x-3.x-dev because the ContextProvider changes have not been applied yet in page_manager. We also have it running with Panels 8.x-3.0-beta4 and Page Manager 8.x-1.0-alpha23 and Ctools 8.x-3.0-alpha26. The patch does not do much but add in the new context. The combination of versions of panels, page_manager and ctools are also important.
Also clear cache, and recreate the page variant. Delete it first and rebuild it. It should show the added language context in the new wizard interface. Do not forget to checkmark the values Optional features Selection criteria & Context when creating the new variant. When in the condition screen add the "Language" condition.
@sylus: wrong issue patch? You need to apply https://www.drupal.org/files/issues/issue-2770653.patch
Comment #13
sylus commentedAh yeah sorry I was trying that issue as well; your right should be:
Comment #14
dkarso commentedClosing this duplicate and continuing to https://www.drupal.org/node/2633052#comment-11478101
Comment #15
dkarso commented