Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In Magento 1, if you wanted to transform an arbitrary block of text, the same as the body of a CMS page or block might be changed, you could use the following model class

Mage::getModel('cms/template');

This object was also available via the CMS data helper's getBlockTemplateProcessor method.

Mage::helper('cms')->getBlockTemplateProcessor();

In Magento 2, there is no CMS data helper object. There is also no CMS template object.

In Magento 2, if I want to transform an arbitrary string as through it were a CMS page or CMS block, how would I do that?

share|improve this question
up vote 4 down vote accepted

if I understand you correctly, you can do this with the

Magento\Cms\Model\Template\FilterProvider

if you want to "filter" a string with cms "objects" it should be working like this:

return $this->filterProvider->getBlockFilter()
        ->setStoreId($this->storeManager->getStore()->getId())
        ->filter($yourString);

hope I understood your question right :X

share|improve this answer
    
Yup, that's the class I was looking for. Thank you for saving me the code glopping! :) – Alan Storm Feb 10 at 21:26
    
Wow, done without a single static method. – Buttle Butkus Feb 11 at 4:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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