1

How can I list content in cms edit page from other table?

Which function should be overwritten?

I want to change the table where the content in wysiwyg editor is getting from another table.

How can i change this?

brentwpeterson
  • 6,104
  • 7
  • 43
  • 81
Mike
  • 455
  • 4
  • 14

1 Answers1

0

You have to first create a .phtml file anywhere inside "app/design/frontend/yourpackage/yourtheme/template", you can create phtml in any sub-directory of this folder but as you're gonna use to get custom data so put this phtml inside "page" or "catalog/product" subdirectory.

In that phtml you can use magento getSingleton object to fire a custom query to get content from custom table.

Put below code in the phtml file and save it.

<!-- language: lang-php -->
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$query = 'SELECT * FROM ' . $resource->getTableName('custom_table_name');
$results = $readConnection->fetchAll($query);

//display however you like the values of $results

And then you can call this phtml file in your CMS page as below: {{block type="core/template" template="path_to_file/filename.phtml"}} (*path_to_file with respect to template folder) (You can use any block type depending on your look-and-feel requirements). And you're all set.

Happy coding :)

Amit Bera
  • 77,456
  • 20
  • 123
  • 237
Vivek
  • 85
  • 1
  • 7
  • Even if this might work, it is a very very VERY bad practice. Please don't do it like that. It defeats the whole purpose of MVC and not only. – Marius Oct 10 '14 at 19:40