2

This may be a stupid question. Is it possible to call a custom block after the closing HTML tag in my templates? Here's what I've got so far, but the block is not included/rendered and there's nothing in the error logs.

File: app/design/frontend/default/theme/layout/local.xml

<?xml version="1.0" encoding="UTF-8"?>
<layout>
    <default>
        ...
        <reference name="custom_block">
            <block type="core/template" name="custom_block" as="custom_block" template="page/html/custom_block.phtml" />
        </reference>
        ...
    </default>
</layout>

File: app/design/frontend/default/theme/template/page/html/custom_block.phtml

<!-- boo! -->
<link rel="stylesheet" type="text/css" href="style.css" />

And lastly, I call the block in the layout file(s) like so:

File: app/design/frontend/default/theme/template/page/1column.phtml

    ...
    </div>
    <?php echo $this->getAbsoluteFooter() ?>
</body>
</html>
<?php echo $this->getChildHtml('custom_block') ?>

Have I got the scope of getChildHtml() wrong? I have cleared the cache manually a hundred times and re-indexed the site as much. Thanks for taking a look.

5

Your layout xml should look like this:

<?xml version="1.0" encoding="UTF-8"?>
<layout>
    <default>
        <reference name="root">
            <block type="core/template" name="custom_block" as="custom_block" template="page/html/custom_block.phtml" />
        </reference>
    </default>
</layout>

But please don't output anything after </html>. It's wrong.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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