0

I've got a root template block, in which there's a block for the left column. I want to place there 2 more sub-blocks. So this is what I do...

This is the referenced left-column template block:

<block type="core/text_list" name="left" as="left" translate="label">
...
</block

and my stuff:

<reference name="left">
    <block type="core/template" name="cart_sparkasse" as="cart_sparkasse" template="sparkasse/cart.phtml" />
    <block type="core/template" name="ssl_information" as="ssl_information" template="sparkasse/ssl_information.phtml" />
</reference>

I do not get anything visualised. I turn on the template + block hints and I can see that the 2 template blocks are there, but they have no content and are not visualized. I cannot find them in the source HTML code of the page either, which leads me to the thought that they are not rendered or whatever Magento does...

Any ideas how to fix this?

UPDATE:

The code in the additional templates:

<p style="border: 1px solid red"><?php echo $this->__('Baby, I am here')?></p>
  • did check your cache is disable? – MeenakshiSundaram R Aug 6 '14 at 10:39
  • i think you don't have those(ssl_information.phtml, cart.phtml) files in your active theme, so its fallback to the base theme and display nothing – MeenakshiSundaram R Aug 6 '14 at 11:03
  • I do have the templates and I did clean the cache before testing. :) – Syspect Aug 6 '14 at 11:12
  • Where did you add your second stuff? Means inside which handler ? Inside which layout file ? – Rajeev K Tomy Aug 6 '14 at 11:31
  • @programmer_rkt - inside frontend/mytheme/default/layout/local.xml. There I have a node <myrouter_mycontroller_myaction>, because the page is called from that action, and the action calls ->renderLayout();. But in this XML node I also have <remove .../> nodes, which are working, so that is why I am sure this is the right place to add the block. – Syspect Aug 6 '14 at 11:37
1

So your template file holds <html /> <head /> <body /> tags in it. It will be a bad design, because magento loads all these things through page.xml layout file. If you want to see those codes.

For simplicity, I assumes you have a 2 column -left layout for your page. Then the template that holds definitionof this layout has a design like this

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



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->getLang() ?>" lang="<?php echo $this->getLang() ?>">
<head>
<?php echo $this->getChildHtml('head') ?>
</head>
<body<?php echo $this->getBodyClass()?' class="'.$this->getBodyClass().'"':'' ?>>
<?php echo $this->getChildHtml('after_body_start') ?>
<div class="wrapper">
    <?php echo $this->getChildHtml('global_notices') ?>
    <div class="page">
        <?php echo $this->getChildHtml('header') ?>
        <div class="main-container col2-left-layout">
            <div class="main">
                <?php echo $this->getChildHtml('breadcrumbs') ?>
                <div class="col-main">
                    <?php echo $this->getChildHtml('global_messages') ?>
                    <?php echo $this->getChildHtml('content') ?>
                </div>
                <div class="col-left sidebar"><?php echo $this->getChildHtml('left') ?></div>
            </div>
        </div>
        <?php echo $this->getChildHtml('footer') ?>
        <?php echo $this->getChildHtml('global_cookie_notice') ?>
        <?php echo $this->getChildHtml('before_body_end') ?>
    </div>
</div>
<?php echo $this->getAbsoluteFooter() ?>
</body>
</html>

As you can see all those tags that your are added through your block is already loading by Magento. "So don't make Magento angry by placing that code in your template file. If magento becomes angry, she will respond badly :)".

More info : Your block is added to the above code by this section.

 <div class="col-left sidebar"><?php echo $this->getChildHtml('left') ?></div>

This will add all blocks that comes under left block that are specified through layout files. So in order to be a part of it,(or to test) you just need to use this design code in your template files.

<p>$this->__('Baby, I am here')</p>

Normally I am using this for testing purposes :)

Conclusion

Without that, I can't see any problem with your code. There is only one chance remain. You may included these template files in wrong position. That would be the most probable reason that resist to show the output

signing off :)

  • what was the problem ? – Rajeev K Tomy Aug 6 '14 at 15:24
  • Okay, the problem was that I haven't had set permissions to the project files (as I was testing on a remote server)... stuuuuuuupid... :D It works fine with the code that I have. :) Thanks. – Syspect Aug 6 '14 at 15:24
  • 1
    Ya your code should work as I already stated. But you studied a new thing through my answer I hope. Happy to help you – Rajeev K Tomy Aug 6 '14 at 15:27

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.