You will have to create a custom module, as you have already noted.
I can't give you the complete code, but here's an outline; if you try this and have a more specific question, just open a new one here.
app/etc/modules/Myname_Mymodule.xml
This file tells Magento that your module is there.
<?xml version="1.0"?>
<config>
<modules>
<Myname_Mymodule>
<active>true</active>
<codePool>local</codePool>
</Myname_Mymodule>
</modules>
</config>
app/code/local/Myname/Mymodule/etc/config.xml
Your module configuration that tells Magento what your module does.
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Myname_Mymodule>
<version>0.1.0</version>
</Myname_Mymodule>
</modules>
<global>
<models>
<myname_mymodule>
<class>Myname_Mymodule_Model</class>
</myname_mymodule>
</models>
<helpers>
<myname_mymodule>
<class>Myname_Mymodule_Helper</class>
</myname_mymodule>
</helpers>
</global>
<frontend>
<routers>
<myname_mymodule>
<use>standard</use>
<args>
<module>Myname_Mymodule</module>
<frontName>myname_mymodule</frontName>
</args>
</myname_mymodule>
</routers>
<layout>
<updates>
<myname_mymodule>
<file>myname_mymodule.xml</file>
</myname_mymodule>
</updates>
</layout>
</frontend>
</config>
What the config.xml actually does, is: it registers the shortnames of your helpers, models and blocks that you can use in Mage::getModel(...)
, Mage::helper(...)
and Mage::getLayout()->createBlock(...)
. It also registers a new URL (route). We will send your form there.
app/design/frontend/base/default/templates/myname_mymodule/form.phtml
Put your form here :) Send it to the URL $this->getUrl('myname_mymodule/index/save')
app/code/local/Myname/Mymodule/controllers/IndexController.php
<?php
class Myname_Mymodule_IndexController extends Mage_Core_Controller_Front_Action {
public function saveAction() {
$postData = $this->getRequest()->getPost();
// TODO validate post data
// TODO save post data to CSV file
// afterwards, show a nice message & redirect the user to the previous page
$session = Mage::getSingleton('core/session');
if($success) {
$session->addSuccess(Mage::helper('myname_mymodule')->__("IT WORKED"));
} else {
$session->addError(Mage::helper('myname_mymodule')->__("Something went wrong."));
}
$this->_redirectReferer();
}
}