Call Static Block into Another Static Block Through Template

PHPstatic-block

I want to call a static block into another static block if the right conditions are met. I believe that my main problem is how to register the template in XML, as I never worked with it before.

First off I have a static block with the code: footer02-links.
Here I'm trying to call my template file. I realise that the code below is missing the XML tags.

{{block template="custom/employee-links-template.phtml"}}

Then in the themes template folder in /custom/employee-links-template.phtml I have my conditional statement.

<?php if (Mage::getSingleton('customer/session')->isLoggedIn() && Mage::getSingleton('customer/session')->getCustomerGroupId() == "4") :?>
    <?php echo $this->getChildHtml('employee-links') ?>
<?php endif;?> 

So if the customer is logged in and part of customer group with ID 4, they will be shown the static block with the code: employee-links.
In this static block I simply have a link to a otherwise hidden category.

<li><a title="Employee Offers" href="/employee-offers.phtml">Employee Monthly Offers</a></li>

So I guess my problem is how to register the block in the local.xml file, which I really have no idea of how to do. Furthermore there might be a better way to do what I'm trying to achieve?

Best Answer

First off, the code should be

{{block type="core/template" template="custom/employee-links-template.phtml"}}

No need to edit your local.xml you can call your static block in your custom/employee-links-template.phtml template, see below.

   <?php if (Mage::getSingleton('customer/session')->isLoggedIn() && Mage::getSingleton('customer/session')->getCustomerGroupId() == "4") :?>
    <?php echo $this->getLayout()->createBlock("cms/block")->setBlockId("your-static-block-id")->toHtml();?>
   <?php endif;?> 

Explanation: You cannot add children to blocks that are dynamically created with {{block}}, or access them from the layout XML, so you have to create the inner block directly from the template.