title: Fatal error: Call to a member function setTemplate() on a non-object
body: <p>I have created one block inside my custom module but it's not working. My module is working fine but my block is not working when I call my block from footer.phtml file it shows 'Fatal error: Call to a member function setTemplate() on a non-object'. Actually I want to show some message in my frontend using my custom block.I have mentioned my code below</p>
  
  <p>local/Monojit/Custom/controllers/IndexController.php</p>
  
  <pre><code>&lt;?php
  class Monojit_Custom_IndexController extends Mage_Core_Controller_Front_Action
  {
     public function indexAction()
      {   
  
          $this-&gt;loadLayout();    
  
          $block = $this-&gt;getLayout()-&gt;createBlock(
              'Mage_Core_Block_Template',
              'my_block_name_here',
              array('template' =&gt; 'custom/test.phtml')
          );
  
          $this-&gt;getLayout()-&gt;getBlock('content')-&gt;append($block);
          $this-&gt;renderLayout();
      }
  
  }
  ?&gt;
  </code></pre>
  
  <p>local/Monojit/Custom/Block/Mycustomblock.php</p>
  
  <pre><code>&lt;?php
  class Monojit_Custom_Block_Mycustomblock extends Mage_Core_Block_Template
  
  {
  //public function _prepareLayout()
  //    {
  //      return parent::_prepareLayout();
  //    }
  
      public function _construct() {     
          parent::_construct(); 
          $this-&gt;setTemplate('custom/test.phtml');     
      }
      public function getmessage()
       {
         $msg = "showing my custom block";       
         return $msg;
       }   
  } 
  ?&gt;
  </code></pre>
  
  <p>local/Monojit/Custom/etc/config.xml
      </p>
  
  <pre><code>&lt;config&gt;
  
  &lt;global&gt;
  
  &lt;modules&gt;
  
  &lt;monojit_custom&gt;
  
  &lt;version&gt;0.1.0&lt;/version&gt;
  
  &lt;/monojit_custom&gt;
  
  &lt;/modules&gt;
  
  &lt;blocks&gt;
  
  &lt;custom&gt;
  
  &lt;rewrite&gt;
  
  &lt;custom&gt;Monojit_Custom_Block_Mycustomblock&lt;/custom&gt;
  
  &lt;/rewrite&gt;
  
  &lt;/custom&gt;
  
  &lt;/blocks&gt;
  &lt;helpers&gt;
    &lt;custom&gt;
        &lt;class&gt;Monojit_Custom_Helper&lt;/class&gt;
    &lt;/custom&gt;
  &lt;/helpers&gt;
  &lt;/global&gt;
  
  &lt;frontend&gt;
  
  &lt;routers&gt;
  
  &lt;custom&gt;
  
  &lt;use&gt;standard&lt;/use&gt;
  
  &lt;args&gt;
  
  &lt;module&gt;Monojit_Custom&lt;/module&gt;
  
  &lt;frontName&gt;custom&lt;/frontName&gt;
  
  &lt;/args&gt;
  
  &lt;/custom&gt;
  
  &lt;/routers&gt;
  
  &lt;layout&gt;
  
  &lt;updates&gt;
  
  &lt;custom&gt;
  
  &lt;file&gt;custom.xml&lt;/file&gt;
  
  &lt;/custom&gt;
  
  &lt;/updates&gt;
  
  &lt;/layout&gt;
  
  &lt;/frontend&gt;
  
  &lt;/config&gt;
  </code></pre>
  
  <p>I have created one theme (copied modern theme) inside frontend/default/monojit Changed admin design configuration as well,created necessary folder as well inside skin.screenshot pic <img src="https://i.stack.imgur.com/qsV8Y.png" alt="enter image description here"></p>
  
  <p>design/frontend/default/monojit/template/custom/test.phtml</p>
  
  <pre><code>//want to fetch data from my block 
  &lt;p&gt;This is your custom block called programatically.&lt;/p&gt;
  </code></pre>
  
  <p>localhost/magento/index.php/custom page shows my message correctly but when I call my block from footer.phtml page </p>
  
  <pre><code>&lt;?php echo $this-&gt;getLayout()-&gt;createBlock('custom/mycustomblock')-&gt;setTemplate('custom/test.phtml')-&gt;toHtml(); ?&gt;
  </code></pre>
  
  <p>It shows 'Fatal error: Call to a member function setTemplate() on a non-object' Do I need to create any layout.xml file? Please help me how can i fix my issue.thanks</p>