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?

asked Jan 24, 2017 at 12:02
0

1 Answer 1

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

answered Jan 24, 2017 at 12:48

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.