<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Programatically create Magento blocks and inject them into layout</title>
	<atom:link href="http://inchoo.net/ecommerce/magento/programatically-create-magento-blocks-and-inject-them-into-layout/feed/" rel="self" type="application/rss+xml" />
	<link>http://inchoo.net/ecommerce/magento/programatically-create-magento-blocks-and-inject-them-into-layout/</link>
	<description>Magento Design and Magento Development Professionals - Inchoo</description>
	<lastBuildDate>Fri, 10 Feb 2012 19:34:16 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Rao</title>
		<link>http://inchoo.net/ecommerce/magento/programatically-create-magento-blocks-and-inject-them-into-layout/comment-page-1/#comment-25897</link>
		<dc:creator>Rao</dc:creator>
		<pubDate>Fri, 27 Jan 2012 07:09:52 +0000</pubDate>
		<guid isPermaLink="false">http://inchoo.net/?p=2292#comment-25897</guid>
		<description>how can i create dynamic breadcrumbs for my custom module. i am in 80% of my first magento module construction and this is what i am on right now. kindly guide me. 
elegant.rao@gmail.com
thank you.</description>
		<content:encoded><![CDATA[<p>how can i create dynamic breadcrumbs for my custom module. i am in 80% of my first magento module construction and this is what i am on right now. kindly guide me.<br />
<a href="mailto:elegant.rao@gmail.com">elegant.rao@gmail.com</a><br />
thank you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: haifa</title>
		<link>http://inchoo.net/ecommerce/magento/programatically-create-magento-blocks-and-inject-them-into-layout/comment-page-1/#comment-25526</link>
		<dc:creator>haifa</dc:creator>
		<pubDate>Mon, 09 Jan 2012 19:00:55 +0000</pubDate>
		<guid isPermaLink="false">http://inchoo.net/?p=2292#comment-25526</guid>
		<description>thanks for this! helped me a lot!</description>
		<content:encoded><![CDATA[<p>thanks for this! helped me a lot!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harry</title>
		<link>http://inchoo.net/ecommerce/magento/programatically-create-magento-blocks-and-inject-them-into-layout/comment-page-1/#comment-23023</link>
		<dc:creator>Harry</dc:creator>
		<pubDate>Sat, 08 Oct 2011 09:22:17 +0000</pubDate>
		<guid isPermaLink="false">http://inchoo.net/?p=2292#comment-23023</guid>
		<description>I dont want to use the core/template as a block type.. what if i want to use checkout/cart... i have tried the following code but its is not working.... 
[code]
 public function indexAction()
		{   
			//Get current layout state 
			$this-&gt;loadLayout();	
					
			$block = $this-&gt;getLayout()-&gt;createBlock(
				&#039;checkout/cart&#039;, // OR &#039;Mage_Checkout_Block_Cart&#039;
				&#039;my_block_name_here&#039;,
				array(&#039;template&#039; =&gt; &#039;custom/cart.phtml&#039;)
			);
			
			$this-&gt;getLayout()-&gt;getBlock(&#039;content&#039;)-&gt;append($block);
			$this-&gt;getLayout()-&gt;getBlock(&#039;root&#039;)-&gt;setTemplate(&#039;page/empty.phtml&#039;);

			//Release layout stream
			$this-&gt;renderLayout();
		}
[/code]
any suggestions will be highly appreciated.... Thanks you.</description>
		<content:encoded><![CDATA[<p>I dont want to use the core/template as a block type.. what if i want to use checkout/cart&#8230; i have tried the following code but its is not working&#8230;. </p>
<pre class="brush: plain; title: ; notranslate">
 public function indexAction()
		{
			//Get current layout state
			$this-&gt;loadLayout();	

			$block = $this-&gt;getLayout()-&gt;createBlock(
				'checkout/cart', // OR 'Mage_Checkout_Block_Cart'
				'my_block_name_here',
				array('template' =&gt; 'custom/cart.phtml')
			);

			$this-&gt;getLayout()-&gt;getBlock('content')-&gt;append($block);
			$this-&gt;getLayout()-&gt;getBlock('root')-&gt;setTemplate('page/empty.phtml');

			//Release layout stream
			$this-&gt;renderLayout();
		}
</pre>
<p>any suggestions will be highly appreciated&#8230;. Thanks you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: neeraj</title>
		<link>http://inchoo.net/ecommerce/magento/programatically-create-magento-blocks-and-inject-them-into-layout/comment-page-1/#comment-22460</link>
		<dc:creator>neeraj</dc:creator>
		<pubDate>Fri, 26 Aug 2011 07:39:22 +0000</pubDate>
		<guid isPermaLink="false">http://inchoo.net/?p=2292#comment-22460</guid>
		<description>thanks Salik</description>
		<content:encoded><![CDATA[<p>thanks Salik</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: salik</title>
		<link>http://inchoo.net/ecommerce/magento/programatically-create-magento-blocks-and-inject-them-into-layout/comment-page-1/#comment-20335</link>
		<dc:creator>salik</dc:creator>
		<pubDate>Sun, 10 Apr 2011 18:44:25 +0000</pubDate>
		<guid isPermaLink="false">http://inchoo.net/?p=2292#comment-20335</guid>
		<description>Use this for set layout of page

$template = Mage::getConfig()-&gt;getNode(&#039;global/page/layouts/two_columns_right/template&#039;);
$this-&gt;getLayout()-&gt;getBlock(&#039;root&#039;)-&gt;setTemplate($template);</description>
		<content:encoded><![CDATA[<p>Use this for set layout of page</p>
<p>$template = Mage::getConfig()-&gt;getNode(&#8216;global/page/layouts/two_columns_right/template&#8217;);<br />
$this-&gt;getLayout()-&gt;getBlock(&#8216;root&#8217;)-&gt;setTemplate($template);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Oleg Kudrenko</title>
		<link>http://inchoo.net/ecommerce/magento/programatically-create-magento-blocks-and-inject-them-into-layout/comment-page-1/#comment-20032</link>
		<dc:creator>Oleg Kudrenko</dc:creator>
		<pubDate>Mon, 21 Mar 2011 21:56:02 +0000</pubDate>
		<guid isPermaLink="false">http://inchoo.net/?p=2292#comment-20032</guid>
		<description>Hi!
I need to create many cms page programmatically. How can i do it, what methods i must use?</description>
		<content:encoded><![CDATA[<p>Hi!<br />
I need to create many cms page programmatically. How can i do it, what methods i must use?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eyal Peleg</title>
		<link>http://inchoo.net/ecommerce/magento/programatically-create-magento-blocks-and-inject-them-into-layout/comment-page-1/#comment-13794</link>
		<dc:creator>Eyal Peleg</dc:creator>
		<pubDate>Mon, 27 Dec 2010 06:15:47 +0000</pubDate>
		<guid isPermaLink="false">http://inchoo.net/?p=2292#comment-13794</guid>
		<description>I don&#039;t know what you are using for code formatting but at least on my MFC-440CN  it just prints out garbage instead of the code. :(</description>
		<content:encoded><![CDATA[<p>I don&#8217;t know what you are using for code formatting but at least on my MFC-440CN  it just prints out garbage instead of the code. <img src='http://inchoo.net/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fabio</title>
		<link>http://inchoo.net/ecommerce/magento/programatically-create-magento-blocks-and-inject-them-into-layout/comment-page-1/#comment-8920</link>
		<dc:creator>Fabio</dc:creator>
		<pubDate>Wed, 03 Nov 2010 17:35:34 +0000</pubDate>
		<guid isPermaLink="false">http://inchoo.net/?p=2292#comment-8920</guid>
		<description>Hi.
I am trying to work my ways trough magento and i can&#039;t find a way to create a block the &quot;right&quot; way.
 Can you point me to the doc or a tutorial of how to create a block with just the necessary files?</description>
		<content:encoded><![CDATA[<p>Hi.<br />
I am trying to work my ways trough magento and i can&#8217;t find a way to create a block the &#8220;right&#8221; way.<br />
 Can you point me to the doc or a tutorial of how to create a block with just the necessary files?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: narzedzia pneumatyczne</title>
		<link>http://inchoo.net/ecommerce/magento/programatically-create-magento-blocks-and-inject-them-into-layout/comment-page-1/#comment-8416</link>
		<dc:creator>narzedzia pneumatyczne</dc:creator>
		<pubDate>Sun, 26 Sep 2010 19:21:56 +0000</pubDate>
		<guid isPermaLink="false">http://inchoo.net/?p=2292#comment-8416</guid>
		<description>And my question is how can I access layout object from inside some block. I want to get current page title (if its set already).</description>
		<content:encoded><![CDATA[<p>And my question is how can I access layout object from inside some block. I want to get current page title (if its set already).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vier</title>
		<link>http://inchoo.net/ecommerce/magento/programatically-create-magento-blocks-and-inject-them-into-layout/comment-page-1/#comment-7690</link>
		<dc:creator>Vier</dc:creator>
		<pubDate>Tue, 20 Jul 2010 17:50:11 +0000</pubDate>
		<guid isPermaLink="false">http://inchoo.net/?p=2292#comment-7690</guid>
		<description>Hi, I&#039;m using this piece of code to create a simple contact form, but it appears with a default 3 columns layout and I&#039;d like to know how can I set it to appear with just 1 column.</description>
		<content:encoded><![CDATA[<p>Hi, I&#8217;m using this piece of code to create a simple contact form, but it appears with a default 3 columns layout and I&#8217;d like to know how can I set it to appear with just 1 column.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daisy</title>
		<link>http://inchoo.net/ecommerce/magento/programatically-create-magento-blocks-and-inject-them-into-layout/comment-page-1/#comment-6594</link>
		<dc:creator>Daisy</dc:creator>
		<pubDate>Tue, 30 Mar 2010 04:53:57 +0000</pubDate>
		<guid isPermaLink="false">http://inchoo.net/?p=2292#comment-6594</guid>
		<description>Hi,

I want to add newsletter block into my one column products page. How to add newsletter block in desired location of the page.

Thanks</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I want to add newsletter block into my one column products page. How to add newsletter block in desired location of the page.</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tejas</title>
		<link>http://inchoo.net/ecommerce/magento/programatically-create-magento-blocks-and-inject-them-into-layout/comment-page-1/#comment-6484</link>
		<dc:creator>Tejas</dc:creator>
		<pubDate>Tue, 16 Mar 2010 10:01:53 +0000</pubDate>
		<guid isPermaLink="false">http://inchoo.net/?p=2292#comment-6484</guid>
		<description>Hi,

Your post is very helpful :)

Thanks,</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Your post is very helpful <img src='http://inchoo.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Thanks,</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Margots</title>
		<link>http://inchoo.net/ecommerce/magento/programatically-create-magento-blocks-and-inject-them-into-layout/comment-page-1/#comment-6354</link>
		<dc:creator>Margots</dc:creator>
		<pubDate>Wed, 03 Mar 2010 19:05:58 +0000</pubDate>
		<guid isPermaLink="false">http://inchoo.net/?p=2292#comment-6354</guid>
		<description>Can you create block in the xml layout file. For example, I want to use X block

X block name



X - new block that needs to be created, but how to do it in layout xml file?
Simply putting following will not work</description>
		<content:encoded><![CDATA[<p>Can you create block in the xml layout file. For example, I want to use X block</p>
<p>X block name</p>
<p>X &#8211; new block that needs to be created, but how to do it in layout xml file?<br />
Simply putting following will not work</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mzouhel</title>
		<link>http://inchoo.net/ecommerce/magento/programatically-create-magento-blocks-and-inject-them-into-layout/comment-page-1/#comment-6188</link>
		<dc:creator>mzouhel</dc:creator>
		<pubDate>Fri, 12 Feb 2010 15:12:07 +0000</pubDate>
		<guid isPermaLink="false">http://inchoo.net/?p=2292#comment-6188</guid>
		<description>Can i add a custom template to my backend ?
i want print my orders in html format and i need to create a block under adminhtml :(</description>
		<content:encoded><![CDATA[<p>Can i add a custom template to my backend ?<br />
i want print my orders in html format and i need to create a block under adminhtml <img src='http://inchoo.net/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pneumatyka</title>
		<link>http://inchoo.net/ecommerce/magento/programatically-create-magento-blocks-and-inject-them-into-layout/comment-page-1/#comment-5854</link>
		<dc:creator>pneumatyka</dc:creator>
		<pubDate>Wed, 13 Jan 2010 08:02:46 +0000</pubDate>
		<guid isPermaLink="false">http://inchoo.net/?p=2292#comment-5854</guid>
		<description>Wonderfull, just what I was looking for simplest module possible. Thx!</description>
		<content:encoded><![CDATA[<p>Wonderfull, just what I was looking for simplest module possible. Thx!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cnboy</title>
		<link>http://inchoo.net/ecommerce/magento/programatically-create-magento-blocks-and-inject-them-into-layout/comment-page-1/#comment-2870</link>
		<dc:creator>cnboy</dc:creator>
		<pubDate>Wed, 22 Jul 2009 06:25:42 +0000</pubDate>
		<guid isPermaLink="false">http://inchoo.net/?p=2292#comment-2870</guid>
		<description>thanks !it is helpful for me</description>
		<content:encoded><![CDATA[<p>thanks !it is helpful for me</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erik Hansen</title>
		<link>http://inchoo.net/ecommerce/magento/programatically-create-magento-blocks-and-inject-them-into-layout/comment-page-1/#comment-2794</link>
		<dc:creator>Erik Hansen</dc:creator>
		<pubDate>Sun, 12 Jul 2009 05:47:42 +0000</pubDate>
		<guid isPermaLink="false">http://inchoo.net/?p=2292#comment-2794</guid>
		<description>This comment box doesn&#039;t like XML tags - it replaced some XML tags from my previous post with ....

Here&#039;s the XML I posted:
&lt;block type=&quot;**/****&quot;&gt;...&lt;/block&gt;</description>
		<content:encoded><![CDATA[<p>This comment box doesn&#8217;t like XML tags &#8211; it replaced some XML tags from my previous post with &#8230;.</p>
<p>Here&#8217;s the XML I posted:<br />
&lt;block type=&quot;**/****&quot;&gt;&#8230;&lt;/block&gt;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erik Hansen</title>
		<link>http://inchoo.net/ecommerce/magento/programatically-create-magento-blocks-and-inject-them-into-layout/comment-page-1/#comment-2793</link>
		<dc:creator>Erik Hansen</dc:creator>
		<pubDate>Sun, 12 Jul 2009 05:43:14 +0000</pubDate>
		<guid isPermaLink="false">http://inchoo.net/?p=2292#comment-2793</guid>
		<description>The &quot;createBlock&quot; method is used in quite a few controllers throughout the Magento codebase.  It&#039;s especially used in the Adminhtml module.  There are many places where a controller loads a block using the createBlock method, where that could have also been specified in a layout XML file.  The createBlock method is essentially a more direct way of loading a block as opposed to typing up the XML for that block in a layout file.

When you see a ... in a layout file, you should know that it ultimately gets loaded by the Mage_Core_Model_Layout class, the same object type that gets returned by $this-&gt;getLayout()</description>
		<content:encoded><![CDATA[<p>The &#8220;createBlock&#8221; method is used in quite a few controllers throughout the Magento codebase.  It&#8217;s especially used in the Adminhtml module.  There are many places where a controller loads a block using the createBlock method, where that could have also been specified in a layout XML file.  The createBlock method is essentially a more direct way of loading a block as opposed to typing up the XML for that block in a layout file.</p>
<p>When you see a &#8230; in a layout file, you should know that it ultimately gets loaded by the Mage_Core_Model_Layout class, the same object type that gets returned by $this-&gt;getLayout()</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erik Hansen</title>
		<link>http://inchoo.net/ecommerce/magento/programatically-create-magento-blocks-and-inject-them-into-layout/comment-page-1/#comment-2792</link>
		<dc:creator>Erik Hansen</dc:creator>
		<pubDate>Sun, 12 Jul 2009 05:32:41 +0000</pubDate>
		<guid isPermaLink="false">http://inchoo.net/?p=2292#comment-2792</guid>
		<description>Thanks for another helpful post.

The code above can also be written as follows:
$block = $this-&gt;getLayout()-&gt;createBlock(
    &#039;core/template&#039;,
     &#039;my_block_name_here&#039;)
)-&gt;setTemplate(&#039;activecodeline/developer.phtml&#039;);

Is it not better to load the Block using it&#039;s &quot;alias name&quot;, so that in case it gets overridden by another module, the overridden class will be loaded?</description>
		<content:encoded><![CDATA[<p>Thanks for another helpful post.</p>
<p>The code above can also be written as follows:<br />
$block = $this-&gt;getLayout()-&gt;createBlock(<br />
    &#8216;core/template&#8217;,<br />
     &#8216;my_block_name_here&#8217;)<br />
)-&gt;setTemplate(&#8216;activecodeline/developer.phtml&#8217;);</p>
<p>Is it not better to load the Block using it&#8217;s &#8220;alias name&#8221;, so that in case it gets overridden by another module, the overridden class will be loaded?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Branko Ajzele</title>
		<link>http://inchoo.net/ecommerce/magento/programatically-create-magento-blocks-and-inject-them-into-layout/comment-page-1/#comment-2520</link>
		<dc:creator>Branko Ajzele</dc:creator>
		<pubDate>Fri, 12 Jun 2009 14:06:35 +0000</pubDate>
		<guid isPermaLink="false">http://inchoo.net/?p=2292#comment-2520</guid>
		<description>Another example on how to space the block to any area of screen

$this-&gt;getLayout()-&gt;getBlock(&#039;right&#039;)-&gt;insert($block, &#039;catalog.compare.sidebar&#039;, true);

This will position it on right sidebar under the &#039;catalog.compare.sidebar&#039; block.</description>
		<content:encoded><![CDATA[<p>Another example on how to space the block to any area of screen</p>
<p>$this->getLayout()->getBlock(&#8216;right&#8217;)->insert($block, &#8216;catalog.compare.sidebar&#8217;, true);</p>
<p>This will position it on right sidebar under the &#8216;catalog.compare.sidebar&#8217; block.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

