I have created a custom module but having a little difficulty with blocks in the config.xml
For some reason I'm not able to get the blocks to show on the dump of all the xml...maybe I've missed something?
I have the following structure:
app\code\local\Site\SiteTest\etc\config.xml
app\code\local\Site\SiteTest\Block\test.php
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Site_Test>
<version>1.0.0</version>
</Site_Test>
</modules>
<global>
<blocks>
<highest>
<class>Site_Block</class>
</highest>
</blocks>
</global>
</config>
I am trying to link this to a custom layout for example:
<block type="sitetest/test" name="home.catalog.product.test" template="catalog/product/test.phtml" after="cms_page">
If anyone could shed some light on this would really be appreciated.
-
Try following this tutorial: magento.stackexchange.com/questions/23629/…TBI Infotech– TBI Infotech2014年06月16日 05:33:22 +00:00Commented Jun 16, 2014 at 5:33
1 Answer 1
Since you have provided less info about your module I can suggest the following corrections only. Hope it might useful.
1). There are some mis-configurations in your config.xml file. See the below code (corrected one)
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Site_SiteTest><!--use 'Namespace_Module' -->
<version>1.0.0</version>
</Site_Test>
</modules>
<global>
<blocks>
<sitetest> <!-- this node can be anything, But as standard use the lowercase name of your module-->
<class>Site_SiteTest_Block</class><!-- put entire path upto Block folder-->
</sitetest>
</blocks>
</global>
</config>
2). Rename your block class file as Test.php
So the block class declaration should be as follow.
<?php
class Site_SiteTest_Block_Test extends Mage_Core_Block_Template
{
//your code here.
}
3). Make sure you have written the module activation file in app/etc/modules folder. It should be Site_SiteTest.xml with the following content.
<config>
<modules>
<Site_SiteTest>
<active>true</active>
<codePool>local</codePool>
</Site_SiteTest>
</modules>
</config>
4). Make sure the cache is disabled. (go to System > Cache Management and select all, then disabled them)
-
Thanks a bunch this helped! May have one or two more questions later though :)user9178– user91782014年06月16日 09:47:28 +00:00Commented Jun 16, 2014 at 9:47
-
Glad to hear that it helped you :)Sukeshini– Sukeshini2014年06月16日 09:49:11 +00:00Commented Jun 16, 2014 at 9:49
-
Ok so I now have: <sitetest> <class>Site_Test_Block</class> </sitetest> Within my ?showConfig=true...however I seem to be having trouble linking this to a custom XML layout. <block type="test/test" name="test" template="catalog/product/test.phtml" after="cms_page"> Sorry more tests than anything else loluser9178– user91782014年06月16日 09:54:48 +00:00Commented Jun 16, 2014 at 9:54
-
The last test would be the .php file so ermm if I have this right.... <block type="modulename/filename">user9178– user91782014年06月16日 10:00:04 +00:00Commented Jun 16, 2014 at 10:00
-
Ok I think I've got it sorted however I have been given the following error when loading the page: Fatal error: Class 'Site_Test_Block_Test' not found in C:\wamp\www\magento\app\code\core\Mage\Core\Model\Layout.php on line 491user9178– user91782014年06月16日 10:45:16 +00:00Commented Jun 16, 2014 at 10:45
Explore related questions
See similar questions with these tags.