0

I have created a cms block in backend with the id wsmaterial. I have a modal that is created in a JavaScript file and the content for the modal should be the html from the cms block. Right now, it displays the id (wsmaterial) of the cms block, not the content.

In my features.js file:

var description = extendedOptionsConfig[option_id]['description'];
console.log(description);  // => displays 'wsmaterial'

Instead of wsmaterial I want to get the content of the block with the id wsmaterial. Something like this:

var description = <?php echo $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('wsmaterial')->toHtml();?>

Is there any way of getting the content of the cms block in JS by the identifier?

Thank you!

4
  • Do you want to call some js content/file on the html element of that backend block file? Commented Feb 27, 2019 at 9:04
  • Update the code Commented Feb 27, 2019 at 9:09
  • add code here that you tried
    – Sohel Rana
    Commented Feb 27, 2019 at 9:27
  • I have updated the question.
    – Mihaela
    Commented Feb 27, 2019 at 9:31

0

Your Answer

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

Browse other questions tagged or ask your own question.