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.

Comments

dkarso created an issue. See original summary.

dkarso’s picture

StatusFileSize
new3.23 KB
criscom’s picture

Applying 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_manager

Using 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

criscom’s picture

Against what dev version of page_manager does this patch apply?

laravz’s picture

The patch applies to the 8.x-1.0-alpha23 version.

berdir’s picture

Status: Needs review » Needs work

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

criscom’s picture

I 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?

criscom’s picture

Holy cow - clearing cache fixed it. I can see now a Language item under Selection criteria.

criscom’s picture

Your patch works great! No issues so far. For anyone applying the patch, clear cache!!!

laravz’s picture

Are you using the latest dev versions of page_manager and panels? If so, then the patch may actually be added to the module.

sylus’s picture

Status: Needs work » Needs review

The 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. ^_^

git clone --branch 8.x-1.x https://git.drupal.org/project/page_manager.git
wget https://www.drupal.org/files/issues/page_manager-block_content_contextual-2601004-14.patch
cd page_manager
patch -p1 < ../page_manager-block_content_contextual-2601004-14.patch
dkarso’s picture

The 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

sylus’s picture

Ah yeah sorry I was trying that issue as well; your right should be:

git clone --branch 8.x-1.x https://git.drupal.org/project/page_manager.git
wget https://www.drupal.org/files/issues/issue-2770653.patch
cd page_manager
patch -p1 < issue-2770653.patch
dkarso’s picture

Closing this duplicate and continuing to https://www.drupal.org/node/2633052#comment-11478101

dkarso’s picture

Status: Needs review » Closed (duplicate)

The last submitted patch, page_manager-languageinterface-context.patch, failed testing.