2

I just created a module and I put this in my layout file:

<?xml version="1.0"?>
<layout version="0.1.0">
    <filteredproducts_index_index>
        <reference name="root">
            <action method="setTemplate">
                <template>page/2columns-left.phtml</template>
            </action>
        </reference>
        <reference name="content">
            <block type="filteredproducts/myblock" name="myblock" template="test.phtml"/>
        </reference>
    </filteredproducts_index_index>
</layout>

Now for some reason, no mather what block I put there inside my reference name="content" tag. The block is shown twice.

test.phtml:

<?php
    echo "test";
?>

IndexController.php:

<?php
class Brightinsight_FilteredProducts_IndexController extends Mage_Core_Controller_Front_Action
{

    public function indexAction()
    {
        $this->loadLayout();
        $this->renderLayout();
    }

}

The text shown at the page is testtest. So the content must be loaded two times for some reason I just can't seem to figure out how. Any help appreciated.

  • What does your controller code look like (Filteredproducts_IndexController::indexAction)? Maybe that can give us some better clues. – Rick Buczynski Dec 28 '14 at 1:05
1

Given your layout / controller combination, the only things I can think of that could cause the output to occur twice are:

  1. The page/2columns-left.phtml template renders the content block twice (or the content block and manually an instance of filteredproducts/myblock).
  2. There's an event observer than it manually rendering out the additional block.
  3. You are injecting your custom phtml file test.phtml into the layout elsewhere as well as in that layout file. Perhaps some initial debug code in one of the core layout files.
  4. Your block definition extends Mage_Core_Block_Template but has additional render code in one of the rendering methods that manually renders, but still calls the parent method.
| improve this answer | |
0

In my case it was only additional block filled from backend (Admin Panel -> CMS -> Pages -> Content)

| improve this answer | |

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.