I am trying to get the my custom module on front end from database but it not showing any thing but just the blank module page:
My controller:
<?php
class OptFirst_ReviewMyCompany_IndexController extends Mage_Core_Controller_Front_Action{
public function IndexAction() {
$this->loadLayout();
$this->getLayout()->getBlock("head")->setTitle($this->__("Reviews"));
$breadcrumbs = $this->getLayout()->getBlock("breadcrumbs");
$breadcrumbs->addCrumb("home", array(
"label" => $this->__("Home Page"),
"title" => $this->__("Home Page"),
"link" => Mage::getBaseUrl()
));
$breadcrumbs->addCrumb("titlename", array(
"label" => $this->__("Reviews"),
"title" => $this->__("Reviews")
));
$this->renderLayout();
}
}
Here is my block :
<?php
class OptFirst_ReviewMyCompany_Block_Index extends Mage_Core_Block_Template
{
public function index()
{
$productId = 1;//change to your product id
$collection = Mage::getModel('optfirst_reviewmycompany/new_optfirst_reviewmycompany')->getCollection()
->addFieldToFilter('id_optfirst_reviewmycompany', $productId);
return $collection;
}
}
And this is my module template:
<?php
$collection = $this->index();
print_r($collection);
foreach ($collection as $instance) {
echo $instance['facebook'].'<br>';
/* you can customize code here */
}
?>
layout Node review.xml
<? xml version = "1.0" ?>
<layout version="0.1.0">
<reviews_index_index>
<reference name="root">
<action method="setTemplate"><template>page/1column.phtml</template></action>
</reference>
<reference name="content">
<block type="reviews/index" name="reviews_index" template="reviews/index.phtml"/>
</reference>
</reviews_index_index>
</layout>
here is the front-end template:
Anyone can look and let me know what is the issue:
Thanks!