<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Subesh Pokhrel&#039;s Blog - Magento Development Tips &#187; Layout</title>
	<atom:link href="http://subesh.com.np/tag/layout/feed/" rel="self" type="application/rss+xml" />
	<link>http://subesh.com.np</link>
	<description>PHP &#38; Magento Tips and Tutorials</description>
	<lastBuildDate>Wed, 01 Feb 2012 04:09:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Magento Module Release: Uses Layout To List Post, made by AW Blog, on the basis of Category Identifier</title>
		<link>http://subesh.com.np/2010/03/magento-module-release-layout-list-post-aw-blog-basis-category-identifier/</link>
		<comments>http://subesh.com.np/2010/03/magento-module-release-layout-list-post-aw-blog-basis-category-identifier/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 06:27:23 +0000</pubDate>
		<dc:creator>Subesh Pokhrel</dc:creator>
				<category><![CDATA[Custom Module]]></category>
		<category><![CDATA[Magento]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Layout]]></category>

		<guid isPermaLink="false">http://subesh.com.np/?p=222</guid>
		<description><![CDATA[I&#8217;ve always wanted to contribute something in Magento Community and I think today the day has arrived. The module is named as Sirius Blog Helper, just a name, Who cares about the &#8220;Name&#8221; unless it works . The basic function of the Module is to list the post made via AW Blog extension, categorized by [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve always wanted to contribute something in Magento Community and I think today the day has arrived. The module is named as Sirius Blog Helper, just a name, Who cares about the &#8220;Name&#8221; unless it works <img src='http://subesh.com.np/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> . The basic function of the Module is to list the post made via <a href="http://www.magentocommerce.com/extension/1516/blog">AW Blog</a> extension, categorized by category identifier of the post, using Layout. Yes, only through layout you can list the post anywhere you want. Not only that you can also restrict the size of the list through layout as well.</p>
<p>Suppose you want to list 5 recent post made under &#8220;news&#8221; category identifier. Here&#8217;s how you can do it easily, of course you have to install the module first. The Module can be currently downloaded from <a href="http://subeshexamples.googlecode.com/files/Sirius_Bloghelper.zip">Here</a>, and will be soon available in Magento Connect as well.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;reference name=&quot;right&quot;&gt;
	&lt;block type=&quot;sbloghelper/helper&quot; name=&quot;news.list&quot;&gt;
		&lt;action method=&quot;addCategoryIdentifier&quot;&gt;
			&lt;identifier&gt;news&lt;/identifier&gt;
		&lt;/action&gt;
		&lt;action method=&quot;addListSize&quot;&gt;
			&lt;size&gt;5&lt;/size&gt;
		&lt;/action&gt;
	&lt;/block&gt;
&lt;/reference&gt;
</pre>
<p>Simple isn&#8217;t it? You can place similar kind of code in layout out to list other post categorically. Hope this helps to someone. Please do post your feedbacks.</p>
<div id="attachment_226" class="wp-caption alignnone" style="width: 263px"><img src="http://subesh.com.np/wp-content/uploads/2010/03/frontend-253x300.png" alt="Frontend Screen Shots" title="Frontend Screen Shots" width="253" height="300" class="size-medium wp-image-226" /><p class="wp-caption-text">Frontend Screen Shots</p></div>
]]></content:encoded>
			<wfw:commentRss>http://subesh.com.np/2010/03/magento-module-release-layout-list-post-aw-blog-basis-category-identifier/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Creating Block From the Code in Magento</title>
		<link>http://subesh.com.np/2009/12/creating-block-code-magento/</link>
		<comments>http://subesh.com.np/2009/12/creating-block-code-magento/#comments</comments>
		<pubDate>Fri, 25 Dec 2009 13:15:43 +0000</pubDate>
		<dc:creator>Subesh Pokhrel</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Block]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[Import]]></category>
		<category><![CDATA[Layout]]></category>
		<category><![CDATA[Map Type]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://subesh.com.np/?p=164</guid>
		<description><![CDATA[Here are some methods of creating block by code in Magento. This type of code can be used directly in template, not need to create a layout file or add a child node inside already existing layout file. You can use this to echo a different type of block inside already loading block and template. [...]]]></description>
			<content:encoded><![CDATA[<p>Here are some methods of creating block by code in Magento. This type of code can be used directly in template, not need to create a layout file or add a child node inside already existing layout file. You can use this to echo a different type of block inside already loading block and template.</p>
<pre class="brush: php; title: ; notranslate">
// Directly in the PHTML where you want to show the block
&lt;?php
echo $this-&gt;getLayout()-&gt;createBlock(&quot;module/block&quot;)-&gt;setTemplate(&quot;module/page.phtml&quot;)-&gt;toHtml();
?&gt;
</pre>
<p>What we have actually done is just load the layout and create an instance of a block class defined inside its paramerter, then assigned a template to the block and finally echoed as html. Simple! The code above will be equivalent to what we do as following in layout and in template file.</p>
<pre class="brush: xml; title: ; notranslate">
// In layout
&lt;block type=&quot;module/block&quot; name=&quot;module.name&quot; template=&quot;module/page.html&quot;/&gt;
</pre>
<pre class="brush: php; title: ; notranslate">
&lt;?php
// In parent PHTML
$this-&gt;getChildHtml(&quot;module.name&quot;);
?&gt;
</pre>
<p>May be helpful!</p>
]]></content:encoded>
			<wfw:commentRss>http://subesh.com.np/2009/12/creating-block-code-magento/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Working with AJAX in Magento</title>
		<link>http://subesh.com.np/2009/11/working-with-ajax-in-magento/</link>
		<comments>http://subesh.com.np/2009/11/working-with-ajax-in-magento/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 13:50:14 +0000</pubDate>
		<dc:creator>Subesh Pokhrel</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Magento]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Block]]></category>
		<category><![CDATA[Controllers]]></category>
		<category><![CDATA[Layout]]></category>

		<guid isPermaLink="false">http://subesh.com.np/?p=82</guid>
		<description><![CDATA[Ajax in Magento can be pretty troublesome.Because you will need to take controllers and layout into account.And I almost used up a whole day trying to make ajax work. Here are some of the steps I&#8217;d like to share so that you will not waste lots of your time, before making this work . Let&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>Ajax in Magento can be pretty troublesome.Because you will need to take controllers and layout into account.And I almost used up a whole day trying to make ajax work. Here are some of the steps I&#8217;d like to share so that you will not waste lots of your time, before making this work <img src='http://subesh.com.np/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> .<br />
Let&#8217;s first know in Magento terms what we need.</p>
<p><strong>Controller:</strong> The url on which Ajax will work on, or the request URL. You will have to set up the controller with its frontend router set in config.xml and its corresponding controller class.<br />
<strong>Layout:</strong> Layout to handle the requested URL and return HTML if required.<br />
<strong>Block:</strong> The block to call through layout for the above controller.</p>
<p>Now lets be descriptive.</p>
<p>If you want to show a loader while request is being processed just add the following whereever you like in the phtml page.First fetch the Javascript.</p>
<pre class="brush: jscript; title: ; notranslate">
&lt;script src=&quot;&lt;?php echo $this-&gt;getJsUrl() ?&gt;mage/adminhtml/loader.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
</pre>
<p>Then echo the loader which pops up. This loader will be similar to that of the admin.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;div id=&quot;loadingmask&quot; style=&quot;display: none;&quot;&gt;
&lt;div class=&quot;loader&quot; id=&quot;loading-mask-loader&quot;&gt;&lt;img src=&quot;&lt;?php echo str_replace(&quot;index.php/&quot;,&quot;&quot;,$this-&gt;getUrl()) ?&gt;skin/adminhtml/default/default/images/ajax-loader-tr.gif&quot; alt=&quot;&lt;?php echo $this-&gt;__('Loading...') ?&gt;&quot;/&gt;&lt;?php echo $this-&gt;__('Loading...') ?&gt;&lt;/div&gt;
&lt;div id=&quot;loading-mask&quot;&gt;&lt;/div&gt;
&lt;/div&gt;
</pre>
<p>Now to Call Ajax, use the following lines</p>
<pre class="brush: jscript; title: ; notranslate">

/*Please note that the URL is created in reloadurl. Also see that the response text will be echoed in div with id=output-div*/

var reloadurl = '&lt;?php echo $this-&gt;getUrl('router/controller/action') ?&gt;';
Element.show('loadingmask');
new Ajax.Request(reloadurl, {
method: 'post',
parameters: &quot;Params_Here&quot;,
onComplete: function(transport) {
Element.hide('loadingmask');
$('output-div').innerHTML = &quot;&quot;;
$('output-div').innerHTML = transport.responseText;

}
});
</pre>
<p>After the Ajax Request is made it goes to your controller&#8217;s action, which in turn sees to your layout as follows:</p>
<pre class="brush: php; title: ; notranslate">
class Namespace_module_frontendController extends Mage_Core_Controller_Front_Action
{
public function actionAction(){
$this-&gt;loadLayout()-&gt;renderLayout();
}
}
</pre>
<p>And here is the main part in layout where I spent most of my time in. Since in layout we will have to define reference where the html will echo (Most of the times), i got stuck here, because i need to echo the output on the div with id output-div not in any reference.And the trick is to name the layout as root and output as html. Like the following:</p>
<pre class="brush: xml; title: ; notranslate">

&lt;module_controller_action&gt;
&lt;block type=&quot;module/block&quot;  name=&quot;root&quot; output=&quot;toHtml&quot;  template=&quot;module/template.phtml&quot;/&gt;
&lt;/module_controller_action&gt;
</pre>
<p>You are done now! What ever you write or echo in phtml file you will see populated in the DIV. Now you can treat block as normally as you do before.</p>
<p>Happy Coding!!</p>
]]></content:encoded>
			<wfw:commentRss>http://subesh.com.np/2009/11/working-with-ajax-in-magento/feed/</wfw:commentRss>
		<slash:comments>41</slash:comments>
		</item>
	</channel>
</rss>

