I have created a custom module in Magento. The idea of the module is to provide the ability to report a product.
I have configured the front end and that is all working fine.
The basic idea is that you click on a link on a product page which then reports the product (it adds a row to a report
table, containing the following columns: report_id
, product_id
& status
).
I'm now onto creating the back end for the module. For this, I have added a menu item under "Catalog > Reported Products".
When I click on the link, it goes to a blank page (it has the admin header and footer, so my controller is set up correctly).
What I'm stuck on is adding a block to manage the admin side of things. For the front end, I have a block "Tbe/Report/Block/Report.php" and, it works perfectly. I just can't seem to do the same for the admin side of things.
I would then like to be able to actually add some kind of list to the admin area to display the products that have been reported.
Tutorials on this subject seem to be very hard to come by and I really have no idea of the best practices when it comes to creating a layout for the admin section.
Here's what I have so far:
**app/code/core/local/Tbe/Report/Block/Adminhtml/Report.php
class Tbe_Report_Block_Adminhtml_Report extends Mage_Adminhtml_Block_Template {
public function __construct(){
echo "BLOCK HAS BEEN INCLUDED!";
die();
parent::_construct();
}
}
app/code/core/local/Tbe/Report/controllers/Adminhtml/ReportedController.php
class Tbe_Report_Adminhtml_ReportedController extends Mage_Adminhtml_Controller_Action {
public function indexAction() {
$this->loadLayout();
$this->renderLayout();
}
}
app/code/core/local/Tbe/Report/etc/config.xml
<config>
...
<global>
...
<blocks>
<report>
<class>Tbe_Report_Block</class>
</report>
</blocks>
...
</global>
...
<admin>
<routers>
<adminhtml>
<args>
<modules>
<Tbe_Report after="Mage_Adminhtml">Tbe_Report_Adminhtml</Tbe_Report>
</modules>
</args>
</adminhtml>
</routers>
</admin>
</config>
Like I said, tutorials on this appear to be in short, so if you know of any tutorials which could help, please let me know.
Cheers
UPDATE
I have changed config.xml to look like this:
<config>
...
<adminhtml>
<layout>
<updates>
<report>
<file>tbe_report.xml</file>
</report>
</updates>
</layout>
</adminhtml>
<admin>
<routers>
<adminhtml>
<args>
<modules>
<Tbe_Report after="Mage_Adminhtml">Tbe_Report_Adminhtml</Tbe_Report>
</modules>
</args>
</adminhtml>
</routers>
</admin>
</config>
I have also add the file "app/design/adminhtml/default/default/layout/tbe_report.xml"
<layout>
<tbe_report_adminhtml> <!-- I have also tried "tbe_report_adminhtml_index" and "tbe_report_index" -->
<reference name="head">
<action method="addCss"><stylesheet>report/css/report1.css</stylesheet></action>
</reference>
</tbe_report_adminhtml>
</layout>
Am I right in thinking I should have an error in the console "File not found" for the stylesheet report/css/report1.css. I do not have any sort of error and neither is it in resources.