0
<block class="Magento\Store\Block\Switcher" name="store_language" as="store_language" template="Magento_Store::switch/languages.phtml">
<arguments>
<argument name="view_model" xsi:type="object">Magento\Store\ViewModel\SwitcherUrlProvider</argument>
</arguments>
</block>

I just want to call the above block via Static block (From Admin), but it gives an error due to ViewModel class.

I don't know how to pass view model argument when we call block via static block

Does anyone have any idea?

1 Answer 1

1

You cannot set object as arguments when using the Markup Notation in Magento2.

{{block class="Magento\Framework\View\Element\Template" view_model="Vendor\Example\ViewModel\Standard" name="Vendor_Example::view.phtml" }}

In view.phtml

If you execute echo $block->getViewModel() will return Vendor\Example\ViewModel\Standard as a string and not an object.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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