I'm using Magento EE 1.6
When I use a custom block class to display some tags inside my <head>
, block won't display. But if I use the "page/html"
type, everything is fine... I need my custom class to add some features to the block (activation, getting image url etc).
Please help me to understand what I missed. Here is what I've done so far :
app/etc/modules/Wbx_Social.xml :
<?xml version="1.0"?>
<config>
<modules>
<Wbx_Social>
<active>true</active>
<codePool>local</codePool>
</Wbx_Social>
</modules>
</config>
app/code/local/Wbx/Social/etc/config.xml :
<?xml version="1.0"?>
<config>
<modules>
<Wbx_Social>
<version>0.1.0</version>
</Wbx_Social>
</modules>
<global>
[...]
<blocks>
<wbx_social>
<class>Wbx_Social_Block</class>
</wbx_social>
</blocks>
</global>
<frontend>
<layout>
<updates>
<wbx_social>
<file>wbx_social.xml</file>
</wbx_social>
</updates>
</layout>
</frontend>
</config>
app/code/local/Wbx/Social/Block/Opengraph.php :
class Wbx_Social_Block_Opengraph extends Mage_Core_Block_Template
{
/**
* @return int
*/
public function isActive()
{
return true; // Will be replaced with store config value
}
/* And other useful functions */
}
app/design/frontend/responsive/default/layout/wbx_social.xml :
<?xml version="1.0"?>
<layout>
<default>
<reference name="head">
<block type="wbx_social/opengraph" name="opengraph" as="opengraph" template="social/opengraph.phtml"/>
</reference>
</default>
</layout>
And finally the template : app/design/frontend/responsive/default/template/social/opengraph.phtml :
<?php /* @var $this Wbx_Social_Block_Opengraph */ ?>
<?php if ($this->isActive()) : ?>
<meta property="fb:app_id" content="an id"/>
<meta property="og:type" content="website"/>
<meta property="og:site_name" content="a name"/>
<?php endif; ?>
Just in case, I didn't forget the Wbx_Social_Helper_Data
empty helper.
In wbx_social.xml
, when I try changing the block class for type="core/template"
or type="page/html"
(for example), the block is correctly displayed (without any access of custom functions of course)
I really need a hint, it's been several hours I'm tearing out...
_toHtml()
method in your block? If yes, post it in the question. If no, then try to add something in the template outside the if statement and see if it prints._toHtml()
method. I already tried printing something outside the if statement, and it's only working when this is nottype="wbx_social/opengraph"
. So I think the problem is whether in config (blocks declaration) or layout config (bad type ?)