cancel
Showing results for 
Search instead for 
Did you mean: 

Content block not showing

Content block not showing

I'm trying to set up a custom block module and display it. For this question my namespace is V, module name W. I've created global config file, V_All.xml, in app/etc/modules/

  <?xml version="1.0"?>
   <config>
    <modules>
     <V_W>
       <active>true</active>
       <codePool>local</codePool>
     </V_W>
    </modules>
   </config>

I've also created module config file, config.xml, in app/code/local/V/W/etc/

 <?xml version="1.0"?>
  <config>
   <modules>
     <V_W>
       <version>1.0</version>
     </V_W>
   </modules>

   <global>
    <blocks>
      <w>
        <class>V_W_Block</class>
      </w>
    </blocks>
   </global>
  </config>

I've created class file for custom block, Yblock.php, at: app/code/local/V/W/Block/Yblock.php

 <?php
  class V_W_Block_Yblock extends Mage_Core_Block_Template
  {  // Methods
  }
  ?>

I've created a template file, Yblock.phtml, to output custom block data in app/design/frontend/Mypackage/Mytheme/template/Z/Yblock.phtml. In it I have:

  <?php echo "Test Custom Block"; ?>

I've tried to display block via local.xml:

 <?xmlversion="1.0"encoding="UTF-8"?>
   <layoutversion="0.1.0">
     <default>
       <reference name="root">
         <reference name="content">
           <block type="w/yblock" name="yblock" template="z/yblock.phtml" before="-"/>
         </reference>
       </reference>
     </default>
   </layout>

However, nothing is displayed on browser. I've gone through my code and cannot find anything to alter. I wonder if anyone could point why "Test Custom Block" is not being displayed. I'll be grateful for all assistance.

6 REPLIES 6

Re: Content block not showing

Hi @raydona

 

Change your global config file name from "V_All" to "V_W".
And for further details please check this link out: http://inchoo.net/magento/programmatically-add-custom-block-in-magento-admin/

 

Let me know if you stuck at anything.

Was my answer helpful? You can accept it as a solution.
175+ Professional Extensions for M1 & M2
Need a developer?Just visit Contact Us Now

Re: Content block not showing

Module declaration file name should not matter. The problem should be in your local.xml, I don't think you can call reference inside another reference, in fact, you can call <reference name="content"> directly without the outer one

Re: Content block not showing

"Change your global config file name from "V_All" to "V_W"  I've tried that but it does not solve problem.

Re: Content block not showing

"you can call <reference name="content"> directly without the outer one"  I've tried that but it does not solve problem.

Re: Content block not showing

layoutversion="0.1.0"

should be :

layout version="0.1.0"

 

Re: Content block not showing

I've tried to display block via local.xml:

<?xmlversion="1.0"encoding="UTF-8"?>

Should be:

<?xml version="1.0"encoding="UTF-8"?>