I can post my code. it's working controller and also block file but template File not working.
Sending code here.
<?xml version="1.0" ?>
<!--
/**
* Module Configuration
*
*@author Magento
-->
<config>
<modules>
<Magentostudy_News>
<version>1.0.0</version>
</Magentostudy_News>
</modules>
<frontend>
<routers>
<magentostudy_news>
<use>standard</use>
<args>
<module>Magentostudy_News</module>
<frontName>news</frontName>
</args>
</magentostudy_news>
</routers>
</frontend>
<layout>
<updates>
<magentostudy_news>
<file>news.xml</file>
</magentostudy_news>
</updates>
</layout>
<global>
<blocks>
<news><class>Magentostudy_News_Block</class></news>
</blocks>
</global>
</config>
My news.xml file
<layout version="0.1.0">
<default>
<reference name="content"></reference>
</default>
<news_index_index>
<reference name="content">
<block type="news/news" name="news.slider" template="news/news.phtml"></block>
</reference>
</news_index_index>
<layout>
This is My controller file
<?php
class Magentostudy_News_IndexController extends Mage_Core_Controller_Front_Action{
public function _construct(){
Mage::app()->loadArea($this->getLayout()->getArea());
$this->loadLayout();
$this->renderLayout();
}
public function indexAction(){
$cpBlock = $this->getLayout()->getBlockSingleton('Magentostudy_News_Block_News');
}
}
?>
This is My Block file
<?php
class Magentostudy_News_Block_News extends Mage_Core_Block_Template{
public function _construct()
{
parent::_construct();
$this->setTemplate('news/news.phtml');
}
}
?>
Tell me What type of issue in this file? and how to slove it?
Best Answer
I'm not sure what tutorial you are using, but it seem a little overly complicated than it need to be. Take a look at How to create front-end module in Magento
In your controller all you need to do is
In you DO NOT have a news.xml file then in your controller you could