2

I have a custom module admin side created by me via an extension of module creator.

My module has some fields and one field is type editor i.e. the field having WYSIWYG editor. I want to fetch its data whatever it contains Image or Text or Both and show it in a pop.

Data Stored in database like :

<img src="{{media url="wysiwyg/test-image.jpg"}}" alt="" />
Welcome to our store.

Let me suggest how can I achieve this.

2

You can get data using following code:

$collection = Mage::getModel('namespace_module/tablename')->getCollection();

foreach($collection as $_data){

    // do your job here 
}

Or use direct mysql query:

$read = Mage::getSingleton('core/resource')->getConnection('core_read');
$sql = "select * from table_name";
$result = $read->fetchAll($sql);
foreach($result as $_data){

    // do your job here 
}

Here is the way to print short code of text area :

<?php echo Mage::helper('cms')->getBlockTemplateProcessor()->filter($yourContent); ?>
| improve this answer | |
  • Its working, Thanks.. I also use this but In wrong way. – Yogita Jan 25 '17 at 10:27
2

To call data in frontend you can simply call your model

If you have Specific ID

$model = Mage::getModel('custom/custom_model')->load('id');
$model->getFieldName(); 
//or
$model->getData('field_name');

If You want to call Collection

$collection = Mage::getModel('custom/custom_model')->getCollection();
foreach($collection as $row){
     $row->getFieldName()
}

In Case Of WYSIWYG Editor Data You need to proccess the data first

$wysiwygData = $model->getFieldName();
$htmlContent = Mage::helper('cms')->getPageTemplateProcessor()->filter($wysiwygData);
echo $htmlContent;
| improve this answer | |

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.