php - Magento when calling a static block's content via AJAX, images entered in CMS with {{ }} are not processed into their filename -


i trying call static block via ajax. can retrieve text fine, images not processed {{ }} template format actual image path , come accross written in cms.

{{media url="wysiwyg/groups-scenes-associations-c-296_367.jpeg"}}

this not case when reference block in cms page or phtml file, when block via ajax method.

so making request script have created, launches instance of magento, calls block html , echos out return original calling javascript - so:

script handing ajax request:

require_once('../app/mage.php');  umask(0); mage::app();  $block_identifier = 'delivery_country_' . $_get['iso_country'];  $staticblock = mage::getmodel('cms/block')->load($block_identifier); echo $staticblock->getcontent(); 

content of cms static block

<div class="delivery-panes"> <div class="delivery-left-pane"><img src="{{media url="wysiwyg/groups-scenes-associations-c-296_367.jpeg"}}" alt="" /></div> <div class="delivery-right-pane"> <h2>france</h2> <p>fr lorem ipsum dolor sit amet, consectetur adipiscing elit. aenean dignissim tempus vestibulum. quisque tempor velit sed enim hendrerit vehicula. donec egestas iaculis risus in bibendum. ut est nisi, semper ac adipiscing ut, hendrerit faucibus metus. nam mollis velit non purus congue sagittis. phasellus sit amet felis in leo ultricies vehicula sit amet nec libero. sed ultricies metus et quam scelerisque auctor. vivamus et consequat orci.</p> </div> </div> 

full response of script

<div class="delivery-left-pane"><img src="{{media url="wysiwyg/groups-scenes-associations-c-296_367.jpeg"}}" alt="" /></div> <div class="delivery-right-pane"> <h2>france</h2> <p>fr lorem ipsum dolor sit amet, consectetur adipiscing elit. aenean dignissim tempus vestibulum. quisque tempor velit sed enim hendrerit vehicula. donec egestas iaculis risus in bibendum. ut est nisi, semper ac adipiscing ut, hendrerit faucibus metus. nam mollis velit non purus congue sagittis. phasellus sit amet felis in leo ultricies vehicula sit amet nec libero. sed ultricies metus et quam scelerisque auctor. vivamus et consequat orci.</p> </div> </div> 

why in ajax approach images returned unprocessed {{ }} string above, rather being processed proper path , filename? i.e. turning {{ }} image file name.

i think happens because model doesn't have text preprocessing methods inside. if need block - use block instead:

$block_identifier = 'delivery_country_' . $_get['iso_country']; $block = mage::app()->getlayout()->createblock('cms/block')->setblockid($block_identifier); echo $block->tohtml(); 

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -