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?

migrated from meta.magento.stackexchange.com Sep 5 '14 at 19:49

This question came from our discussion, support, and feature requests site for users of the Magento e-Commerce platform.

  • Can you explain what you mean by "Table" do you mean an HTML table or SQL table? – brentwpeterson Sep 5 '14 at 19:58
  • I mean on SQL table. I want to get the content from custom SQL table instead of cms_page table. – Mike Sep 7 '14 at 21:57
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 :)

  • 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

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.