Im creating a module where in the admin i have created options to enable/disable a block in the header.

So i planned on using ifconfig to show the block or not depending on the admin value.

Ive declared the block and it shows as should but im struggling to get the ifconfig to work. I understand it can only be used on action tags.

So my question is how do i show my block depending on the config value?

Heres my current xml:

<reference name="header">
        <block name="untitled.social.footer.links" as="social_footer" template="untitled/social/links.phtml"/>
        <action method="setChild" ifconfig="untitled_social/platforms/footer_enabled">

This doesnt work at the moment, so where am i going wrong?


** EDIT **

Following Johnathon's suggestions below if have amended my code which now looks like this:

Layout XML

        <reference name="footer">
            <action method="setChild" ifconfig="social/platforms/footer_enabled">

Construct in my block php file

public function __construct()

Unfortunately it's still not showing. How can i check the returns value of the ifconfig?


  • what is untitle_social ? is it the module name or a tab name?
    – Dexter
    Commented Oct 16, 2014 at 10:31
  • module name mate
    – Tom Burman
    Commented Oct 16, 2014 at 11:11

1 Answer 1


At the moment your layout XML isn't quite right. You are referencing the header block, and within that adding a block with the <block ... /> tag. After that you are essentially doing the same thing again by calling the setChild() method in the <action ...> tag. However when declaring <block ... /> you define a name, alias and template, but you don't set a block type which is required. Also unless you have reason to, you don't need to define an alias either. So instead do something like:

<block type="yourmodule/your_block" name="untitled.social.footer.links" template="untitled/social/links.phtml"/>

For the <action ...> call check the path for ifconfig, it's unusual to have an underscore in the first section of the path (untitled_social) but it depends on how you have defined the config entry in your system.xml. Bear in mind this should not be namespace_module, it needs to be according to the path you have defined in system.xml for that config value. This path may be the reason why it is not working correctly as if it is wrong it will always return false. Apart from that the <action ...> looks ok.

So if you want the block to show only according to the config value you need to remove the <block .../> declaration, otherwise remove <action ...> to have it always show. In both cases the header is not of block type core/text_list and so child blocks will not automatically render out. This means you need a call to the child block inside the header template to render out your template.

  • Ok so if i only have the <action> tag how do i set the template and type for the block? thanks
    – Tom Burman
    Commented Oct 16, 2014 at 11:28
  • The type is the the <block> argument passed to the setChild() method and you can set the block template inside the __construct() method of the block - $this->setTemplate('untitled/social/links.phtml');. Commented Oct 16, 2014 at 11:33
  • I have updated my question above. unfortunately its still not work. Could you help me out? Thanks
    – Tom Burman
    Commented Oct 16, 2014 at 13:09
  • There's not really much more I can add - what I have already put should achieve what you are trying to do. Just double check your code to make sure everything is correct. Commented Oct 17, 2014 at 6:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.