Blocks instantiated by the {{block}}
directive in can not be referenced from layout XML files.
That is because they are instantiated during the processing of the renderLayout()
step, which calls each blocks toHtml()
method.
The layout XML is processed before that, during the execution of the loadLayout()
step.
To work around this, declare the child blocks without a parent block in the layout XML
<layout>
<default>
<block type="custommodule/search_bysize" name="search_by_size" template="custommodule/search/by-size.phtml" />
<block type="custommodule/search_byvehicle" name="search_by_vehicle" template="custommodule/search/by-vehicle.phtml" />
</default>
</layout>
Then, in your custommodule/search
block template use getBlockHtml()
instead of getChildHtml()
.
<?php echo $this->getBlockHtml('search_by_size') ?>
<?php echo $this->getBlockHtml('search_by_vehicle') ?>
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 :)
Best Answer
catalog_category_view
is loaded for all the category pages.It's the default layout handler for the category page. The category page maps to the
catalog
module,category
controller,view
action.catalog_category_default
is loaded only for categories that are not marked as anchors.There is also a layout handle called
catalog_category_layered
that is loaded for categories marked as anchor.If you want to show a particular block for one single category, you can either make it as a static block and use the category display settings. Set the display mode as
Static block and products
and select the appropriate static block.Or you can use the layout handle
<CATEGORY_{ID_HERE}>
. replace{ID_HERE}
with the category id.Also you can try to use the custom xml layout field in the category display settings in the backend.
[EDIT]
To use the category handle do this:
Let's say that you want to add a block for category with id 10.
Add this in the layout