We have four indexes for each of four languages on our site. Panelized content always gets indexed in the default language because entity languages don't get passed down through the panels/panelizer rendering stack.

The only solution I could find was to override the language_content global during the rendering of the page_manager entity.

See attached patch.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mathieuhelie created an issue. See original summary.

dsnopek’s picture

Status: Active » Needs work

Thanks! This makes senses to me

I have one bit of code review, however:

+++ b/plugins/search_api/PanelizerSearchApiAlterCallback.class.php
@@ -37,10 +37,23 @@ class PanelizerSearchApiAlterCallback extends SearchApiAbstractAlterCallback {
+        // Restore the language_content global if it was overridden.
+        if(isset($original_language_content)) {
+          $language_content = $original_language_content;
+        }
       }

This should be done outside of the try/catch block so that the global language is stored even when an exception in thrown. In fact, I'd move all of the language manipulation stuff to be outside of the try/catch block, and just leave the rendering inside.

DamienMcKenna’s picture

Agreed with what dsnopek said, also the if() statements need a space after the "if" word to match the Drupal coding standards.

clairedesbois@gmail.com’s picture

I modified the patch to do the corrections

clairedesbois@gmail.com’s picture

Status: Needs work » Needs review
dsnopek’s picture

Thanks! I haven't tested this, but the code looks good to me.

DamienMcKenna’s picture

Status: Needs review » Fixed
Parent issue: » #2155813: Plan for Panelizer 7.x-3.2 release

Thanks for the improvements, I've committed this.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.