Jump to content

Multi Language with PageBuilder


Yipper
 Share

Recommended Posts

Just getting into PageBuilder (and still figuring out PW in general).

Where I was stuck currently is how the get the blocks working with multilingual fields.

For example I simply wanted to have the /RockPageBuilder/blocks/Text example block to show the TinyMCE Inline field as Multilanguage Textarea.

// from RockPageBuilder/blocks/Text/Text.php..
public function migrate()
  {
    $rm = $this->rockmigrations();
    $rm->migrate([
      'fields' => [
        self::field_text => [
          'type' => 'textarea',
          'inputfieldClass' => 'InputfieldTinyMCE',
          'contentType' => FieldtypeTextarea::contentTypeHTML,
          'label' => 'Text',
          'rows' => 5,
          'icon' => 'align-left',
          'inlineMode' => true,
          // 'rpb-nolabel' => true, // hide label in backend
          'settingsFile' => '/site/modules/RockMigrations/TinyMCE/text.json',
          'textformatters' => [
            'TextformatterRockFrontend',
          ],
        ],
      ],
      'templates' => [
        $this->getTplName() => [
          'fields' => [
            RockPageBuilder::field_eyebrow,
            'title' => [
              'label' => 'Headline',
              'icon' => 'header',
            ],
            self::field_text,
          ],
        ],
      ],
    ]);
  }

in the Accordion example block is the easy solution:

'type' => $this->wire->languages ? 'textareaLanguage' : 'textarea',

Maybe this should be in every example block and in the vs code snippets, cause that would've saved me some time.

Link to comment
Share on other sites

Hi @Yipper thx for the info!

I have updated all example blocks like this:

  public function migrate()
  {
    $rm = $this->rockmigrations();
    $rm->migrate([
      'fields' => [
        self::field_text => [
          'type' => 'textarea', // or textareaLanguage
          'inputfieldClass' => 'InputfieldTinyMCE',
          ...

Will be part of the next release!

  • Like 1
Link to comment
Share on other sites

6 minutes ago, bernhard said:
 'type' => 'textarea', // or textareaLanguage

but wouldn't the more dynamic solution from the accordion template be more versatile? That way you wouldn't even have to touch the demo block phps to have it when u activated pw language.

  • Thanks 1
Link to comment
Share on other sites

Well... it has Pro's and Con's I guess. For example if you wanted those fields to be textarea (single Language), but then you install language support later that would mean RockMigrations will change the field's type, which might not be intended. But I guess you are right in this case that it's the more likely situation that those fields should be multilang when languages are enabled. I have updated the blocks to use the dynamic version.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...