0
votes

I’d like to add a custom field to my CMS pages which allows someone using the admin panel to upload and specify an image of their choice to appear as a banner on the page. I would set where this image appears in the template. Has anyone come across this functionality or have any recommendations on where to begin?

I am running 1.3.x and I have read that 1.4 has nicer tinyMCE features, so I imagine this will be easier with an upgrade, is that true? Anyone have any experience with richer CMS like this for Magento? I am hoping to find a solution similar to the way Custom Fields and Write Panels work in Wordpress.

1

1 Answers

1
votes

The first solution which I could suggest is to create custom widget. Widgets are special kind of blocks which could be added to your CMS content - both pages and static blocks.

To create new widget first of all you should create new block in your module

class Yourcompany_Yourmodule_Block_Upload 
  extends Mage_Core_Block_Template
    implements Mage_Widget_Block_Interface

After that you should create widget.xml file in your module's etc directory

<widgets>
  <yourcompany_yourmodule type="yourcompany_yourmodule/upload">
    <name>File Uploader</name>
    <description type="desc">Widget for files' uploading</description>
    <parameters>
        <template>
            <required>0</required>
            <visible>0</visible>
            <label>Template</label>
            <type>upload</type>
            <value>yourmodule/upload.phtml</value>
        </template>
    </parameters>
</yourcompany_yourmodule></widgets>

After doing this steps and flushing cache new widget should be visible in widget selector of your cms content - there is a button "insert widget" in WYSIWYG.