<?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>Tips for Twits&#187; development</title>
	<atom:link href="http://t.wits.sg/category/dev/feed/" rel="self" type="application/rss+xml" />
	<link>http://t.wits.sg</link>
	<description>WARNING: excessive use of this site will increase MP at the expense of HP</description>
	<lastBuildDate>Tue, 12 Jul 2011 15:09:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Howto: Backup Microsoft SQL Server Database, as in Dump it to a SQL Script (like MYSQL&#8217;s sqldump)</title>
		<link>http://t.wits.sg/2009/08/12/howto-backup-microsoft-sql-server-database-as-in-dump-it-to-a-sql-script-like-mysqls-sqldump/</link>
		<comments>http://t.wits.sg/2009/08/12/howto-backup-microsoft-sql-server-database-as-in-dump-it-to-a-sql-script-like-mysqls-sqldump/#comments</comments>
		<pubDate>Wed, 12 Aug 2009 08:14:44 +0000</pubDate>
		<dc:creator>vid</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[howto]]></category>

		<guid isPermaLink="false">http://t.wits.sg/?p=342</guid>
		<description><![CDATA[How to backup Microsoft SQL Server Database, as in Dump it to a SQL Script (like MYSQL's sqldump)]]></description>
			<content:encoded><![CDATA[<p>Something as simple as getting the sql dump of a database in Microsoft SQL Server (2000, 2005 et al) to a SQL file could be quite a bit complicated (atleast more so as compared to the way we do it in MYSQL). SQL Server Management Studio does a good job of creating scripts that can help you recreate Database Schema. But when it comes to recreating the real Database data through SQL scripting sadly it simply just doesn&#8217;t have any simple method to accomplish it (as far as I know it).</p>
<p>The best way to accomplish this MS SQL is by using <a href="http://sqlhost.codeplex.com/Wiki/View.aspx?title=Database%20Publishing%20Wizard">Microsoft SQL Server Database Publishing Wizard 1.1</a>.  It seems to be a pretty good tool because of its simplicity, stability, accuracy and ease of use. Once you download &#038; install it, you can choose either the tool&#8217;s GUI or the command line interface to  generate a single SQL script file which can be used to recreate a database (both schema and data). What is mire, there is even a bonus feature of being integrable with Visual Studio!</p>
<p>Download it from the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=56E5B1C5-BF17-42E0-A410-371A838E570A&#038;displaylang=en">Microsoft Download Page for Microsoft SQL Server Database Publishing Wizard 1.1</a> </p>
]]></content:encoded>
			<wfw:commentRss>http://t.wits.sg/2009/08/12/howto-backup-microsoft-sql-server-database-as-in-dump-it-to-a-sql-script-like-mysqls-sqldump/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Managing client&#8217;s expectation with wireframe software</title>
		<link>http://t.wits.sg/2009/08/06/better-work-flow-with-wireframe-software/</link>
		<comments>http://t.wits.sg/2009/08/06/better-work-flow-with-wireframe-software/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 04:33:01 +0000</pubDate>
		<dc:creator>donald</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[howto]]></category>

		<guid isPermaLink="false">http://t.wits.sg/?p=339</guid>
		<description><![CDATA[Using wireframe software results in better communication within the team, saves money and time, and helps you manage client's expectation.]]></description>
			<content:encoded><![CDATA[<p>An important component of my role as UI designer and Project Manager at <a href="http://www.savantdegrees.com">Savant Degrees</a> involves prototyping application concepts for clients, as well as in-house product ideas. Ever since <a href="http://www.savantdegrees.com/">Savant Degrees</a> started out, we have been working with people from all walks of life – partners who are graphic designer, client who play an active role, new experience team members, etc. I have to admit that working with someone new can really be a pain at times. Especially when the different groups speak in different languages (the design team, the HCI team, the development team and the project managers, etc).</p>
<p>I’m sure many of us know what a wireframe is, but how many of us use a proper software to work on a wireframe? For the benefit of people who are new to the term, it simply meant a visual presentation used in web design. Previously, I build simple HTML or drew simple shapes in word document and run through the process with the web developers. After some time, I turn to mockup softwares. I was happy with some but not as much as with Axure.</p>
<p>Before I talk about the tool, I like to explain why it is so important to use mockups.</p>
<ol>
<li>Designing wireframes the right way the first time, cost no more than doing it the wrong way. Creating a paper prototype adds no cost, either- simply print out the wireframe diagrams for the pages a visitor will use to complete the tasks most closely related to achieving his goals and meeting the site&#8217;s business objectives.</li>
<li>Web Prototyping saves costs of any marketing communication that may be necessary to undo brand damage resulting from poorly functioning web site and a frustrating user experience. Expensive site redesigns are often undertaken to correct those kinds of problems. Adding a few days to create a wireframe and test a prototype ensures that the redesigned site won&#8217;t introduce any new causes for user frustration or further erosion of brand equity.</li>
<li>Using simple shapes lets you focus on the information design first, to make sure it meets users needs, before moving on to the pretty pictures. For an existing site, wireframes are abstracted from screen shots, with new content, functional, and navigational elements sketched in.</li>
</ol>
<p>Usually, your client will want to see visual designs as early as possible in the project. If possible, try to delay giving them a design, not before them the mockup.</p>
<p>Why?</p>
<p>One very important reason is to save money and time. Why spend on graphics before the underlying information design is complete?</p>
<p>Equally important, colors, fonts and stylistic treatments of logos and other graphical elements can invoke emotional responses (“I hate this pink”; “I love that blue”; “That version of the logo makes me ill”) that distract from the task of determining the best information design for the page.</p>
<p>A wireframe diagrams lets everybody focus on what’s important at this step: clearly understanding what goes on each page, where it goes, and why it goes there, so you can achieve the best overall balance and structure for each page. A wireframe is a sketch of a page-layout idea. The sketch may be rendered in the computer using an illustration application or hand-drawn on paper. Either method is fine, as long as it clearly communicates your ideas.</p>
<p>The information design will evolve as wireframe diagrams change, incorporating results from the usability test at the end of this step, to reflect placement of page elements in ways that better meet user needs. Keeping the information design flexible at this stage will help you create a more positive brand experience over the long term, so you don’t want anyone to develop partisan attachments to a particular look this early in the game.</p>
<p>Despite all that was said. Its sometime hard to say no to your clients request when they have more power over you. Hence, how you manage your project depends on the type of project, your relationship with the client, and your company’s work culture.</p>
<p><strong>Note for Visual Designers</strong></p>
<p>At this point in the process, visual designers should conduct exploratory meetings to understand the client’s visual preferences and the visual elements of the client’s brand. Wait until wireframes are set before showing visual-design treatments of the pages to the client.</p>
<p><strong>Note for Clients</strong></p>
<p>For clients who insist on seeing visuals earlier rather than later, you can ask visual designers to design page mock-ups representing possible colors, imagery, and look and feel – possible styles of what is being considered – at this stage. However, you should do this only if absolutely necessary – that is, if they won’t take no for an answer – and be sure to emphasize that these mock-ups in no way reflect the final designs (repeat this warning early and often).</p>
<p>Caution the people in the site-owning organization against developing any attachments to these mock-ups, because such attachments will make it difficult it change the visual design later on. Chances are these people will not be happy when they see the final design with text, links and information added to it. Focusing only on wireframes at this stage helps you avoid building unrealistic expectations about the site’s final look and feel, guarding maximum flexibility to evolve the site’s information design as necessary.</p>
<p><strong>What I use</strong></p>
<p>Now, let’s go on to why I personally choose Axure and what it can do for you. Do check out their website, www.axure.com for some videos. Do note that there are many mockup software out there and you should check them out before making a decision. For a good list, check out http://www.sitepoint.com/print/tools-prototyping-wireframing/</p>
<p>Axure RP Pro</p>
<p>* Price: USD$589 – Single User License (Discounted to $539 for 5+ Licenses)</p>
<p>* OS Compatability: Windows 2000, XP, 2003 Server or Vista</p>
<p>Axure allows the tagging of elements with functional specifications, which is excellent when a wireframe itself will not provide adequate information to allow a programmer to code the feature. Having said that, a programmer will normally prefer to receive specifications whether they be tagged to an element or written in a wiki, rather than code based on an interpretation of a wireframe.</p>
<p>I use Axure when I am planning a medium to large scale application which requires documentation (Axure exports all tagged specifications into a neatly laid out document – a big time saver!), functional specifications and HTML prototype (Axure will generate an HTML prototype for you – another time saver, however if you take a look at the code you’ll realise that there is no way it could be used as a basis for the actual production application. Use the prototype to display UX concepts and provide clients with a realistic and tangible model for feedback.)</p>
<p>I could go on for pages about what the product accomplish, but I believe their website, www.axure.com, do a better job in selling their products than in I do. Furthermore, it is not the purpose of this article to review this particular software.</p>
<p>By the way, did I mention I got my copy of Axure for free back when I was a student? Axure gives out free licenses to “good student”. Just email Axure and show them your transcript. See <a href="http://www.axure.com/learnMoreBuy.aspx">http://www.axure.com/learnMoreBuy.aspx</a> for more info.</p>
]]></content:encoded>
			<wfw:commentRss>http://t.wits.sg/2009/08/06/better-work-flow-with-wireframe-software/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Howto: Repackageable custom extension development in Magento &#8211; Part 9 &#8211; Frontend &#8211; List</title>
		<link>http://t.wits.sg/2009/06/22/howto-repackageable-custom-extension-development-in-magento-part-9-frontend-list/</link>
		<comments>http://t.wits.sg/2009/06/22/howto-repackageable-custom-extension-development-in-magento-part-9-frontend-list/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 07:47:13 +0000</pubDate>
		<dc:creator>gaweee</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[backend]]></category>
		<category><![CDATA[db]]></category>
		<category><![CDATA[ecommerce]]></category>
		<category><![CDATA[frontend]]></category>
		<category><![CDATA[magento]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://t.wits.sg/?p=327</guid>
		<description><![CDATA[Download the source for this entire series here! Frontend &#8211; List Let us revisit our frontend controller. Surely by now you&#8217;ve gotten a better grasp of the controller and models. So we&#8217;ll be revisiting those concepts here. So lets say you want to allow users to view you current Twits as well as create a [...]]]></description>
			<content:encoded><![CDATA[<div class="contentblock">
<h4>Download the source for this entire series here! <a href="http://t.wits.sg/downloads/magento-tutorial.zip"><img src="http://t.wits.sg/wp-content/uploads/2009/03/download.png" alt="" title="download Magento Tutorial" /></a></h4>
</div>
<div class="h_l">
<div></div>
</div>
<h3>Frontend &#8211; List</h3>
<p>Let us revisit our frontend controller. Surely by now you&#8217;ve gotten a better grasp of the controller and models. So we&#8217;ll be revisiting those concepts here. So lets say you want to allow users to view you current Twits as well as create a new Tip. </p>
<ol>
<li>Some new file structure loving

<div class="wp_syntax"><div class="code"><pre class="dos" style="font-family:monospace;">app/
  design/
    frontend/
      base/
        default/
          template/
            twits/
              - tip_list.phtml
  etc/
    modules/
      - SavantDegrees_All.xml <span style="color: #33cc33;">(</span>Or what ever your company name might be<span style="color: #33cc33;">)</span>
  code/
    local/
      SavantDegrees/ <span style="color: #33cc33;">(</span>Or what ever your company name might be<span style="color: #33cc33;">)</span>
        Twits/ <span style="color: #33cc33;">(</span>Or whatever your module name might be<span style="color: #33cc33;">)</span>
          Block/
            Admin/
              - Main.php
              Main/
                - Grid.php
              - Edit.php
              Edit/
                - Form.php
              - New.php
              New/
                - Form.php
            - HelloWorld.php
            - Index.php
          controllers/
            - AdminController.php
            - IndexController.php
          etc/
            - config.xml
          Helper/
            - Data.php
          Model/
            - Tip.php
            Mysql4/
              - Tip.php
              Tip/
                - Collection.php
          sql/
            twits_setup/
              - mysql4-install-0.2.0.php
              - mysql4-upgrade-0.1.0-0.2.0.php</pre></div></div>

<p>We&#8217;ve added a whole nasty branch of subdirectories under <code>app/designs</code>. Read on to understand what its all for&#8230;
</li>
<li>Let us return to our <code>IndexController.php</code>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> SavantDegrees_Twits_IndexController <span style="color: #000000; font-weight: bold;">extends</span> Mage_Core_Controller_Front_Action
<span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> indexAction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">loadLayout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getLayout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getBlock</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'content'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">append</span><span style="color: #009900;">&#40;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getLayout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createBlock</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits/index'</span><span style="color: #009900;">&#41;</span>
    	<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">renderLayout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Hold your horses, this code is EXACTLY the same as the Part 1. Its just a revision. However, that being said, we see that in Part 1, we made the system create a <code>Block</code> called <code>index</code>. That&#8217;s an opening&#8230;</li>
<li>So let us modify our <code>Index.php</code> block:

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> SavantDegrees_Twits_Block_Index <span style="color: #000000; font-weight: bold;">extends</span> Mage_Core_Block_Template
<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        parent<span style="color: #339933;">::</span>__construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setTemplate</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits/tip_list.phtml'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getTips<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
    	<span style="color: #000088;">$model</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">getModel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits/tip'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    	<span style="color: #000088;">$collection</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$model</span>
    	    	<span style="color: #339933;">-&gt;</span><span style="color: #004000;">getCollection</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    	    	<span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$collection</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getItems</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>What the difference here? We made the block load the template from <code>twits/tip_list.phtml</code>. We can create/find this file in <code>/app/design/frontend/default/default/template/twits/tip_list.phtml</code>. Some explanation is due here:
<ul>
<li>When you say <code>setTemplate</code> in the block, it means, use this file as the presentation/view</li>
<li>This file exists in the some subdirectory of <code>/app/design/frontend/default/default/template</code>. That is the path to your default template. Even though you may have other templates, this is the default 1. So when Magento cant find your template file in the other template directories, it always reverts back to this folder. Its a directory form of inheritance/ancestory/precedence.
<li>
</ul>
</li>
<li>Lastly, the <code>tip_list.phtml</code> file:

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;?php
$_tips = $this-&gt;getTips();
if ($_tips) {
	$count = 0;
	foreach ($_tips as $i=&gt;$tip) {
?&gt;
		&lt;div class=&quot;tip&quot;&gt;
			&lt;div class='title'&gt;&lt;?= $tip-&gt;getTitle() ?&gt;&lt;/div&gt;
			&lt;div class='author'&gt;&lt;?= $tip-&gt;getAuthor() ?&gt;&lt;/div&gt;
			&lt;p&gt;&lt;?= $tip-&gt;getContents() ?&gt;&lt;/p&gt;
		&lt;/div&gt;
&lt;?php
	}
}
?&gt;</pre></div></div>

<p>Since the whole purpose of <code>tip_list.phtml</code> is to prepare the view for the list of tips, it obviously needs to get the data from somewhere. It turns out, the <code>Template</code> is the extension of the <code>Block</code>. So by calling <code>$this->getTips()</code>, we&#8217;re calling the <code>Block's</code> <code>getTips()</code> method.
</li>
<li>There you have it! check your tips list at <a href="http://127.0.0.1/magento/index.php/twits">http://127.0.0.1/magento/index.php/twits</a></li>
<div class="h_l">
<div></div>
</div>
<p>If it works for you, leave a comment! =)</p>
]]></content:encoded>
			<wfw:commentRss>http://t.wits.sg/2009/06/22/howto-repackageable-custom-extension-development-in-magento-part-9-frontend-list/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>JQuery Progress Bar 2.0</title>
		<link>http://t.wits.sg/2009/06/21/jquery-progress-bar-2-0/</link>
		<comments>http://t.wits.sg/2009/06/21/jquery-progress-bar-2-0/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 02:39:49 +0000</pubDate>
		<dc:creator>gaweee</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[frontend]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[progressbar]]></category>

		<guid isPermaLink="false">http://t.wits.sg/?p=320</guid>
		<description><![CDATA[Hi all its us again, In the past few months we&#8217;ve been asked many a times to help improve the progressbar code. We&#8217;ve also been referenced by several websites as THE progressbar to use. In all, we felt we owed it to you guys to make it better. So here we are, after all those [...]]]></description>
			<content:encoded><![CDATA[<div style="float: left; margin: 0px 10px 10px 0px;"><a href="http://t.wits.sg/wp-content/uploads/2008/06/jqueryprogressbar.jpg"><img class="alignnone size-medium wp-image-11" title="jQuery progressBar" src="http://t.wits.sg/wp-content/uploads/2008/06/jqueryprogressbar.jpg" alt="jQuery progressBar screenshot" width="200" height="200" /></a></div>
<p>Hi all its us again, In the past few months we&#8217;ve been asked many a times to help improve the progressbar code. We&#8217;ve also been referenced by several websites as THE progressbar to use. In all, we felt we owed it to you guys to make it better.</p>
<p>So here we are, after all those emails and bug reports, we finally got down to it. Always good to take a couple of months to have a fresh prespective of things. We ripped out the old code and made it much better and more extensible than its predecessors. So much that we decided it was enough to qualify as a major revision.</p>
<div style="clear: both">&nbsp;</div>
<p>Let see whats been done&#8230;</p>
<ul>
<li>Cleaned up the code, yes its lighter, cleaner faster. (Still lacks documentation though) <img src='http://t.wits.sg/wp-includes/images/smilies/icon_neutral.gif' alt=':|' class='wp-smiley' /> </li>
<li>Callbacks! Everyone&#8217;s favourite</li>
<li>Max values, you can now set it to be 150/2000 instead of just a percentage</li>
<li>Text formats. Show 75/100 or 75% by toggling the <code>textFormat</code> accordingly</li>
<li>Steps, how many steps to get to your target value</li>
<li>Step Duration, how long each step lasts</li>
<li>Webkit (Chrome/Safari) compatibility. More like, Webkit Hacks</li>
</ul>
<p>Once again, many a thanks for all those who have so generously provided the feature requests as well as bug fixes every now and then. And thanks for all your patience in waiting for this new release. <img src='http://t.wits.sg/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /><br />
If its working for you, drop us a comment and tell us where we can see your stuff!</p>
<p><strong>Download the new jQuery progressbar here: <a href="http://t.wits.sg/jquery-progress-bar/" target="_blank">jQuery progressbar<br />
</a>or view the demo <a href="http://t.wits.sg/misc/jQueryProgressBar/demo.php" target="_blank">here</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://t.wits.sg/2009/06/21/jquery-progress-bar-2-0/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>HOWTO: Find icons for your new prototype system</title>
		<link>http://t.wits.sg/2009/06/14/howto-find-icons-for-your-new-prototype-system/</link>
		<comments>http://t.wits.sg/2009/06/14/howto-find-icons-for-your-new-prototype-system/#comments</comments>
		<pubDate>Sun, 14 Jun 2009 14:08:11 +0000</pubDate>
		<dc:creator>gaweee</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[frontend]]></category>
		<category><![CDATA[icons]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://t.wits.sg/?p=284</guid>
		<description><![CDATA[Having a good UI is 30% of your customer won. No i dont know, 30% was completely arbitrary but absolutely believable. As such, please dont try to make those icons yourself! As all developers know, we try our best not to reinvent the wheel. Unless the wheel sucks and we have the budget, then we [...]]]></description>
			<content:encoded><![CDATA[<p>Having a good UI is 30% of your customer won. No i dont know, 30% was completely arbitrary but absolutely believable. As such, please dont try to make those icons yourself! As all developers know, we try our best not to reinvent the wheel. Unless the wheel sucks and we have the budget, then we knock ourselves out. <img src='http://t.wits.sg/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /><br />
So its time to share those little icon secrets! Where do you find nice icons!?</p>
<ul>
<li><strong><a href="http://www.famfamfam.com/">famfamfam</a></strong>. If you dont know this site, you should be SHOT. Mark James spent good time making a fantastic set of icons so that everyone else could use them. Kudos to him!</li>
<li><strong><a href="http://www.everaldo.com/crystal/?action=downloads">crystal icons</a></strong>Another awesome job done by Everaldo. Download link&#8217;s not working. Use <a href="http://www.crystalxp.net/galerie/num.4538.htm">this</a> instead. Made primarily for the KDE workspace. Which brings us to my next point</li>
<li>Any other Linux icons sources. These includes <a href="http://www.kde-look.org">kde-look</a>, <a href="http://tango.freedesktop.org/Tango_Icon_Library">tango</a>, <a href="http://interfacelift.com">interfacelift</a>, <a href="http://www.deviantart.com">deviantart</a></li>
<li><a href="http://www.iconfinder.net/">Iconfinder</a>. Its new, its awesome and apparently they&#8217;re license-friendly! If everything&#8217;s as promised, they&#8217;re gonna kick some serious internet butt! We&#8217;re fans already!</li>
<li>Ok we admit, sometimes we&#8217;re really tempted to use existing packages icons. <a href="http://joomla.org">Joomla</a> has a really nice set. <img src='http://t.wits.sg/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </li>
</ul>
<p>All in all, plenty of icons. And if that doesnt work out. Go buy some from <a href="http://www.istockphoto.com">istockphoto </a>and <a href="http://www.sxc.hu">stock.xchng</a>! They&#8217;re the pros for a good reason!<br />
And a final word in licensing. Respect it.  Not so much for the hard work, but more for the fact that designers can do what we cannot. Even if we tried, we probably wouldn&#8217;t have as much flair. Just like magicians.</p>
]]></content:encoded>
			<wfw:commentRss>http://t.wits.sg/2009/06/14/howto-find-icons-for-your-new-prototype-system/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Google Maps Helper</title>
		<link>http://t.wits.sg/2009/06/14/google-maps-helper/</link>
		<comments>http://t.wits.sg/2009/06/14/google-maps-helper/#comments</comments>
		<pubDate>Sun, 14 Jun 2009 13:51:15 +0000</pubDate>
		<dc:creator>gaweee</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[frontend]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[maps]]></category>

		<guid isPermaLink="false">http://t.wits.sg/?p=281</guid>
		<description><![CDATA[In our work we like to create Google Maps links for our client&#8217;s (offices, stores, etc). However, the larger our clients presence, the more random links there are bound to be. When it comes to using Google Map&#8217;s javascript API to control the map, thats still perfectly fine. But how do I create a google [...]]]></description>
			<content:encoded><![CDATA[<p>In our work we like to create Google Maps links for our client&#8217;s (offices, stores, etc). However, the larger our clients presence, the more random links there are bound to be. When it comes to using Google Map&#8217;s javascript API to control the map, thats still perfectly fine. But how do I create a google maps link that only shows 1 entry? Turns out, there are several ways to do this:</p>
<ol>
<li><strong>Manipulate the request such that it only shows your entry</strong>How? For example, searching for &#8220;Holland, Singapore&#8221; will lead us to about 1,356 results. See <a href="http://www.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=holland,+Singapore&amp;mrt=yp&amp;sll=1.305855,103.786876&amp;sspn=0.008055,0.016522&amp;ie=UTF8&amp;z=14">here</a>. So lets tweak it a little:
<ul>
<li>Append <code>&amp;mrt=yp</code> to the url &#8211; That returns us all the business listings. (852 results)</li>
<li>Append <code>&amp;start=16</code> to the url &#8211; That skips the first 16 results (Shows results 17-26 of 852)</li>
<li>Append <code>&amp;num=2</code> to the url &#8211; That returns us only 2 results (Only shows 2 results)</li>
</ul>
<p>For a more complete listing of Google Maps Parameters, consult <a href="http://mapki.com/wiki/Google_Map_Parameters">mapki.com</a>. Kudos to those guys for compiling that list. Really useful stuff<br />
So there you have it, a simple way to link your business such that its the only entry there. However this method is relatively dangerous. Why? Cause you&#8217;ve got no idea of the exact ordering that Google maps may return. Today you could be entry 17, surely not in a year (hopefully for the better). As such, this is not the recommended solution.</li>
<li><strong>Use the address with your long/lat coordinates to generate your entry.</strong>
<ul>
<li> First get your GPS coordinates, there are a number of ways to do this. Check our this <a href="http://en.wikipedia.org/wiki/Geographic_coordinates_(obtaining)">link</a></li>
<li>Then create your link via the following structure: <code>http://www.google.com/maps?&amp;ie=UTF8&amp;hl=en&amp;q=[urlescaped address]&amp;ll=[GPS lat,long]&amp;z=[Zoom]&amp;iwloc=A</code></li>
<li>Still too troublesome? We&#8217;ve created a simple tool for our clients to use. Save yourself some time.  <a href="http://t.wits.sg/misc/googleMapsHelper/demo.php">Try it!</a>
</li>
<p>Done! Whats the downside to this? <strong>You can only show the address for the business</strong>. Because searching by business names returns us way too many results. So instead, we have to search for an address, Google interprets this as an address and only returns 1 result (which is the whole point of geocoding). At this point its easy to the map to what we need. We&#8217;d use this typically for this nifty little &#8220;Find us on a map&#8221; links (instead of embedding the actual map on your site).</ul>
</li>
</ol>
<p>Once again, if you&#8217;d rather embed Google maps directly into your site via the JS, then your options are much more open.<br />
Good luck! Let us know if it works for you, of if you find a better way of doing things!<br />
<a href="http://t.wits.sg/misc/googleMapsHelper/demo.php"><img src="http://t.wits.sg/wp-content/uploads/2009/06/googleMapsHelper-300x291.png" alt="googleMapsHelper" title="googleMapsHelper" width="300" height="291" class="alignnone size-medium wp-image-314" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://t.wits.sg/2009/06/14/google-maps-helper/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Howto: Repackageable custom extension development in Magento &#8211; Part 8 &#8211; CRUD &#8211; Update</title>
		<link>http://t.wits.sg/2009/03/31/howto-repackageable-custom-extension-development-in-magento-part-8-crud-update/</link>
		<comments>http://t.wits.sg/2009/03/31/howto-repackageable-custom-extension-development-in-magento-part-8-crud-update/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 08:27:45 +0000</pubDate>
		<dc:creator>gaweee</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[Add new tag]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[backend]]></category>
		<category><![CDATA[db]]></category>
		<category><![CDATA[ecommerce]]></category>
		<category><![CDATA[magento]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://t.wits.sg/?p=186</guid>
		<description><![CDATA[Download the source for this entire series here! CRUD &#8211; Update Very similar to the Create phase, this phase basically requires the Form and Form Container blocks, and the controller to save them. Thats all! Repeat the file structure goodness: app/ etc/ modules/ - SavantDegrees_All.xml (Or what ever your company name might be) code/ local/ [...]]]></description>
			<content:encoded><![CDATA[<div class="contentblock">
<h4>Download the source for this entire series here! <a href="http://t.wits.sg/downloads/magento-tutorial.zip"><img src="http://t.wits.sg/wp-content/uploads/2009/03/download.png" alt="" title="download Magento Tutorial" /></a></h4>
</div>
<div class="h_l">
<div></div>
</div>
<h3> CRUD &#8211; Update</h3>
<p>Very similar to the Create phase, this phase basically requires the <code>Form</code> and <code>Form Container</code> blocks, and the <code>controller</code> to save them. Thats all!</p>
<ol>
<li>Repeat the file structure goodness:

<div class="wp_syntax"><div class="code"><pre class="dos" style="font-family:monospace;">app/
  etc/
    modules/
      - SavantDegrees_All.xml <span style="color: #33cc33;">(</span>Or what ever your company name might be<span style="color: #33cc33;">)</span>
  code/
    local/
      SavantDegrees/ <span style="color: #33cc33;">(</span>Or what ever your company name might be<span style="color: #33cc33;">)</span>
        Twits/ <span style="color: #33cc33;">(</span>Or whatever your module name might be<span style="color: #33cc33;">)</span>
          Block/
            Admin/
              - Main.php
              Main/
                - Grid.php
              - Edit.php
              Edit/
                - Form.php
              - New.php
              New/
                - Form.php
            - HelloWorld.php
          controllers/
            - AdminController.php
            - IndexController.php
          etc/
            - config.xml
          Helper/
            - Data.php
          Model/
            - Tip.php
            Mysql4/
              - Tip.php
              Tip/
                - Collection.php
          sql/
            twits_setup/
              - mysql4-install-0.2.0.php
              - mysql4-upgrade-0.1.0-0.2.0.php</pre></div></div>

<p>Here we&#8217;ve added the block for the <code>Edit</code> container and <code>Form</code>
</li>
<li>Looking at the <code>Edit.php</code> code:

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> SavantDegrees_Twits_Block_Admin_Edit <span style="color: #000000; font-weight: bold;">extends</span> Mage_Adminhtml_Block_Widget_Form_Container
<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        parent<span style="color: #339933;">::</span>__construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_blockGroup <span style="color: #339933;">=</span> <span style="color: #0000ff;">'twits'</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_mode <span style="color: #339933;">=</span> <span style="color: #0000ff;">'edit'</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_controller <span style="color: #339933;">=</span> <span style="color: #0000ff;">'admin'</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getParam</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_objectId<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$tip</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">getModel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits/tip'</span><span style="color: #009900;">&#41;</span>
                <span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getParam</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_objectId<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            Mage<span style="color: #339933;">::</span><span style="color: #004000;">register</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'frozen_tip'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$tip</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getHeaderText<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Edit Tip'<span style="color: #009933; font-weight: bold;">%s</span>'&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">htmlEscape</span><span style="color: #009900;">&#40;</span>Mage<span style="color: #339933;">::</span><span style="color: #004000;">registry</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'frozen_tip'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>The additional code loads the right <code>Tip</code> data based on the <code>Request</code> parameter, then stores that data in the <code>Mage</code> registry. We&#8217;ll be using that data on the <code>Form</code> page again later to populate the form.<br />
Notice that the saving code is <code>Mage::register</code> and the retrieving code is <code>Mage::registry</code>
</li>
<li>Then the accompanying <code>Edit/Form.php</code> code

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> SavantDegrees_Twits_Block_Admin_Edit_Form <span style="color: #000000; font-weight: bold;">extends</span> Mage_Adminhtml_Block_Widget_Form
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> _prepareForm<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$form</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Varien_Data_Form<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$fieldset</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addFieldset</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'edit_tip'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'legend'</span> <span style="color: #339933;">=&gt;</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Tip Details'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$fieldset</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'title'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'text'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
            <span style="color: #0000ff;">'name'</span>      <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'title'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'title'</span>     <span style="color: #339933;">=&gt;</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Title'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'label'</span>     <span style="color: #339933;">=&gt;</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Title'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'maxlength'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'250'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'required'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$fieldset</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'author'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'text'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
            <span style="color: #0000ff;">'name'</span>      <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'author'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'title'</span>     <span style="color: #339933;">=&gt;</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Author'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'label'</span>     <span style="color: #339933;">=&gt;</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Author'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'maxlength'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'250'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'required'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$fieldset</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'contents'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'textarea'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
            <span style="color: #0000ff;">'name'</span>      <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'contents'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'title'</span>     <span style="color: #339933;">=&gt;</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Contents'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'label'</span>     <span style="color: #339933;">=&gt;</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Contents'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'style'</span>     <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'width: 98%; height: 200px;'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'required'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
 		<span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setMethod</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'post'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setUseContainer</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setId</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'edit_form'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAction</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getUrl</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'*/*/save'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setValues</span><span style="color: #009900;">&#40;</span>Mage<span style="color: #339933;">::</span><span style="color: #004000;">registry</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'frozen_tip'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setForm</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$form</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

</li>
<li>
Then lastly the <code>adminController</code> with its <code>editAction</code> and <code>saveAction</code> to load and save the form respectively</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> SavantDegrees_Twits_AdminController <span style="color: #000000; font-weight: bold;">extends</span> Mage_Adminhtml_Controller_Action
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> indexAction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">loadLayout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #339933;">-&gt;</span>_addContent<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getLayout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createBlock</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits/admin_main'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #339933;">-&gt;</span><span style="color: #004000;">renderLayout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> deleteAction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$tipId</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getParam</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'id'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        try <span style="color: #009900;">&#123;</span>
            Mage<span style="color: #339933;">::</span><span style="color: #004000;">getModel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits/tip'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setId</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tipId</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">delete</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            Mage<span style="color: #339933;">::</span><span style="color: #004000;">getSingleton</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'adminhtml/session'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addSuccess</span><span style="color: #009900;">&#40;</span>Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Tip successfully deleted'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getResponse</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setRedirect</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getUrl</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'*/*/'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> catch <span style="color: #009900;">&#40;</span>Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            Mage<span style="color: #339933;">::</span><span style="color: #004000;">getSingleton</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'adminhtml/session'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addError</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$e</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_redirectReferer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> newAction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">loadLayout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #339933;">-&gt;</span>_addContent<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getLayout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createBlock</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits/admin_new'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #339933;">-&gt;</span><span style="color: #004000;">renderLayout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> postAction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getPost</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$tip</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">getModel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits/tip'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setData</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            try <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$tip</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                Mage<span style="color: #339933;">::</span><span style="color: #004000;">getSingleton</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'adminhtml/session'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addSuccess</span><span style="color: #009900;">&#40;</span>Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Tip successfully saved'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getResponse</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setRedirect</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getUrl</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'*/*/'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> catch <span style="color: #009900;">&#40;</span>Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                Mage<span style="color: #339933;">::</span><span style="color: #004000;">getSingleton</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'adminhtml/session'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addError</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$e</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getResponse</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setRedirect</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getUrl</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'*/*/'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> editAction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">loadLayout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_addContent<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getLayout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createBlock</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits/admin_edit'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">renderLayout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> saveAction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$tipId</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getParam</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'id'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getPost</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$tip</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">getModel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits/tip'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tipId</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addData</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            try <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$tip</span> <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setId</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tipId</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
                Mage<span style="color: #339933;">::</span><span style="color: #004000;">getSingleton</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'adminhtml/session'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addSuccess</span><span style="color: #009900;">&#40;</span>Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Tip successfully saved'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getResponse</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setRedirect</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getUrl</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'*/*/'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> catch <span style="color: #009900;">&#40;</span>Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                Mage<span style="color: #339933;">::</span><span style="color: #004000;">getSingleton</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'adminhtml/session'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addError</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$e</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_redirectReferer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

</li>
<li>
Ok i admit the code is a tad inefficient. We have 2 separate functions that both does save. In fact, <code>postAction</code> and <code>saveAction</code> only differ that saveAction loads the right record via the <code>->load($tipId)</code> function. Thats separates a <code>CREATE</code> from an <code>UPDATE</code> request.</p>
<p>And we&#8217;re finally finally finally done! To test out the edit function, simply click on any row from the  <code>Grid</code>! Thats assuming of course that you actually have some data.<br />
<img src="http://t.wits.sg/wp-content/uploads/2009/03/magento_admin_form.jpg" alt="Magento Admin Form" title="Magento Admin Form" style="border: 1px solid #ddd;"  class="size-full wp-image-210" />
</li>
</ol>
<div class="h_l">
<div></div>
</div>
<p>&raquo; For frontend stuff, carry on &#8230; <a href="http://t.wits.sg/2009/06/22/howto-repackageable-custom-extension-development-in-magento-part-9-frontend-list/">Fontend &#8211; List</a></p>
<p>Otherwise, if it works for you, leave a comment! =)</p>
]]></content:encoded>
			<wfw:commentRss>http://t.wits.sg/2009/03/31/howto-repackageable-custom-extension-development-in-magento-part-8-crud-update/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Howto: Repackageable custom extension development in Magento &#8211; Part 7 &#8211; CRUD &#8211; Create</title>
		<link>http://t.wits.sg/2009/03/31/howto-repackageable-custom-extension-development-in-magento-part-7-crud-create/</link>
		<comments>http://t.wits.sg/2009/03/31/howto-repackageable-custom-extension-development-in-magento-part-7-crud-create/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 08:27:36 +0000</pubDate>
		<dc:creator>gaweee</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[backend]]></category>
		<category><![CDATA[crud]]></category>
		<category><![CDATA[db]]></category>
		<category><![CDATA[ecommerce]]></category>
		<category><![CDATA[magento]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://t.wits.sg/?p=182</guid>
		<description><![CDATA[Download the source for this entire series here! CRUD &#8211; Create More file structure goodness: app/ etc/ modules/ - SavantDegrees_All.xml (Or what ever your company name might be) code/ local/ SavantDegrees/ (Or what ever your company name might be) Twits/ (Or whatever your module name might be) Block/ Admin/ - Main.php Main/ - Grid.php - [...]]]></description>
			<content:encoded><![CDATA[<div class="contentblock">
<h4>Download the source for this entire series here! <a href="http://t.wits.sg/downloads/magento-tutorial.zip"><img src="http://t.wits.sg/wp-content/uploads/2009/03/download.png" alt="" title="download Magento Tutorial" /></a></h4>
</div>
<div class="h_l">
<div></div>
</div>
<h3>CRUD &#8211; Create</h3>
<ol>
<li>More file structure goodness:

<div class="wp_syntax"><div class="code"><pre class="dos" style="font-family:monospace;">app/
  etc/
    modules/
      - SavantDegrees_All.xml <span style="color: #33cc33;">(</span>Or what ever your company name might be<span style="color: #33cc33;">)</span>
  code/
    local/
      SavantDegrees/ <span style="color: #33cc33;">(</span>Or what ever your company name might be<span style="color: #33cc33;">)</span>
        Twits/ <span style="color: #33cc33;">(</span>Or whatever your module name might be<span style="color: #33cc33;">)</span>
          Block/
            Admin/
              - Main.php
              Main/
                - Grid.php
              - New.php
              New/
                - Form.php
            - HelloWorld.php
          controllers/
            - AdminController.php
            - IndexController.php
          etc/
            - config.xml
          Helper/
            - Data.php
          Model/
            - Tip.php
            Mysql4/
              - Tip.php
              Tip/
                - Collection.php
          sql/
            twits_setup/
              - mysql4-install-0.2.0.php
              - mysql4-upgrade-0.1.0-0.2.0.php</pre></div></div>

<p>Here we&#8217;ve added the block for the <code>New</code> container and <code>Form</code>
</li>
<li>Looking at the <code>New.php</code> code:

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> SavantDegrees_Twits_Block_Admin_New <span style="color: #000000; font-weight: bold;">extends</span> Mage_Adminhtml_Block_Widget_Form_Container
<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        parent<span style="color: #339933;">::</span>__construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_blockGroup <span style="color: #339933;">=</span> <span style="color: #0000ff;">'twits'</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_mode <span style="color: #339933;">=</span> <span style="color: #0000ff;">'new'</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_controller <span style="color: #339933;">=</span> <span style="color: #0000ff;">'admin'</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getHeaderText<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Add New Tip'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

</li>
<li>Then the <code>New/Form.php</code> code

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> SavantDegrees_Twits_Block_Admin_New_Form <span style="color: #000000; font-weight: bold;">extends</span> Mage_Adminhtml_Block_Widget_Form
<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> _prepareForm<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$form</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Varien_Data_Form<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$fieldset</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addFieldset</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'new_tip'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'legend'</span> <span style="color: #339933;">=&gt;</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Tip Details'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$fieldset</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'title'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'text'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
            <span style="color: #0000ff;">'name'</span>      <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'title'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'title'</span>     <span style="color: #339933;">=&gt;</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Title'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'label'</span>     <span style="color: #339933;">=&gt;</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Title'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'maxlength'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'250'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'required'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$fieldset</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'author'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'text'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
            <span style="color: #0000ff;">'name'</span>      <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'author'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'title'</span>     <span style="color: #339933;">=&gt;</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Author'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'label'</span>     <span style="color: #339933;">=&gt;</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Author'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'maxlength'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'250'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'required'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$fieldset</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'contents'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'textarea'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
            <span style="color: #0000ff;">'name'</span>      <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'contents'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'title'</span>     <span style="color: #339933;">=&gt;</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Contents'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'label'</span>     <span style="color: #339933;">=&gt;</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Contents'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'style'</span>     <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'width: 98%; height: 200px;'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'required'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setMethod</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'post'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setUseContainer</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setId</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'edit_form'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAction</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getUrl</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'*/*/post'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setForm</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$form</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Just like your listings/grid page, the <code>New.php</code> and <code>Form.php</code> classes are the <code>Form Container</code> and <code>Form</code> respectively. So the <code>Form Container</code> automagically creates the form. Did I mention why containers are good? They come with nice pretty buttons! (Save and Back).
</li>
<li>
Then lastly the <code>adminController</code> with its <code>newAction</code> and <code>postAction</code> to load and save the form respectively</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> SavantDegrees_Twits_AdminController <span style="color: #000000; font-weight: bold;">extends</span> Mage_Adminhtml_Controller_Action
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> indexAction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">loadLayout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #339933;">-&gt;</span>_addContent<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getLayout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createBlock</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits/admin_main'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #339933;">-&gt;</span><span style="color: #004000;">renderLayout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> deleteAction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$tipId</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getParam</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'id'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        try <span style="color: #009900;">&#123;</span>
            Mage<span style="color: #339933;">::</span><span style="color: #004000;">getModel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits/tip'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setId</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tipId</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">delete</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            Mage<span style="color: #339933;">::</span><span style="color: #004000;">getSingleton</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'adminhtml/session'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addSuccess</span><span style="color: #009900;">&#40;</span>Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Tip successfully deleted'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getResponse</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setRedirect</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getUrl</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'*/*/'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> catch <span style="color: #009900;">&#40;</span>Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            Mage<span style="color: #339933;">::</span><span style="color: #004000;">getSingleton</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'adminhtml/session'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addError</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$e</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_redirectReferer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> newAction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">loadLayout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #339933;">-&gt;</span>_addContent<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getLayout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createBlock</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits/admin_new'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #339933;">-&gt;</span><span style="color: #004000;">renderLayout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> postAction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getPost</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$tip</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">getModel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits/tip'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setData</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            try <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$tip</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                Mage<span style="color: #339933;">::</span><span style="color: #004000;">getSingleton</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'adminhtml/session'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addSuccess</span><span style="color: #009900;">&#40;</span>Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Tip was successfully saved'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getResponse</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setRedirect</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getUrl</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'*/*/'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> catch <span style="color: #009900;">&#40;</span>Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                Mage<span style="color: #339933;">::</span><span style="color: #004000;">getSingleton</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'adminhtml/session'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addError</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$e</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getResponse</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setRedirect</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getUrl</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'*/*/'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

</li>
<li>
Reward yourself for your lightning fast copy-and-paste kung foo! Whats happening though?<br />
When the script receives a  call <code>newAction</code>, it&#8217;ll show the form to enter data. The data is posted to the <code>postAction</code> method. That method creates an instance of the model, sets the post data into the model, saves it then redirects it back to the <code>indexAction</code>. Did i mention automagically? Yes, thats why we had to learn so much of the Magento code just to write this simple tutorial.   The sql is automagically generated and run and the form is automagically created! *sheds a tear*</p>
<p>Again, your well deserved create form can be found by clicking on the &#8220;Add New Tip&#8221; button from the <code>Grid</code>!
</li>
</ol>
<div class="h_l">
<div></div>
</div>
<p>&raquo; Just 1 more &#8230; <a href="http://t.wits.sg/2009/03/31/howto-repackageable-custom-extension-development-in-magento-part-8-crud-update/">CRUD &#8211; Update</a></p>
]]></content:encoded>
			<wfw:commentRss>http://t.wits.sg/2009/03/31/howto-repackageable-custom-extension-development-in-magento-part-7-crud-create/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Howto: Repackageable custom extension development in Magento &#8211; Part 6 &#8211; CRUD &#8211; Delete</title>
		<link>http://t.wits.sg/2009/03/31/howto-repackageable-custom-extension-development-in-magento-part-6-crud-delete/</link>
		<comments>http://t.wits.sg/2009/03/31/howto-repackageable-custom-extension-development-in-magento-part-6-crud-delete/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 08:22:25 +0000</pubDate>
		<dc:creator>gaweee</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[backend]]></category>
		<category><![CDATA[crud]]></category>
		<category><![CDATA[db]]></category>
		<category><![CDATA[ecommerce]]></category>
		<category><![CDATA[magento]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://t.wits.sg/?p=178</guid>
		<description><![CDATA[Download the source for this entire series here! CRUD &#8211; Delete The simplest step thus far, add a new function to your AdminController.php 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 &#60;?php class SavantDegrees_Twits_AdminController extends Mage_Adminhtml_Controller_Action [...]]]></description>
			<content:encoded><![CDATA[<div class="contentblock">
<h4>Download the source for this entire series here! <a href="http://t.wits.sg/downloads/magento-tutorial.zip"><img src="http://t.wits.sg/wp-content/uploads/2009/03/download.png" alt="" title="download Magento Tutorial" /></a></h4>
</div>
<div class="h_l">
<div></div>
</div>
<h3>CRUD &#8211; Delete</h3>
<ol>
<li>The simplest step thus far, add a new function to your <code>AdminController.php</code>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> SavantDegrees_Twits_AdminController <span style="color: #000000; font-weight: bold;">extends</span> Mage_Adminhtml_Controller_Action
<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> indexAction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">loadLayout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #339933;">-&gt;</span>_addContent<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getLayout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createBlock</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits/admin_main'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #339933;">-&gt;</span><span style="color: #004000;">renderLayout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> deleteAction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$tipId</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getParam</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'id'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        try <span style="color: #009900;">&#123;</span>
            Mage<span style="color: #339933;">::</span><span style="color: #004000;">getModel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits/tip'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setId</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tipId</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">delete</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            Mage<span style="color: #339933;">::</span><span style="color: #004000;">getSingleton</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'adminhtml/session'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addSuccess</span><span style="color: #009900;">&#40;</span>Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Tip successfully deleted'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getResponse</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setRedirect</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getUrl</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'*/*/'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> catch <span style="color: #009900;">&#40;</span>Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            Mage<span style="color: #339933;">::</span><span style="color: #004000;">getSingleton</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'adminhtml/session'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addError</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$e</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_redirectReferer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

</li>
</ol>
<div class="h_l">
<div></div>
</div>
<p>&raquo; Almost there &#8230; <a href="http://t.wits.sg/2009/03/31/howto-repackageable-custom-extension-development-in-magento-part-7-crud-create/">CRUD &#8211; Create</a></p>
]]></content:encoded>
			<wfw:commentRss>http://t.wits.sg/2009/03/31/howto-repackageable-custom-extension-development-in-magento-part-6-crud-delete/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Howto: Repackageable custom extension development in Magento &#8211; Part 5 &#8211; CRUD &#8211; Retrieve</title>
		<link>http://t.wits.sg/2009/03/31/howto-repackageable-custom-extension-development-in-magento-part-5-crud-retrieve/</link>
		<comments>http://t.wits.sg/2009/03/31/howto-repackageable-custom-extension-development-in-magento-part-5-crud-retrieve/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 08:18:54 +0000</pubDate>
		<dc:creator>gaweee</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[backend]]></category>
		<category><![CDATA[crud]]></category>
		<category><![CDATA[db]]></category>
		<category><![CDATA[ecommerce]]></category>
		<category><![CDATA[magento]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://t.wits.sg/?p=173</guid>
		<description><![CDATA[Download the source for this entire series here! CRUD &#8211; Retrieve Lets add a new block to the file structure app/ etc/ modules/ - SavantDegrees_All.xml (Or what ever your company name might be) code/ local/ SavantDegrees/ (Or what ever your company name might be) Twits/ (Or whatever your module name might be) Block/ Admin/ - [...]]]></description>
			<content:encoded><![CDATA[<div class="contentblock">
<h4>Download the source for this entire series here! <a href="http://t.wits.sg/downloads/magento-tutorial.zip"><img src="http://t.wits.sg/wp-content/uploads/2009/03/download.png" alt="" title="download Magento Tutorial" /></a></h4>
</div>
<div class="h_l">
<div></div>
</div>
<h3>CRUD &#8211; Retrieve</h3>
<ol>
<li>Lets add a new block to the file structure

<div class="wp_syntax"><div class="code"><pre class="dos" style="font-family:monospace;">app/
  etc/
    modules/
      - SavantDegrees_All.xml <span style="color: #33cc33;">(</span>Or what ever your company name might be<span style="color: #33cc33;">)</span>
  code/
    local/
      SavantDegrees/ <span style="color: #33cc33;">(</span>Or what ever your company name might be<span style="color: #33cc33;">)</span>
        Twits/ <span style="color: #33cc33;">(</span>Or whatever your module name might be<span style="color: #33cc33;">)</span>
          Block/
            Admin/
              - Main.php
              Main/
                - Grid.php
            - HelloWorld.php
          controllers/
            - AdminController.php
            - IndexController.php
          etc/
            - config.xml
          Helper/
            - Data.php
          Model/
            - Tip.php
            Mysql4/
              - Tip.php
              Tip/
                - Collection.php
          sql/
            twits_setup/
              - mysql4-install-0.2.0.php
              - mysql4-upgrade-0.1.0-0.2.0.php</pre></div></div>

<p>We&#8217;ll create folder called <code>Admin</code> to store all the admin related blocks. Inside we&#8217;ll have a Main.php file that contains the <code>Grid Container</code>. Why do we need a grid container? To put the title and <code>Create</code> button!
</li>
<li>
The <code>Main.php</code> code</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> SavantDegrees_Twits_Block_Admin_Main <span style="color: #000000; font-weight: bold;">extends</span> Mage_Adminhtml_Block_Widget_Grid_Container
<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_addButtonLabel <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Add New Tip'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        parent<span style="color: #339933;">::</span>__construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_blockGroup <span style="color: #339933;">=</span> <span style="color: #0000ff;">'twits'</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_controller <span style="color: #339933;">=</span> <span style="color: #0000ff;">'admin_main'</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_headerText <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Tips(s)'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Here you see a first use of the helper, which will assist in translation
</li>
<li>
The <code>Grid.php</code> itself</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> SavantDegrees_Twits_Block_Admin_Main_Grid <span style="color: #000000; font-weight: bold;">extends</span> Mage_Adminhtml_Block_Widget_Grid
<span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        parent<span style="color: #339933;">::</span>__construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setId</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'tipsGrid'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_controller <span style="color: #339933;">=</span> <span style="color: #0000ff;">'twits'</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> _prepareCollection<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$model</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">getModel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits/tip'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$collection</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$model</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getCollection</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setCollection</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$collection</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> parent<span style="color: #339933;">::</span>_prepareCollection<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> _prepareColumns<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addColumn</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'tip_id'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
            <span style="color: #0000ff;">'header'</span>        <span style="color: #339933;">=&gt;</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ID'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'align'</span>         <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'right'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'width'</span>         <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'50px'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'filter_index'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'dt.tip_id'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'index'</span>         <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'tip_id'</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addColumn</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
            <span style="color: #0000ff;">'header'</span>        <span style="color: #339933;">=&gt;</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Title'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'align'</span>         <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'left'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'width'</span>         <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'150px'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'filter_index'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'dt.title'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'index'</span>         <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'title'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'type'</span>          <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'text'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'truncate'</span>      <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">50</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'escape'</span>        <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addColumn</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'tags'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
            <span style="color: #0000ff;">'header'</span>    	<span style="color: #339933;">=&gt;</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Author'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'align'</span>         <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'left'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'filter_index'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'dt.author'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'index'</span>    	 	<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'author'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'type'</span>     	 	<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'text'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'escape'</span>		<span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addColumn</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'summary'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
            <span style="color: #0000ff;">'header'</span>        <span style="color: #339933;">=&gt;</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Contents'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'align'</span>         <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'left'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'filter_index'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'dt.contents'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'index'</span>         <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'contents'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'type'</span>          <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'text'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'escape'</span>        <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addColumn</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'action'</span><span style="color: #339933;">,</span>
            <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                <span style="color: #0000ff;">'header'</span>    <span style="color: #339933;">=&gt;</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Action'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'width'</span>     <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'150px'</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'type'</span>      <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'action'</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'getter'</span>	<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'getTipId'</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'actions'</span>   <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                    <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                        <span style="color: #0000ff;">'caption'</span> <span style="color: #339933;">=&gt;</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Edit'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                        <span style="color: #0000ff;">'url'</span>     <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                            <span style="color: #0000ff;">'base'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'*/*/edit'</span>
                         <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                         <span style="color: #0000ff;">'field'</span>   <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'id'</span>
                    <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                    <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                        <span style="color: #0000ff;">'caption'</span> <span style="color: #339933;">=&gt;</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Delete'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                        <span style="color: #0000ff;">'url'</span>     <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                            <span style="color: #0000ff;">'base'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'*/*/delete'</span>
                         <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                         <span style="color: #0000ff;">'field'</span>   <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'id'</span>
                    <span style="color: #009900;">&#41;</span>
                <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'filter'</span>    <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'sortable'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span>
        <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> parent<span style="color: #339933;">::</span>_prepareColumns<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getRowUrl<span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getUrl</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'*/*/edit'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
            <span style="color: #0000ff;">'id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getTipId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>If you scrutinize the code (which i&#8217;d advise against), you&#8217;ll see most of the code is geared towards the setup of the grid columns and the edit/delete urls i&#8217;ll eventually call to perform the other <code>CRUD</code> functions.<br />
But whats going on? Where do we use this code? The main code (being a <code>Grid_Container</code> automatically adds the child <code>Grid</code> code associated to it. By child we&#8217;re talking about the <code>Grid.php</code> file in the <code>Main</code> folder. The folder&#8217;s name follows the file. So if you changed the folder&#8217;s name to <code>Main2</code>, it wouldnt work. That being said, you can just put any block code in the folder and expect it to run. The reason why this all works now is cause the geniuses at Magento already did alot of work to call the Grid child to run. They have no super time travel powers to tell what else you&#8217;re gonna put in there. So, it simply wont work (yet).
</li>
<li>Now lets make our <code>adminController.php</code> use that block instead of Hello world.

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> SavantDegrees_Twits_AdminController <span style="color: #000000; font-weight: bold;">extends</span> Mage_Adminhtml_Controller_Action
<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> indexAction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">loadLayout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #339933;">-&gt;</span>_addContent<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getLayout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createBlock</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twits/admin_main'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #339933;">-&gt;</span><span style="color: #004000;">renderLayout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Well it says <code>createBlock</code> doesnt it? What do you think it does? <code>twits/admin_main</code> as always refers to the twits namespace and the <code>admin/main.php</code> block file.
</li>
<li>Viola! Your very very very hard earned grid!<br />
<img src="http://t.wits.sg/wp-content/uploads/2009/03/magento_admin_grid.jpg" alt="Magento Admin Grid" title="Magento Admin Grid" style="border: 1px solid #ddd;" class="size-full wp-image-204" />
</li>
</ol>
<div class="h_l">
<div></div>
</div>
<p>&raquo; Anytime now &#8230; <a href="http://t.wits.sg/2009/03/31/howto-repackageable-custom-extension-development-in-magento-part-6-crud-delete/">Part 6 &#8211; CRUD &#8211; Delete</a></p>
]]></content:encoded>
			<wfw:commentRss>http://t.wits.sg/2009/03/31/howto-repackageable-custom-extension-development-in-magento-part-5-crud-retrieve/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

