0

I created a block under CMS -> Static Blocks with the following content:

<a href="http://www.foo.com">
   <img src="{{media url="wysiwyg/email/751-footer.png"}}"/>
</a>


Unfortunately the media directive interprets to src="{{media url=" when I try to load the CMS Block via

$signaturemodel = Mage::getModel('cms/block')->load('email_signature');

$signature = $signaturemodel->hasData() ? $signaturemodel->getContent() : "";
echo $signature;

Is there any chance to get the correct media url?

2

There are different solutions depending on the context.


e.g.

// use thestatic block email_signature
$signature = '';
$block = Mage::getModel('cms/block')
    ->setStoreId(Mage::app()->getStore()->getId())
    ->load('email_signature');

if ($block->getIsActive()) {
    /* @var $helper Mage_Cms_Helper_Data */
    $helper    = Mage::helper('cms');
    $processor = $helper->getBlockTemplateProcessor();
    $signature = $processor->filter($block->getContent());
}

echo $signature;


or in a .phtml-File

echo $this->getLayout()->createBlock('cms/block')
     ->setBlockId('email_signature')
     ->toHtml();

For better understanding have a look at app/code/core/Mage/Cms/Block/Block.php

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.