Search code examples
magentomodelmagento-1.12

What's the source_model for a cms block chooser in magento?


I want to add a config field to my magento instance. You should be able to store a cms block in it.

<block translate="label">
    <label>Cms block</label>
    <frontend_type>select</frontend_type>
    <source_model>???</source_model>
    <sort_order>30</sort_order>
    <show_in_default>1</show_in_default>
    <show_in_website>1</show_in_website>
    <show_in_store>1</show_in_store>
</block>

But I only found the model for cms pages (adminhtml/system_config_source_cms_page).

What is the corresponding source_model for cms blocks?


Solution

  • I think class Mage_Cms_Model_Resource_Block_Collection works great for this:

                        <cms_block translate="label">
                          <label>Left template CMS block</label>
                          <frontend_type>select</frontend_type>
                          <source_model>cms/resource_block_collection</source_model>
                          <sort_order>0</sort_order>     
                          <show_in_default>1</show_in_default>
                          <show_in_website>0</show_in_website>
                          <show_in_store>0</show_in_store>
                        </cms_block>