Magento is still very much a learning curve for myself but I'm trying to steer away from so much of my hard-coded, procedural PHP and start following the Magento MVC. I've set myself the task of converting a singular .phtml file that I've created a best-sellers carousel for into an extension that follows the proper MVC. Here's my code/files:
app/code/local/Liam/Interested/etc/config.xml:
<?xml version="1.0"?>
<config>
<global>
<modules>
<liam_interested>
<version>0.1.0</version>
</liam_interested>
</modules>
<blocks>
<interested>
<rewrite>
<interested>Liam_Interested_Block_Interested</interested>
</rewrite>
</interested>
</blocks>
</global>
</config>
app/code/local/Liam/Interested/Block.php:
<?php
class Liam_Interested_Block_Interested extends Mage_Core_Block_Template
{
// necessary methods
}
?>
app/etc/modules/Liam_Interested.xml:
<?xml version="1.0"?>
<config>
<modules>
<Liam_Interested>
<active>true</active>
<codePool>local</codePool>
</Liam_Interested>
</modules>
</config>
app/design/frontend/custom/default/template/interested/interested.phtml:
<?php
echo 'test';
?>
Then, in my CMS - I'm adding:
{{block type="interested/interested" name="interested_interested" template="interested/interested.phtml"}}
This was based on following a guide online, but I still can't seem to get my head around it all!