0

i have a multi language Magento2 Store and i have CMS static blocks in home page , so to translate these blocks i had to duplicate each block and change store view to En or Ar for each block to show in En or Ar Store View only But after doing that and adding the blocks in cms_index_index.xml i found no blocks showing in the Ar Store View

so here i have the code for adding blocks,Both of En and Ar Blocks

  <container name="alert.block" htmlTag="div" htmlClass="alert show" after="subscribe.block">
    <block class="Nobles\Core\Block\Alert" cacheable="false" name="alert-block">
      <arguments>
        <argument name="block_id" xsi:type="string">alert-block</argument>
      </arguments>
    </block>
  </container>

  <container name="alert.block" htmlTag="div" htmlClass="alert show" after="subscribe.block">
    <block class="Nobles\Core\Block\Alert" cacheable="false" name="alert-block-en">
      <arguments>
        <argument name="block_id" xsi:type="string">alert-block-en</argument>
      </arguments>
    </block>
  </container>

and here is the settings for the block that doesn't show Ar-Block-Settings

0

i just found the issue with my code , i was adding blocks but did not change container name so Magento displayed the last block only and ignored the first so here what i changed

  <container name="alert.block" htmlTag="div" htmlClass="alert show" after="subscribe.block">
    <block class="Nobles\Core\Block\Alert" cacheable="false" name="alert-block">
      <arguments>
        <argument name="block_id" xsi:type="string">alert-block</argument>
      </arguments>
    </block>
  </container>

  <container name="alert.block.en" htmlTag="div" htmlClass="alert show" after="subscribe.block">
    <block class="Nobles\Core\Block\Alert" cacheable="false" name="alert-block-en">
      <arguments>
        <argument name="block_id" xsi:type="string">alert-block-en</argument>
      </arguments>
    </block>
  </container>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.