<?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>Grapii &#187; Software Development</title>
	<atom:link href="http://www.grapii.com/category/software-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.grapii.com</link>
	<description>Personal Site of Raj Patel</description>
	<lastBuildDate>Mon, 06 Sep 2010 13:45:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to build a simple search filter with jQuery</title>
		<link>http://www.grapii.com/2010/08/how-to-build-a-simple-search-filter-with-jquery/</link>
		<comments>http://www.grapii.com/2010/08/how-to-build-a-simple-search-filter-with-jquery/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 16:12:00 +0000</pubDate>
		<dc:creator>grapii</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Web Apps]]></category>

		<guid isPermaLink="false">http://www.grapii.com/2010/08/how-to-build-a-simple-search-filter-with-jquery/</guid>
		<description><![CDATA[There are occasions when developing a wed application where you’d like to give users the ability to search or filter the information presented.&#160; For example, a web application may feature a page listing your DVD collection, and you want the users to find the movie they’re looking for quickly and easily.&#160; This article shows you [...]]]></description>
			<content:encoded><![CDATA[<p>There are occasions when developing a wed application where you’d like to give users the ability to search or filter the information presented.&#160; For example, a web application may feature a page listing your DVD collection, and you want the users to find the movie they’re looking for quickly and easily.&#160; This article shows you how little code is need to achieve this functionality using <a href="http://jquery.com/">jQuery</a>.</p>
<p> <span id="more-1113"></span><br />
<h1>jQuery</h1>
<p>First we need to download the <a href="http://code.jquery.com/jquery-1.4.2.min.js">jQuery</a> library file and reference it in our HTML page, alternatively you can reference copies of <a href="http://docs.jquery.com/Downloading_jQuery">jQuery</a> hosted existing networks.</p>
<p>Either way, we need to reference it in our HTML:</p>
<pre>&lt;script src=&quot;http://code.jquery.com/jquery-1.4.2.min.js&quot;&gt;&lt;/script&gt;</pre>
<h1>HTML</h1>
<p>The basic HTML you’ll need for this is simple.&#160; Just a header and an unordered list.&#160; Both elements have id’s so we can easily and uniquely identify them:</p>
<pre>&lt;h1 id=&quot;header&quot;&gt;DVD Collection&lt;/h1&gt;

&lt;ul id=&quot;list&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Batman&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Ice Age&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Star Trek (2009)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Tremors&lt;/a&gt;&lt;/li&gt;
  …
&lt;ul&gt;</pre>
<p>With the HTML ready, here is the functionality we need to implement:</p>
<ol>
<li>Add an input field to the header </li>
<li>Set up events to check when the user is typing in the input field </li>
<li>Check the value of the input, and compare it to the movies in the list </li>
<li>Hide the non-matching movies, while showing the matching ones </li>
</ol>
<h2>Step 1: Add an input field to the header</h2>
<p>We’ll start with a simple function, call it listFilter:</p>
<pre>function listFilter(header, list) {
  …
}</pre>
<p>As you can see the function takes two arguments.&#160; We’ll use jQuery to select the header and list and give them as arguments to our function.&#160; Next we need to create a form with an input field, and append it to the header:</p>
<pre>function listFilter(header, list) {
  // create the filter form and append it to the header element
  var form = $(&quot;&lt;form&gt;&quot;).attr({&quot;class&quot;:&quot;filterform&quot;,&quot;action&quot;:&quot;#&quot;}),
      input = $(&quot;&lt;input&gt;&quot;).attr({&quot;class&quot;:&quot;filterinput&quot;,&quot;type&quot;:&quot;text&quot;});

  $(form).append(input).appendTo(header);
  …
}</pre>
<p>Using <code>$(“form”)</code> we can create new elements, and by inserting the input field into the form using <code>append()</code>. Use the <code>appendTo()</code> function to add the form and input field to the header tag, and we’ve easily added the form to the page.&#160; The classes have also been defined so they can be styled easily in CSS.</p>
<h2>Step 2: Set up events</h2>
<p>To check for text entered into the input field, we can use the <code>Change</code> event.&#160; This is triggered every time the value of the input has changed, but only when you exit the input field.</p>
<p>However, this doesn’t work with a letter-for-letter filter.&#160; For that, we need to watch the <code>Keyup</code> event as well.&#160; We use <code>Keyup</code> instead of <code>Keydown</code> because it is triggered after you release the key, and so the value of the input field includes the just-typed letter.&#160; With <code>Keydown</code>, the event is triggered before the letter is added-as your pressing the key-and therefore JavaScript cannot ascertain the value.</p>
<p>As we’ll be using two events, <code>Change</code> and <code>Keyup</code>, there is no need to double the work, we simply call the <code>Change</code> event when we receive a <code>Keyup </code>event:</p>
<pre>Function ListFilter(Header, List) {
  …
  $(Input).Change( Function () {
    …
  }).Keyup( Function () {
    // call the above change event after every letter typed
    $(This).Change();
  });
  …
}</pre>
<h2>Step 3: Compare the values</h2>
<p>jQuery has a way to check for matched elements easily: the <code>:contains()</code> selector.&#160; Using this, we can very easily select all elements containing the text between the parenthesis:</p>
<pre>function listFilter(header, list) {
  …
  $(input).change( function () {
    var filter = $(this).val();
    // get the value of the input field so we can filter the results

    $(list).find(&quot;a:contains(&quot; + filter + &quot;)&quot;).parent().slideDown();
  });
  …
}</pre>
<p>The code above works like this: within the list, which is the <code>&lt;ul&gt;</code> element, it finds and shows all the <code>&lt;a&gt;</code> elements that contain the value in the input field.&#160; It then selects the <strong>parents</strong> of those <code>&lt;a&gt;</code> elements, the <code>&lt;li&gt;</code>’s.&#160; Those <code>&lt;li&gt;</code>’s are then displayed.</p>
<h2>Step 4: Hide the non-matching elements</h2>
<p>However, since we filter the list, we need to also hide all the <code>&lt;li&gt;</code>’s that <em>do not contain</em> the value in the input field.&#160; For this jQuery offers the <code>:not()</code> selector, and we can wrap that around the <code>:contains()</code> selector like this:</p>
<pre>function listFilter(header, list) {
  …
  $(input).change( function () {
    var filter = $(this).val();
    // get the value of the input field so we can filter the results

    $(list).find(&quot;a:not(:contains(&quot; + filter + &quot;))&quot;).parent().slideUp();
    $(list).find(&quot;a:contains(&quot; + filter + &quot;)&quot;).parent().slideDown();
  });
  …
}</pre>
<p>Now, with each keystroke, we check the list for matching elements and hide the ones that don’t match.</p>
<p>So far so good, but what happens when you clear the value in the input field?&#160; Then <code>$(this).val();</code> will be empty, and nothing matches with empty, so all the list items will be hidden.&#160; Luckily this can be remedied quite easily by checking if <code>$(this).val();</code> has any value, and if it doesn’t then show everything.</p>
<pre>function listFilter(header, list) {
  …
  $(input).change( function () {
    var filter = $(this).val();
    if (filter) {
      $(list).find(&quot;a:not(:contains(&quot; + filter + &quot;))&quot;).parent().slideUp();
      $(list).find(&quot;a:contains(&quot; + filter + &quot;)&quot;).parent().slideDown();
    } else {
      $(list).find(&quot;li&quot;).slideDown();
    }
  });
  …
}</pre>
<p>Typing in the input field now filters down the list, and clearing the field shows the entire-non filtered-list.</p>
<p>You would’ve thought that’s all we need, however <code>:contains()</code> is case-sensitive, so if we filter with the word “madagascar”, we won’t find Madagascar.</p>
<p>jQuery allows you to add your own selector expressions, and we can use that to build our own <em>case-insensitive</em> contains filter:</p>
<pre>jQuery.expr[':'].Contains = function(a,i,m){
    return (a.textContent || a.innerText || &quot;&quot;).toUpperCase().indexOf(m[3].toUpperCase())&gt;=0;
};</pre>
<p>This adds a <code>:Contains()</code> (<em>note the uppercase</em>) option to our selectors that has the same functionality as <code>:contains()</code>, but it first converts the text value to uppercase and then does the comparison.&#160; Once this is added to the JavaScript, all we need to do is replace the <code>:contains()</code> with <code>:Contains()</code> within our listFilter function.</p>
<h2>Demo</h2>
<p>I’ve created two simple examples, the first ones uses the unordered list as described in this tutorial, and the second has the same functionality but uses the <code>&lt;div&gt;</code> elements instead.</p>
<p><a href="http://resource.grapii.com/jQueryFilter/ulExample.html">Simple jQuery filter – unordered list</a></p>
<p><a href="http://resource.grapii.com/jQueryFilter/divExample.html">Simple jQuery filter – div tags</a></p>
<h2>Complete Code</h2>
<p>And finally the entire code used in this tutorial:</p>
<pre>&lt;script src=&quot;http://code.jquery.com/jquery-1.4.2.min.js&quot;&gt;&lt;/script&gt;
&lt;script&gt;
	(function ($) {
	  jQuery.expr[':'].Contains = function(a,i,m){
		  return (a.textContent || a.innerText || &quot;&quot;).toUpperCase().indexOf(m[3].toUpperCase())&gt;=0;
	  };

	  function listFilter(header, list) {
		var form = $(&quot;&lt;form&gt;&quot;).attr({&quot;class&quot;:&quot;filterform&quot;,&quot;action&quot;:&quot;#&quot;}),
			input = $(&quot;&lt;input&gt;&quot;).attr({&quot;class&quot;:&quot;filterinput&quot;,&quot;type&quot;:&quot;text&quot;});
		$(form).append(input).appendTo(header);

		$(input)
		  .change( function () {
			var filter = $(this).val();
			if(filter) {
			  $(list).find(&quot;a:not(:Contains(&quot; + filter + &quot;))&quot;).parent().slideUp();
			  $(list).find(&quot;a:Contains(&quot; + filter + &quot;)&quot;).parent().slideDown();
			} else {
			  $(list).find(&quot;li&quot;).slideDown();
			}
			return false;
		  })
		.keyup( function () {
			$(this).change();
		});
	  }

	  $(function () {
		listFilter($(&quot;#header&quot;), $(&quot;#list&quot;));
	  });
	}(jQuery));
&lt;/script&gt; 

&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;wrap&quot;&gt;
    &lt;h1 id=&quot;header&quot;&gt;DVD Collection&lt;/h1&gt;
    &lt;ul id=&quot;list&quot;&gt;
        &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Batman&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Ice Age&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Star Trek (2009)&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Tremors&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
&lt;/div&gt; </pre>
]]></content:encoded>
			<wfw:commentRss>http://www.grapii.com/2010/08/how-to-build-a-simple-search-filter-with-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Model-View-Controller Design Pattern Part 2</title>
		<link>http://www.grapii.com/2009/12/model-view-controller-design-pattern-part-2/</link>
		<comments>http://www.grapii.com/2009/12/model-view-controller-design-pattern-part-2/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 00:44:00 +0000</pubDate>
		<dc:creator>grapii</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Design Patterns]]></category>

		<guid isPermaLink="false">http://www.grapii.com/2009/12/model-view-controller-design-pattern-part-2/</guid>
		<description><![CDATA[In Part 1 of the series I explained the concept of the Model-View-Controller (MVC) pattern.&#160; This final part shows you how to create an ASP.NET MVC application in Visual Studio. 
 
In this walkthrough, you will create and run the sample MVC application. Then you will customize the application by adding a controller and a [...]]]></description>
			<content:encoded><![CDATA[<p>In Part 1 of the series I explained the concept of the <a href="http://www.grapii.com/2009/11/model-view-controller-design-pattern-part-1/">Model-View-Controller</a> (MVC) pattern.&#160; This final part shows you how to create an ASP.NET MVC application in Visual Studio. </p>
<p> <span id="more-644"></span>
<p>In this walkthrough, you will create and run the sample MVC application. Then you will customize the application by adding a controller and a view.</p>
<h2>Prerequisites</h2>
<p>In order to complete this walkthrough, you will need: </p>
<ul>
<li>Microsoft Visual Studio 2008 Service Pack 1. </li>
<li>ASP.NET MVC 1.0. </li>
</ul>
<p>You can download and install the ASP.NET MVC framework in the following ways: </p>
<ul>
<li>Install the framework using the Microsoft Web Platform Installer. You can download the installer from the <a href="http://go.microsoft.com/fwlink/?LinkID=148931&amp;clcid=0x409">installation page</a> on the Microsoft Web gallery site. </li>
<li>Download the framework from the <a href="http://go.microsoft.com/fwlink/?LinkId=144444">ASP.NET MVC 1.0</a> page on the Microsoft Download Center. </li>
</ul>
<h2>Creating a New MVC Project</h2>
<ol>
<li>On the <strong>File</strong> menu, click <strong>New Project</strong>.       <br />The New Project dialog box is displayed.       <br /><a href="http://www.grapii.com/wp-content/uploads/2010/01/mvc001.png" rel="lightbox[644]"><img style="display: block; float: none; margin-left: auto; margin-right: auto" title="mvc001" alt="mvc001" src="http://www.grapii.com/wp-content/uploads/2010/01/mvc001-thumb.png" width="400" height="323" /></a> </li>
<li>In the upper-right corner, make sure that <strong>.NET Framework 3.5</strong> is selected. </li>
<li>Under <strong>Project types</strong>, expand <strong>Visual Basic</strong> and then click <strong>Web</strong>. </li>
<li>Under <strong>Visual Studio installed templates</strong>, select <strong>ASP.NET MVC Web Application</strong>. </li>
<li>In the <strong>Name</strong> box, enter <strong>MvcBasicWalkthrough</strong>. </li>
<li>In the <strong>Location</strong> box, enter a name for the project folder. </li>
<li>If you want the name of the solution to differ from the project name, enter a name in the <strong>Solution Name</strong> box. </li>
<li>Select <strong>Create directory for solution</strong>. </li>
<li>Click <strong>OK</strong>.       <br />The Create Unit Test Project dialog box is displayed.       <br /><a href="http://www.grapii.com/wp-content/uploads/2010/01/mvc002.png" rel="lightbox[644]"><img style="display: block; float: none; margin-left: auto; margin-right: auto" title="mvc002" alt="mvc002" src="http://www.grapii.com/wp-content/uploads/2010/01/mvc002-thumb.png" width="400" height="260" /></a> </li>
<li>Select <strong>No, do not create a unit test project.</strong> </li>
<li>Click <strong>OK</strong>.       <br />The new MVC application project and a test project are generated. </li>
</ol>
<h2>Examining the MVC Project</h2>
<p>The following illustration shows the folder structure of a newly created MVC solution.&#160; <br /><a href="http://www.grapii.com/wp-content/uploads/2010/01/mvc0031.png" rel="lightbox[644]"><img style="display: block; float: none; margin-left: auto; margin-right: auto" title="mvc003" alt="mvc003" src="http://www.grapii.com/wp-content/uploads/2010/01/mvc003-thumb1.png" width="300" height="341" /></a> </p>
<p>The folder structure of an MVC project differs from that of an ASP.NET Web site project. The MVC project contains the following folders:</p>
<ul>
<li>
<p>Content, which is for content support files. This folder contains the cascading style sheet (.css file) for the application.</p>
</li>
<li>
<p>Controllers, which is for controller files. This folder contains the application&#8217;s sample controllers, which are named <tt>AccountController</tt> and <tt>HomeController</tt>. The <tt>AccountController</tt> class contains login logic for the application. The <tt>HomeController</tt> class contains logic that is called by default when the application starts.</p>
</li>
<li>
<p>Models, which is for data-model files such as LINQ-to-SQL .dbml files or data-entity files.</p>
</li>
<li>
<p>Scripts, which is for script files, such as those that support ASP.NET AJAX and jQuery.</p>
</li>
<li>
<p>Views, which is for view page files. This folder contains three subfolders: Account, Home, and Shared. The Account folder contains views that are used as UI for logging in and changing passwords. The Home folder contains an Index view (the default starting page for the application) and an About page view. The Shared folder contains the master-page view for the application.</p>
</li>
</ul>
<p>The newly generated MVC project is a complete application that you can compile and run without change. The following illustration shows what the application looks like when it runs in a browser.<a href="http://www.grapii.com/wp-content/uploads/2010/01/mvc004.png" rel="lightbox[644]"><img style="display: block; float: none; margin-left: auto; margin-right: auto" title="mvc004" alt="mvc004" src="http://www.grapii.com/wp-content/uploads/2010/01/mvc004-thumb.png" width="400" height="220" /></a>The unit-test project is also ready to compile and run. For this walkthrough, you will add a controller with an action method and a view.</p>
<h2>Adding a Controller</h2>
<p><a></a></p>
<p>You will now add a controller that contains logic for downloading city maps from the Microsoft Virtual Earth Web service.</p>
<ol>
<li>In <strong>Solution Explorer</strong>, right-click the <strong>Controllers</strong> folder, click <strong>Add</strong>, and then click <strong>Controller</strong>.       <br />The Add Controller dialog box is displayed.<a href="http://www.grapii.com/wp-content/uploads/2010/01/mvc005.png" rel="lightbox[644]"><img style="display: block; float: none; margin-left: auto; margin-right: auto" title="mvc005" alt="mvc005" src="http://www.grapii.com/wp-content/uploads/2010/01/mvc005-thumb.png" width="400" height="168" /></a> </li>
<li>In the <strong>Name</strong> box, type <strong>MapsController</strong>.       <br />The ASP.NET MVC framework requires controller names to end with &quot;Controller&quot;, such as <tt>HomeController</tt>, <tt>GameController</tt>, or <tt>MapsController</tt>. </li>
<li>Clear the <strong>Add action methods for Create, Update, and Details scenarios</strong> check box. </li>
<li>Click <strong>Add</strong>.       <br />Visual Studio adds the <tt>MapsController</tt> class to the project and opens it in the editor. </li>
</ol>
<h2>Adding Code to the Action Method</h2>
<p>You will now add code to the <tt>MapsController</tt> class for the <tt>ViewMaps</tt> action method in order to render the <tt>Maps</tt> view.</p>
<ol>
<li>Open the <tt>MapsController</tt> class and replace the <tt>ViewMaps</tt> action-method stub with the following code in order to render the <tt>Maps</tt> view.
<pre>Function ViewMaps() As ActionResult
    Return View()
End Function</pre>
</li>
<li>Save and close the file. </li>
</ol>
<h2>Adding a View</h2>
<p><a></a></p>
<p>Next, you will add a <tt>Maps</tt> view. To keep the views organized, you will first add a Maps folder under the Views folder.</p>
<ol>
<li>Open the <tt>MapsController</tt> class, right-click inside the <tt>ViewMaps</tt> action method, and then click <strong>Add View</strong>.
<p>The Add View dialog box is displayed.</p>
<p><a href="http://www.grapii.com/wp-content/uploads/2010/01/mvc006.png" rel="lightbox[644]"><img style="display: block; float: none; margin-left: auto; margin-right: auto" title="mvc006" alt="mvc006" src="http://www.grapii.com/wp-content/uploads/2010/01/mvc006-thumb.png" width="400" height="410" /></a> </li>
<li>In the <strong>View name</strong> box, enter <strong>ViewMaps.aspx</strong>. </li>
<li>Clear the <strong>Create a partial view (.ascx)</strong> check box and the <strong>Create a strongly-typed view</strong> check box. </li>
<li>Select the <strong>Select master page</strong> check box and set the master page to <strong>~/Views/Shared/Site.Master</strong>. </li>
<li>Set <strong>ContentPlaceHolder ID</strong> to &quot;MainContent&quot;. </li>
<li>Click <strong>Add</strong>.
<p>The new view is added to the project in the Maps folder </li>
</ol>
<h2>Adding Content to the View</h2>
<p>Next, you will add content to the new view.</p>
<ol>
<li>Open ViewMaps.aspx and add the following content inside the <strong>Content</strong> element:
<pre>&lt;h2&gt;My City Maps&lt;/h2&gt;
Select map:
&lt;select onclick=&quot;GetMap(value);&quot;&gt;
    &lt;option value=&quot;Seattle&quot;&gt;Seattle, WA&lt;/option&gt;
    &lt;option value=&quot;LasVegas&quot;&gt;Las Vegas, NV&lt;/option&gt;
    &lt;option value=&quot;SaltLake&quot;&gt;Salt Lake City, UT&lt;/option&gt;
    &lt;option value=&quot;Dallas&quot;&gt;Dallas, TX&lt;/option&gt;
    &lt;option value=&quot;Chicago&quot;&gt;Chicago, IL&lt;/option&gt;
    &lt;option value=&quot;NewYork&quot;&gt;New York, NY&lt;/option&gt;
    &lt;option value=&quot;Rio&quot;&gt;Rio de Janeiro, Brazil&lt;/option&gt;
    &lt;option value=&quot;Paris&quot;&gt;Paris, France&lt;/option&gt;
    &lt;option value=&quot;Naples&quot;&gt;Naples, Italy&lt;/option&gt;
    &lt;option value=&quot;Keta&quot;&gt;Keta, Ghana&lt;/option&gt;
    &lt;option value=&quot;Beijing&quot;&gt;Beijing, China&lt;/option&gt;
    &lt;option value=&quot;Sydney&quot;&gt;Sydney, Australia&lt;/option&gt;
&lt;/select&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div id='earthMap' style=&quot;position:relative; width:400px; height:400px;&quot;&gt;
&lt;/div&gt;
&lt;script charset=&quot;UTF-8&quot; type=&quot;text/javascript&quot;
    src=&quot;http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2&amp;mkt=en-us&quot;&gt;
&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
    var map = null;
    var mapID = '';

    function GetMap(mapID)
    {
        switch (mapID)
        {
            case 'Seattle':
                map = new VEMap('earthMap');
                map.LoadMap(new VELatLong(47.6, -122.33), 10 ,'i', true);
                break;
            case 'LasVegas':
                map = new VEMap('earthMap');
                map.LoadMap(new VELatLong(36.17, -115.14), 10 ,'i' ,true);
                break;
            case 'SaltLake':
                map = new VEMap('earthMap');
                map.LoadMap(new VELatLong(40.75, -111.89), 10 ,'i' ,true);
                break;
            case 'Dallas':
                map = new VEMap('earthMap');
                map.LoadMap(new VELatLong(32.78, -96.8), 10 ,'i' ,true);
                break;
            case 'Chicago':
                map = new VEMap('earthMap');
                map.LoadMap(new VELatLong(41.88, -87.62), 10 ,'i' ,true);
                break;
            case 'NewYork':
                map = new VEMap('earthMap');
                map.LoadMap(new VELatLong(40.7, -74), 10 ,'i' ,true);
                break;
            case 'Rio':
                map = new VEMap('earthMap');
                map.LoadMap(new VELatLong(-22.91, -43.18), 10 ,'i' ,true);
                break;
            case 'Paris':
                map = new VEMap('earthMap');
                map.LoadMap(new VELatLong(48.87, 2.33), 10 ,'i' ,true);
                break;
            case 'Naples':
                map = new VEMap('earthMap');
                map.LoadMap(new VELatLong(40.83, 14.25), 10 ,'i' ,true);
                break;
            case 'Keta':
                map = new VEMap('earthMap');
                map.LoadMap(new VELatLong(5.92, 0.983), 10 ,'i' ,true);
                break;
            case 'Beijing':
                map = new VEMap('earthMap');
                map.LoadMap(new VELatLong(39.91, 116.39), 10 ,'i' ,true);
                break;
            case 'Sydney':
                map = new VEMap('earthMap');
                map.LoadMap(new VELatLong(-33.86, 151.21), 10 ,'i' ,true);
         }
    }
&lt;/script&gt;</pre>
<p>This markup defines a drop-down list for selecting a map and the JavaScript logic for retrieving the selected map from the Microsoft Virtual Earth Web service. </li>
<li>Save and close the file. </li>
</ol>
<h2>Adding a Tab to the Master-Page Menu</h2>
<p>You will now add an item to the master-page menu that calls the <tt>ViewMaps</tt> action method.</p>
<ol>
<li>In the Shared folder, open the Site.master file and locate the unordered list (ul element) in the div element whose ID is &quot;menucontainer&quot;. </li>
<li>Add the following code to the list between the <strong>Index</strong> and <strong>About Us</strong> tabs:
<pre>&lt;li&gt;&lt;%= Html.ActionLink(&quot;My City Maps&quot;, &quot;ViewMaps&quot;, &quot;Maps&quot;)%&gt;&lt;/li&gt;</pre>
<p>The <tt>ActionLink</tt> method is a helper method that links to an action method. It takes the following parameters: the text for the link, the name of the action method, and the name of the controller. </li>
<li>Save and close the file. </li>
</ol>
<h2>Testing the MVC Application</h2>
<p>You can now test the application.</p>
<ol>
<li>In <strong>Solution Explorer</strong>, select the walkthrough project and press CTRL+F5 to run the application.
<p>The Index.aspx page is displayed, which includes the tabs that are defined in the master page. </li>
<li>Click the <strong>My City Maps</strong> tab.
<p>The My City Maps page is displayed. Select any map to see it displayed.</p>
<p><a href="http://www.grapii.com/wp-content/uploads/2010/01/mvc007.png" rel="lightbox[644]"><img style="display: block; float: none; margin-left: auto; margin-right: auto" title="mvc007" alt="mvc007" src="http://www.grapii.com/wp-content/uploads/2010/01/mvc007-thumb.png" width="400" height="378" /></a> </li>
</ol>
<h2>Next Steps</h2>
<p>This walkthrough gives you a first look at creating an MVC application and working with unit tests in ASP.NET MVC. From here, you might want to learn more about the ASP.NET MVC framework. The following list suggests topics for additional learning.</p>
<ul>
<li>
<p>For more information about MVC controllers<br />
      <br />&#160;&#160; see <a href="http://msdn.microsoft.com/en-us/library/dd410269.aspx">Controllers and Action Methods in MVC Applications</a>.</p>
</li>
<li>
<p>For more information about MVC views<br />
      <br />&#160;&#160; see <a href="http://msdn.microsoft.com/en-us/library/dd410123.aspx">Views and UI Rendering in MVC Applications</a>.</p>
</li>
<li>
<p>For more information about MVC models<br />
      <br />&#160;&#160; see <a href="http://msdn.microsoft.com/en-us/library/dd410405.aspx">Models and Model Binders in MVC Applications</a>.</p>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.grapii.com/2009/12/model-view-controller-design-pattern-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Model-View-Controller Design Pattern Part 1</title>
		<link>http://www.grapii.com/2009/11/model-view-controller-design-pattern-part-1/</link>
		<comments>http://www.grapii.com/2009/11/model-view-controller-design-pattern-part-1/#comments</comments>
		<pubDate>Mon, 16 Nov 2009 01:09:00 +0000</pubDate>
		<dc:creator>grapii</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Design Patterns]]></category>

		<guid isPermaLink="false">http://www.grapii.com/2009/11/model-view-controller-design-pattern-part-1/</guid>
		<description><![CDATA[Part one of a two-part post describing the Model-View-Controller design pattern in context of web applications.

Context
The purpose of many computer systems is to retrieve data from a data store and display it for the user. After the user changes the data, the system stores the updates in the data store. Because the key flow of [...]]]></description>
			<content:encoded><![CDATA[<p>Part one of a two-part post describing the Model-View-Controller design pattern in context of web applications.</p>
<p><span id="more-596"></span></p>
<h2>Context</h2>
<p>The purpose of many computer systems is to retrieve data from a data store and display it for the user. After the user changes the data, the system stores the updates in the data store. Because the key flow of information is between the data store and the user interface, you might be inclined to tie these two pieces together to reduce the amount of coding and to improve application performance. However, this seemingly natural approach has some significant problems. One problem is that the user interface tends to change much more frequently than the data storage system. Another problem with coupling the data and user interface pieces is that business applications tend to incorporate business logic that goes far beyond data transmission.</p>
<h2>Problem</h2>
<p>How do you modularize the user interface functionality of a Web application so that you can easily modify the individual parts?</p>
<h2>Forces</h2>
<p>The following forces act on a system within this context and must be reconciled as you consider a solution to the problem:</p>
<ul>
<li>User interface logic tends to change more frequently than business logic, especially in Web-based applications. For example, new user interface pages may be added, or existing page layouts may be shuffled around. After all, one of the advantages of a Web-based thin-client application is the fact that you can change the user interface at any time without having to redistribute the application. If presentation code and business logic are combined in a single object, you have to modify an object containing business logic every time you change the user interface. This is likely to introduce errors and require the retesting of all business logic after every minimal user interface change.</li>
<li>In some cases, the application displays the same data in different ways. For example, when an analyst prefers a spreadsheet view of data whereas management prefers a pie chart of the same data. In some rich-client user interfaces, multiple views of the same data are shown at the same time. If the user changes data in one view, the system must update all other views of the data automatically.</li>
<li>Designing visually appealing and efficient HTML pages generally requires a different skill set than does developing complex business logic. Rarely does a person have both skill sets. Therefore, it is desirable to separate the development effort of these two parts.</li>
<li>User interface activity generally consists of two parts: presentation and update. The presentation part retrieves data from a data source and formats the data for display. When the user performs an action based on the data, the update part passes control back to the business logic to update the data.</li>
<li>In Web applications, a single page request combines the processing of the action associated with the link that the user selected with the rendering of the target page. In many cases, the target page may not be directly related to the action. For example, imagine a simple Web application that shows a list of items. The user returns to the main list page after either adding an item to the list or deleting an item from the list. Therefore, the application must render the same page (the list) after executing two quite different commands (adding or deleting)-all within the same HTTP request.</li>
<li>User interface code tends to be more device-dependent than business logic. If you want to migrate the application from a browser-based application to support personal digital assistants (PDAs) or Web-enabled cell phones, you must replace much of the user interface code, whereas the business logic may be unaffected. A clean separation of these two parts accelerates the migration and minimizes the risk of introducing errors into the business logic.</li>
</ul>
<h2>Solution</h2>
<p>The <em>Model-View-Controller (MVC)</em> pattern separates the modelling of the domain, the presentation, and the actions based on user input into three separate classes [Burbeck92]:</p>
<ul>
<li><strong>Model</strong>. The model manages the behaviour and data of the application domain, responds to requests for information about its state (usually from the view), and responds to instructions to change state (usually from the controller).</li>
<li><strong>View</strong>. The view manages the display of information.</li>
<li><strong>Controller</strong>. The controller interprets the mouse and keyboard inputs from the user, informing the model and/or the view to change as appropriate.</li>
</ul>
<p>Figure 1 depicts the structural relationship between the three objects.</p>
<p align="center"><a href="http://www.grapii.com/wp-content/uploads/2009/11/mvc001.gif" rel="lightbox[596]"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="Figure 1" src="http://www.grapii.com/wp-content/uploads/2009/11/mvc001-thumb.gif" border="0" alt="Figure 1" width="300" height="200" /></a> <em>Figure 1: MVC class structure</em></p>
<p>It is important to note that both the view and the controller depend on the model. However, the model depends on neither the view nor the controller. This is one the key benefits of the separation. This separation allows the model to be built and tested independent of the visual presentation. The separation between view and controller is secondary in many rich-client applications, and, in fact, many user interface frameworks implement the roles as one object. In Web applications, on the other hand, the separation between view (the browser) and controller (the server-side components handling the HTTP request) is very well defined.</p>
<p><em>Model-View-Controller </em>is a fundamental design pattern for the separation of user interface logic from business logic. Unfortunately, the popularity of the pattern has resulted in a number of faulty descriptions. In particular, the term &#8220;controller&#8221; has been used to mean different things in different contexts. Fortunately, the advent of Web applications has helped resolve some of the ambiguity because the separation between the view and the controller is so apparent.</p>
<h2>Variations</h2>
<p>In <em>Application Programming in Smalltalk-80: How to use Model-View-Controller (MVC)</em> [Burbeck92], Steve Burbeck describes two variations of <em>MVC</em>: a passive model and an active model.</p>
<p>The passive model is employed when one controller manipulates the model exclusively. The controller modifies the model and then informs the view that the model has changed and should be refreshed (see Figure 2). The model in this scenario is completely independent of the view and the controller, which means that there is no means for the model to report changes in its state. The HTTP protocol is an example of this. There is no simple way in the browser to get asynchronous updates from the server. The browser displays the view and responds to user input, but it does not detect changes in the data on the server. Only when the user explicitly requests a refresh is the server interrogated for changes.</p>
<p align="center"><a href="http://www.grapii.com/wp-content/uploads/2009/11/mvc002.gif" rel="lightbox[596]"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="Figure 2" src="http://www.grapii.com/wp-content/uploads/2009/11/mvc002-thumb.gif" border="0" alt="Figure 2" width="300" height="320" /></a> <em>Figure 2: Behaviour of the passive model</em></p>
<p>The active model is used when the model changes state without the controller&#8217;s involvement. This can happen when other sources are changing the data and the changes must be reflected in the views. Consider a stock-ticker display. You receive stock data from an external source and want to update the views (for example, a ticker band and an alert window) when the stock data changes. Because only the model detects changes to its internal state when they occur, the model must notify the views to refresh the display.</p>
<p>However, one of the motivations of using the <em>MVC</em> pattern is to make the model independent from of the views. If the model had to notify the views of changes, you would reintroduce the dependency you were looking to avoid. Fortunately, the <em>Observer</em> pattern [Gamma95] provides a mechanism to alert other objects of state changes without introducing dependencies on them. The individual views implement the <em>Observer </em>interface and register with the model. The model tracks the list of all observers that subscribe to changes. When a model changes, the model iterates through all registered observers and notifies them of the change. This approach is often called &#8220;publish-subscribe.&#8221; The model never requires specific information about any views. In fact, in scenarios where the controller needs to be informed of model changes (for example, to enable or disable menu options), all the controller has to do is implement the <em>Observer </em>interface and subscribe to the model changes. In situations where there are many views, it makes sense to define multiple subjects, each of which describes a specific type of model change. Each view can then subscribe only to types of changes that are relevant to the view.</p>
<p>Figure 3 shows the structure of the active MVC using <em>Observer</em> and how the observer isolates the model from referencing views directly.</p>
<p><a href="http://www.grapii.com/wp-content/uploads/2009/11/mvc003.gif" rel="lightbox[596]"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="Figure 3" src="http://www.grapii.com/wp-content/uploads/2009/11/mvc003-thumb.gif" border="0" alt="Figure 3" width="300" height="180" /></a> <em>Figure 3: Using Observer to decouple the model from the view in the active model</em></p>
<p>Figure 4 illustrates how the <em>Observer</em> notifies the views when the model changes. Unfortunately, there is no good way to demonstrate the separation of model and view in a Unified Modelling Language (UML) sequence diagram, because the diagram represents instances of objects rather than classes and interfaces.</p>
<p align="center"><a href="http://www.grapii.com/wp-content/uploads/2009/11/mvc004.gif" rel="lightbox[596]"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="Figure 4" src="http://www.grapii.com/wp-content/uploads/2009/11/mvc004-thumb.gif" border="0" alt="Figure 4" width="300" height="361" /></a> <em>Figure 4: Behaviour of the active model</em></p>
<h2>Resulting Context</h2>
<p>Architecting the presentation layer around the <em>MVC</em> pattern results in the following benefits and liabilities:</p>
<h3>Benefits</h3>
<ul>
<li><strong>Supports multiple views</strong>. Because the view is separated from the model and there is no direct dependency from the model to the view, the user interface can display multiple views of the same data at the same time. For example, multiple pages in a Web application may use the same model objects. Another example is a Web application that allows the user to change the appearance of the pages. These pages display the same data from the shared model, but show it in a different way. <strong></strong></li>
<li><strong>Accommodates change</strong>. User interface requirements tend to change more rapidly than business rules. Users may prefer different colours, fonts, screen layouts, and levels of support for new devices such as cell phones or PDAs. Because the model does not depend on the views, adding new types of views to the system generally does not affect the model. As a result, the scope of change is confined to the view.</li>
</ul>
<h3>Liabilities</h3>
<ul>
<li><strong>Complexity</strong>. The <em>MVC</em> pattern introduces new levels of indirection and therefore increases the complexity of the solution slightly. It also increases the event-driven nature of the user-interface code, which can become more difficult to debug.</li>
<li><strong>Cost of frequent updates</strong><em>.</em> Decoupling the model from the view does not mean that developers of the model can ignore the nature of the views. For example, if the model undergoes frequent changes, it could flood the views with update requests. Some views, such as graphical displays, may take some time to render. As a result, the view may fall behind update requests. Therefore, it is important to keep the view in mind when coding the model. For example, the model could batch multiple updates into a single notification to the view.</li>
</ul>
<h2>Example</h2>
<p><a href="http://www.grapii.com/2009/12/model-view-controller-design-pattern-part-2/">Part two</a> of this post will describe implementing the <em>MVC</em> model in ASP.NET.</p>
<p class="note"><strong>Acknowledgements:</strong><br />
<em>Model-View-Controller</em> began as a framework developed by Trygve Reenskaug for the Smalltalk platform in the late 1970s [Fowler03]. The version you have just read references the following works:<br />
[<strong>Burbeck92</strong>] Burbeck, Steve. &#8220;Application Programming in Smalltalk-80: How to use Model-View-Controller (MVC).<em>&#8220;</em><em>University of Illinois in Urbana-Champaign (UIUC) Smalltalk Archive.</em><br />
[<strong>Fowler03</strong>] Fowler, Martin. <em>Patterns of Enterprise Application Architecture</em>. Addison-Wesley, 2003.<br />
[<strong>Gamma95</strong>] Gamma, Helm, Johnson, and Vlissides. <em>Design Patterns: Elements of Reusable Object-Oriented Software</em>. Addison-Wesley, 1995.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.grapii.com/2009/11/model-view-controller-design-pattern-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Change WordPress Meta Widget</title>
		<link>http://www.grapii.com/2009/06/change-wordpress-meta-widget/</link>
		<comments>http://www.grapii.com/2009/06/change-wordpress-meta-widget/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 00:53:09 +0000</pubDate>
		<dc:creator>grapii</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.grapii.com/?p=326</guid>
		<description><![CDATA[Want to change your meta links contained in a WordPress sidebar widget?


[2.9] If you are trying to edit the meta data that appears in the sidebar of your Wordpress blog, such as removing the RSS links, find this code in /includes/default-widgets.php file and remove/comment the unwanted lines.
This is what the original class looks like:
class WP_Widget_Meta [...]]]></description>
			<content:encoded><![CDATA[<p>Want to change your meta links contained in a WordPress sidebar widget?</p>
<p><span id="more-326"></span></p>
<p style="text-align: center;"><img class="size-full wp-image-328 title=" src="http://www.grapii.com/wp-content/uploads/2009/06/metalink.png" alt="Meta Link" width="162" height="87" /></p>
<p style="text-align: left;">[2.9] If you are trying to edit the meta data that appears in the sidebar of your Wordpress blog, such as removing the RSS links, find this code in <tt>/includes/default-widgets.php</tt> file and remove/comment the unwanted lines.</p>
<p style="text-align: left;">This is what the original class looks like:</p>
<pre>class WP_Widget_Meta extends WP_Widget {

	function WP_Widget_Meta() {
		$widget_ops = array('classname' =&gt; 'widget_meta', 'description' =&gt; __( "Log in/out, admin, feed and WordPress links") );
		$this-&gt;WP_Widget('meta', __('Meta'), $widget_ops);
	}

	function widget( $args, $instance ) {
		extract($args);
		$title = apply_filters('widget_title', empty($instance['title']) ? __('Meta') : $instance['title']);

		echo $before_widget;
		if ( $title )
			echo $before_title . $title . $after_title;
?&gt;
			&lt;ul&gt;
			&lt;?php wp_register(); ?&gt;
			&lt;li&gt;&lt;?php wp_loginout(); ?&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href="&lt;?php bloginfo('rss2_url'); ?&gt;" title="&lt;?php echo esc_attr(__('Syndicate this site using RSS 2.0')); ?&gt;"&gt;&lt;?php _e('Entries &lt;abbr title="Really Simple Syndication"&gt;RSS&lt;/abbr&gt;'); ?&gt;&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href="&lt;?php bloginfo('comments_rss2_url'); ?&gt;" title="&lt;?php echo esc_attr(__('The latest comments to all posts in RSS')); ?&gt;"&gt;&lt;?php _e('Comments &lt;abbr title="Really Simple Syndication"&gt;RSS&lt;/abbr&gt;'); ?&gt;&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href="http://wordpress.org/" title="&lt;?php echo esc_attr(__('Powered by WordPress, state-of-the-art semantic personal publishing platform.')); ?&gt;"&gt;WordPress.org&lt;/a&gt;&lt;/li&gt;
			&lt;?php wp_meta(); ?&gt;
			&lt;/ul&gt;
&lt;?php
		echo $after_widget;
	}</pre>
<p style="text-align: left;">And this is my modified one:</p>
<pre>class WP_Widget_Meta extends WP_Widget {

	function WP_Widget_Meta() {
		$widget_ops = array('classname' =&gt; 'widget_meta', 'description' =&gt; __( "Log in/out, admin, feed and WordPress links") );
		$this-&gt;WP_Widget('meta', __('Meta'), $widget_ops);
	}

	function widget( $args, $instance ) {
		extract($args);
		$title = apply_filters('widget_title', empty($instance['title']) ? __('Meta') : $instance['title']);

		echo $before_widget;
		if ( $title )
			echo $before_title . $title . $after_title;
?&gt;
			&lt;ul&gt;
			&lt;?php wp_register(); ?&gt;
			&lt;li&gt;&lt;?php wp_loginout(); ?&gt;&lt;/li&gt;
			&lt;?php wp_meta(); ?&gt;
			&lt;/ul&gt;
&lt;?php
		echo $after_widget;
	}</pre>
<p style="text-align: left;">[Pre 2.9] If you are trying to edit the meta data that appears in the sidebar of your Wordpress blog, such as removing the RSS links, find this code in <tt>/includes/widget.php</tt> file and remove the unwanted lines.</p>
<p>This is what the original looks like:</p>
<pre>/**
 * Display meta widget.
 *
 * Displays log in/out, RSS feed links, etc.
 *
 * @since 2.2.0
 *
 * @param array $args Widget arguments.
 */
function wp_widget_meta($args) {
	extract($args);
	$options = get_option('widget_meta');
	$title = empty($options['title']) ? __('Meta') : apply_filters('widget_title', $options['title']);
?&gt;
		&lt;?php echo $before_widget; ?&gt;
			&lt;?php echo $before_title . $title . $after_title; ?&gt;
			&lt;ul&gt;
			&lt;?php wp_register(); ?&gt;
			&lt;li&gt;&lt;?php wp_loginout(); ?&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href="&lt;?php bloginfo('rss2_url'); ?&gt;" title="&lt;?php echo attribute_escape(__('Syndicate this site using RSS 2.0')); ?&gt;"&gt;&lt;?php _e('Entries &lt;abbr title="Really Simple Syndication"&gt;RSS&lt;/abbr&gt;'); ?&gt;&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href="&lt;?php bloginfo('comments_rss2_url'); ?&gt;" title="&lt;?php echo attribute_escape(__('The latest comments to all posts in RSS')); ?&gt;"&gt;&lt;?php _e('Comments &lt;abbr title="Really Simple Syndication"&gt;RSS&lt;/abbr&gt;'); ?&gt;&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href="http://wordpress.org/" title="&lt;?php echo attribute_escape(__('Powered by WordPress, state-of-the-art semantic personal publishing platform.')); ?&gt;"&gt;WordPress.org&lt;/a&gt;&lt;/li&gt;
			&lt;?php wp_meta(); ?&gt;
			&lt;/ul&gt;
		&lt;?php echo $after_widget; ?&gt;
&lt;?php
}</pre>
<p>And this is my modified one:</p>
<pre>/**
 * Display meta widget.
 *
 * Displays log in/out, RSS feed links, etc.
 *
 * @since 2.2.0
 *
 * @param array $args Widget arguments.
 */
function wp_widget_meta($args) {
	extract($args);
	$options = get_option('widget_meta');
	$title = empty($options['title']) ? __('Meta') : apply_filters('widget_title', $options['title']);?&gt;
		&lt;?php echo $before_widget; ?&gt;
			&lt;?php echo $before_title . $title . $after_title; ?&gt;
			&lt;ul&gt;
			&lt;?php wp_register(); ?&gt;
			&lt;li&gt;&lt;?php wp_loginout(); ?&gt;&lt;/li&gt;
			&lt;?php wp_meta(); ?&gt;
			&lt;/ul&gt;
		&lt;?php echo $after_widget; ?&gt;
&lt;?php
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.grapii.com/2009/06/change-wordpress-meta-widget/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Convert HTML</title>
		<link>http://www.grapii.com/2009/05/convert-html/</link>
		<comments>http://www.grapii.com/2009/05/convert-html/#comments</comments>
		<pubDate>Tue, 12 May 2009 19:38:08 +0000</pubDate>
		<dc:creator>grapii</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.grapii.com/?p=313</guid>
		<description><![CDATA[Some of my posts include snippets of code that help explain the process or describe what needs to be done. Most of the code is written in Visual Studio or Dreamweaver, and as such simply copying and pasting the code into the blog post doesn&#8217;t work.

Why? well it&#8217;s because the server thinks it&#8217;s code that [...]]]></description>
			<content:encoded><![CDATA[<p>Some of my posts include snippets of code that help explain the process or describe what needs to be done. Most of the code is written in Visual Studio or Dreamweaver, and as such simply copying and pasting the code into the blog post doesn&#8217;t work.<br />
<span id="more-313"></span><br />
Why? well it&#8217;s because the server thinks it&#8217;s code that needs to be compiled and rendered. Using the <tt>&lt;pre&gt;</tt> tag, also doesn&#8217;t always work and switching between the Visual editor and the HTML editor can cause weird results. So in order to accomplish this task really easy, I&#8217;ve created <a title="Convert HTML" href="http://resource.grapii.com/converthtml.html" target="_blank">Convert HTML</a>. Convert HTML is a simple web page that allows you to convert code tags such as <strong>&lt;</strong> and <strong>&gt;</strong> into their character entities (<strong>&amp;lt;</strong> and <strong>&amp;gt;</strong>), which is then ignored by the server for compiling, but renders correctly on the browser.</p>
<p>Very simple to use, just got to this page and paste in your code including the <strong>&lt;</strong> and <strong>&gt;</strong>, then click on Convert.  Your code should now be shown, where the special characters have been replaced by the character entities.  Simply copy the new code, and paste it inside your <tt>&lt;pre&gt;</tt> tags.</p>
<p>Here&#8217;s an example using Convert HTML</p>
<pre>&lt;ul&gt;
 &lt;li&gt;&lt;a href="&lt;?php echo get_option('home'); ?&gt;/"&gt;Home&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;
  &lt;?php wp_list_pages('title_li=&amp;depth=1'); ?&gt;
 &lt;/li&gt;
 &lt;li&gt;&lt;a class="" href="http://www.grapii.com/?cat=13"&gt;&lt;span&gt;Glossary&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.grapii.com/2009/05/convert-html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flowplayer for WordPress</title>
		<link>http://www.grapii.com/2009/05/flowplayer-for-wordpress/</link>
		<comments>http://www.grapii.com/2009/05/flowplayer-for-wordpress/#comments</comments>
		<pubDate>Tue, 05 May 2009 19:41:36 +0000</pubDate>
		<dc:creator>grapii</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.grapii.com/?p=266</guid>
		<description><![CDATA[I was looking for a simple media player that could play videos that I had created at home.  One of the great things about Magix Movie Edit Pro is that you can output your finished masterpiece in MP4 or FLV format.  Which is great as it keeps the file size small and enables [...]]]></description>
			<content:encoded><![CDATA[<p>I was looking for a simple media player that could play videos that I had created at home.  One of the great things about <a title="Magix Movie Edit Pro" href="http://www.magix.com/uk/movie-edit-pro/plus/" target="_blank">Magix Movie Edit Pro</a> is that you can output your finished masterpiece in MP4 or FLV format.  Which is great as it keeps the file size small and enables me to share my videos to family members across the world.<br />
<span id="more-266"></span></p>
<p>Problem was I just couldn&#8217;t find a simple plugin for WordPress.  There are many out there, mostly for embedding videos from external locations such as YouTube or Google Video, but not easily from the local file server, you have to specify the full URL.  Also, I didn&#8217;t want to keep remebering all the different parameters that needed to be set for each video, there may be months between video posts, no way I can remeber all the settings!</p>
<p>So, I decided to write my own simple WordPress plugin using <a title="FlowPlayer" href="http://flowplayer.org/" target="_blank">Flowplayer</a>.  The plugin adds flowplayer to the WordPress blog, it comes pre-configured and is very very easy to use.   All you need is the name of the video and it&#8217;s resolution (width and height).</p>
<p>The plugin comes with flowplayer version 3.1.0 which is able to play the following formats;</p>
<ul>
<li>H.264</li>
<li>FLV</li>
<li>MP4</li>
</ul>
<p>It is supported by the folowing browsers;</p>
<ul>
<li>Internet Explorer 6.0+</li>
<li>Firefox FF 2+</li>
<li>Safari 2.0+</li>
<li>Opera 9.0+</li>
</ul>
<p>The plugin has the following features;</p>
<ul>
<li>Graphical add button (Visual Editor)</li>
<li>HTML add button (HTML Editor)</li>
<li>Very easy to use</li>
</ul>
<h3>Installation</h3>
<p>Upload the <tt>wp-flowplayer</tt> directory to the <tt>/wp-content/plugins/</tt> directory<br />
Activate the plugin through the &#8216;Plugins&#8217; menu in WordPress</p>
<h3>Usage</h3>
<p>Upload your video to <tt>/wp-content/videos/</tt>.</p>
<p>Create a new post/page and click the flow button (in either Visual editor or HTML editor) and replace the prefilled parameters with your video specific information.</p>
<p>For example this entry;</p>
<pre>flow href="myvideo.mp4" width="320" height="240"</pre>
<p>would add the video <tt>myvideo.mp4</tt> with the width 320 and the height 240 to your post.</p>
<h3>Screenshots</h3>
<p><a href="http://www.grapii.com/wp-content/uploads/2009/05/wp-flowplayer-01.png" rel="lightbox[266]"><img class="aligncenter size-medium wp-image-270" title="wp-flowplayer-01" src="http://www.grapii.com/wp-content/uploads/2009/05/wp-flowplayer-01-300x128.png" alt="wp-flowplayer-01" width="300" height="128" /></a></p>
<p><a href="http://www.grapii.com/wp-content/uploads/2009/05/wp-flowplayer-02.png" rel="lightbox[266]"><img class="aligncenter size-medium wp-image-271" title="wp-flowplayer-02" src="http://www.grapii.com/wp-content/uploads/2009/05/wp-flowplayer-02-300x127.png" alt="wp-flowplayer-02" width="300" height="127" /></a></p>
<h3>Download</h3>
<p>Download the wp-flowplayer plugin and install using the instructions above. If you have any issues please contact me and let me know.</p>
<p class="note"><a href="http://resource.grapii.com/wp-flowplayer.zip">Download wp-flowplayer plugin</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.grapii.com/2009/05/flowplayer-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>What is a System?</title>
		<link>http://www.grapii.com/2009/03/what-is-a-system/</link>
		<comments>http://www.grapii.com/2009/03/what-is-a-system/#comments</comments>
		<pubDate>Mon, 09 Mar 2009 14:56:00 +0000</pubDate>
		<dc:creator>grapii</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[SDLC]]></category>

		<guid isPermaLink="false">http://www.grapii.com/2009/03/what-is-a-system/</guid>
		<description><![CDATA[It is beyond the scope of this post to embark on a detailed discussion of system theory. However, it is useful to have a working definition of the word system.
If we look at some examples of systems:

Solar system 
Digestive system 
Public transport system 
Central heating system 
Computer system 

 
We may arrive at a tentative [...]]]></description>
			<content:encoded><![CDATA[<p>It is beyond the scope of this post to embark on a detailed discussion of system theory. However, it is useful to have a working definition of the word <strong><em>system</em></strong>.</p>
<p>If we look at some examples of systems:</p>
<ul>
<li>Solar system </li>
<li>Digestive system </li>
<li>Public transport system </li>
<li>Central heating system </li>
<li>Computer system </li>
</ul>
<p> <span id="more-869"></span>
<p>We may arrive at a tentative definition – <em>a system is a set of objects or elements that are viewed as a whole</em>. On its own, this is inadequate for our purposes because we are concerned only with systems that are man-made, and therefore under human control, and that have a purpose – otherwise the system cannot be designed by a system developer. This rules out the solar system (no known purpose) and the digestive system (not under human control). An improved definition therefore would be: <em>a system is a set of objects or elements that are viewed as a whole and designed to achieve a purpose.</em></p>
<h2>Relationships</h2>
<p>Another essential feature in our view of systems is that the elements of a system have a relationship to one another; they work together in some way. A heap of stones, for example, although it may be man-made and have the purpose of marking the top of a hill, does not qualify as a system because the elements do not have a significant relationship to one another. If you take one stone from the pile, it does not matter much to the others. In a system removing one element would matter. If you remove the train service from the public transport system, it puts pressure on the other services – it affects them. If you remove the boiler from the central heating system, the system will not work. For our purposes, therefore, the definition of a system we need is: <em>a system is an interrelated set of objects or elements that are viewed as a whole and designed to achieve a purpose.</em></p>
<h2>Boundaries &amp; Environments</h2>
<p>We must add to this definition that a system has a boundary. The system in question lies inside the boundary; outside the <strong><em>system boundary</em></strong> is the <strong><em>environment</em></strong> with which the system interacts. Sometimes the boundary of a system is clear and obvious. If we view a person as a system the boundary is clear – one person is clearly separate from another and from the environment. In computer systems, however, it is usually hard to define the boundary; it is dictated by which elements we choose to think of as being within the system, and which as being part of the environment. The normal rule is that inside the system are things the system is designed to control; outside the system boundary are things the system interacts with, but is not designed to control. The boundary may be set because there are things over which we cannot have control – for example, in a central heating system the weather must be considered to be outside the boundary as we cannot control it. The boundary may also be set because we choose not to include certain elements. This choice may be dictated by the following factors.</p>
<ul>
<li><strong>Money constraints</strong>. We may find that it will cost too much to computerise more than a limited set of system functions. </li>
<li><strong>Time constraints</strong>. The more functions we computerise the longer it will take. </li>
<li><strong>Cost effectiveness</strong>. Sometimes only limited benefits are gained from expensive computerisation. </li>
</ul>
<p>The environment is defined as being the surrounding conditions, outside the boundary, that affect the system and may be affected by it but not controlled by it. We might define the weather conditions as being part of the environment of a central heating system.</p>
<h2>Summary</h2>
<p>To summarise: a <em>system is an interrelated set of objects or elements that are viewed as a whole and designed for a purpose; it has a boundary within which it lies and outside of which is the environment.</em> It is important to define the purpose or objectives of the system; different users will want different things from the system. From the outset, the system developer must be clear about the purpose of the system.</p>
<p><small>Carol Britton &amp; Jill Doake (2006) <em>Software System Development</em>       <br />4th Edition, McGraw-Hill</small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.grapii.com/2009/03/what-is-a-system/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hide WordPress Pages from the Navigation Menu</title>
		<link>http://www.grapii.com/2009/03/hide-wordpress-pages-from-the-navigation-menu/</link>
		<comments>http://www.grapii.com/2009/03/hide-wordpress-pages-from-the-navigation-menu/#comments</comments>
		<pubDate>Mon, 09 Mar 2009 13:48:37 +0000</pubDate>
		<dc:creator>grapii</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.grapii.com/?p=232</guid>
		<description><![CDATA[Having recently purchased an iPhone 3G, I&#8217;ve installed on my blog site WPtouch.  WPtouch is a plug-in that transforms your blog into an application-style theme when you browse to your site using your iPhone.  However, to get the tag cloud and monthly archive list to appear, you must have an Archives page, which [...]]]></description>
			<content:encoded><![CDATA[<p>Having recently purchased an <a title="The Dark Side" href="http://www.grapii.com/index.php/2009/02/21/the-dark-side/" target="_self">iPhone 3G</a>, I&#8217;ve installed on my blog site <a title="WPTouch for WordPress" href="http://wordpress.org/extend/plugins/wptouch/" target="_blank">WPtouch</a>.  WPtouch is a plug-in that transforms your blog into an application-style theme when you browse to your site using your iPhone.  However, to get the tag cloud and monthly archive list to appear, you must have an Archives page, which is based on the Archive template.  <span id="more-232"></span>This is accomplished relatively easily, and works really well on the iPhone, but leaves me with an empty page on my site when browsing using a standard PC and my default theme.  By supplying the page ID to the Exclude prompt of the pages widget it removed the Archives page entry from the right-hand column, but I still had the Archive link at the top of my site, the navigation menu.</p>
<p>So how can I remove the Archives page from the navigation menu, but leave the code intact so that the other page links function and appear as normal? Well, that’s a little tricky, but here’s how:</p>
<ol>
<li>In the WordPress theme editor, open up the <tt>header.php</tt> file and find the following line:
<pre>&lt;?php wp_list_pages('title_li=&amp;depth=1'); ?&gt;</pre>
</li>
<li>Enter <tt>&amp;exclude=</tt> near the end of the line, but inside the brackets. The code should look like this:
<pre>&lt;?php wp_list_pages('title_li=&amp;depth=1&amp;exclude='); ?&gt;</pre>
</li>
<li>Now, all you have to do is add the page ID number or numbers that you want to hide after the <tt>&amp;exclude=</tt>.  If more than one page needs hiding, make sure you separate the page ID&#8217;s with commas.  In my case, the Archives page has an ID of 173, so my code looks like this:
<pre>&lt;?php wp_list_pages('title_li=&amp;depth=1&amp;exclude=173'); ?&gt;</pre>
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.grapii.com/2009/03/hide-wordpress-pages-from-the-navigation-menu/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>List Table/Column names in SQL database</title>
		<link>http://www.grapii.com/2008/03/list-tablecolumn-names-in-sql-database/</link>
		<comments>http://www.grapii.com/2008/03/list-tablecolumn-names-in-sql-database/#comments</comments>
		<pubDate>Mon, 17 Mar 2008 12:50:26 +0000</pubDate>
		<dc:creator>grapii</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.grapii.com/index.php/2008/03/17/list-tablecolumn-names-in-sql-database/</guid>
		<description><![CDATA[Microsoft SQL Server 2000 provides a method for obtaining meta data using information schema views.
List all user tables in the pubs database, we&#8217;re not interested in views
SELECT *
FROM information_schema.tables
WHERE table_type = 'base table'
List only the table names
SELECT table_name
FROM information_schema.tables
WHERE table_type = 'base table'
List all columns in the authors table
SELECT *
FROM information_schema.columns
WHERE table_name = 'authors'
List only [...]]]></description>
			<content:encoded><![CDATA[<p>Microsoft SQL Server 2000 provides a method for obtaining meta data using information schema views.<span id="more-93"></span></p>
<p>List <strong>all</strong> user tables in the <em>pubs</em> database, we&#8217;re not interested in views</p>
<pre>SELECT *
FROM information_schema.tables
WHERE table_type = 'base table'</pre>
<p>List <strong>only</strong> the table names</p>
<pre>SELECT table_name
FROM information_schema.tables
WHERE table_type = 'base table'</pre>
<p>List <strong>all</strong> columns in the <em>authors</em> table</p>
<pre>SELECT *
FROM information_schema.columns
WHERE table_name = 'authors'</pre>
<p>List <strong>only</strong> the column names</p>
<pre>SELECT column_name
FROM information_schema.columns
WHERE table_name = 'authors'</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.grapii.com/2008/03/list-tablecolumn-names-in-sql-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create a Glossary with WordPress</title>
		<link>http://www.grapii.com/2008/02/create-a-glossary-with-wordpress/</link>
		<comments>http://www.grapii.com/2008/02/create-a-glossary-with-wordpress/#comments</comments>
		<pubDate>Fri, 29 Feb 2008 14:50:37 +0000</pubDate>
		<dc:creator>grapii</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.grapii.com/?p=73</guid>
		<description><![CDATA[[EDIT: Tested with WordPress 2.7.1]
I wanted to create a glossary that facilitates terms, buzz words and acronyms used in modern computing. I needed something that was simple to update and manage, and use the capabilities of WordPress rather than creating a simple page with hyperlinks/bookmarks, which would require jumping back and forth into code. I [...]]]></description>
			<content:encoded><![CDATA[<p><em>[EDIT: Tested with WordPress 2.7.1]</em><br />
I wanted to create a glossary that facilitates terms, buzz words and acronyms used in modern computing. I needed something that was simple to update and manage, and use the capabilities of WordPress rather than creating a simple page with hyperlinks/bookmarks, which would require jumping back and forth into code. <span id="more-73"></span>I found a few Glossary plugins like <a title="IMM-Glossary WordPress Plugin" href="http://www.internetmarketingmonitor.org/word-press-plugins/imm-glossary-wordpress-plugin" target="_blank">IMM-Glossary</a>, which did have management of the glossary posts, however, the definitions were in plain text, and wouldn&#8217;t allow formatting. I wanted my text to be formatted using headings, bullet points, even pictures. After many hours of googling and hours of trail and error, I&#8217;ve come up with my perfect glossary solution.</p>
<p>This solution allows me to create the glossary content using WordPress posts, and manage the content like any other posts. It uses a mixture of plugins, templates and custom code, and for me it works really well.</p>
<h3>Step 1</h3>
<p>Download and install the <a title="WP-SNAP! WordPress Plugin" href="http://www.nateomedia.com/wares/downloads/wordpress/wp-snap/" target="_blank">WP-SNAP!</a> plugin. WP-SNAP! creates an alphabetical listing of post titles on a Category or Page template file. Navigation through the listings WP-SNAP! generates is accomplished using the alphabet itself. (For example, if a site visitor clicked on the letter D, any post titles that began with that letter would be showcased.) WP-SNAP! will work on any WordPress 2.1.x or higher site, but is particularly useful managing glossaries, indexes, reviews, or directories.</p>
<h3>Step 2</h3>
<p>To hold all my glossary terms I need to create a new category in WordPress. I called this category &#8220;Glossary&#8221;, and made a note of it&#8217;s ID (13).</p>
<p>Now that I have my category, I need to change the display of the page when someone clicks on Glossary to make use of the WP-SNAP! plugin, and if anyone clicked on the other categories they would get the &#8216;normal&#8217; layout. For this I made use of the category template and the template hierarchy.</p>
<p>The first step in modifying what happens when someone visits a Category page is to figure out which of your theme&#8217;s files is going to be used to display the posts. This is known as the Template Hierarchy.</p>
<p>In the case of categories, the hierarchy is fairly simple. For instance, the ID number of the Glossary category is 13. The Template Hierarchy specifies that WordPress will use the first Template file it finds in your current Theme&#8217;s directory from the following list:</p>
<ol>
<li>category-13.php</li>
<li>category.php</li>
<li>archive.php</li>
<li>index.php</li>
</ol>
<p>That is, if you do not have a <tt>category-13.php</tt>, WordPress will check for a <tt>category.php</tt>, and so on. So, if you want to make the Category whose ID number is 13 look different from what it is currently (and different from other Category pages), you would want to create a <tt>category-13.php</tt> file. If you want to make all Category pages look different from other archive pages (such as date and author archives), then you would want to create or modify the <tt>category.php</tt> file. If you want to make changes to the look of all archive pages, you can create or modify the <tt>archive.php</tt> file. And if you modify the <tt>index.php</tt> file, you will affect your entire blog.</p>
<p>So to create a new <tt>category-13.php </tt>glossary file I copied the next file in the hierarchy that existed in this case <tt>archive.php</tt>.</p>
<p>I made a few changes to the category-13.php page to remove the post dates, tags etc and added the WP-SNAP! configuration line.</p>
<pre>&lt;?php get_header(); ?&gt;
 &lt;!-- Container --&gt;
 &lt;div id="content"&gt;
  &lt;!-- Start Postwrap --&gt;
  &lt;div class="postwrap"&gt;
   &lt;?php if (have_posts()) : ?&gt;
    &lt;?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?&gt;
    &lt;?php /* If this is a category archive */ if (is_category()) { ?&gt;
     &lt;h2 class="pagetitle"&gt;&lt;?php single_cat_title(); ?&gt;&lt;/h2&gt;
     &lt;?php } ?&gt;
      &lt;?php if (function_exists('wp_snap')) { echo wp_snap(13, FALSE); } ?&gt;
      &lt;p&gt;&amp;nbsp;&lt;/p&gt;
       &lt;?php while (have_posts()) : the_post(); ?&gt;
       &lt;div class="Post" id="post-&lt;?php the_ID(); ?&gt;" style="padding-bottom: 40px;"&gt;
        &lt;div class="posthead"&gt;
         &lt;h1&gt;&lt;a title="Permanent Link to &lt;?php the_title(); ?&gt;" href="&lt;?php the_permalink() ?&gt;" rel="bookmark"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h1&gt;
         &lt;small class="postauthor"&gt;&lt;?php edit_post_link('Edit'); ?&gt;&lt;/small&gt;
        &lt;/div&gt;
        &lt;div class="postcontent"&gt;
         &lt;?php the_content() ?&gt;
        &lt;/div&gt;
        &lt;div class="clearer"&gt;&lt;/div&gt;
       &lt;/div&gt;
      &lt;?php endwhile; ?&gt;
     &lt;?php else : ?&gt;
    &lt;h2&gt;Not Found&lt;/h2&gt;
    &lt;?php include (TEMPLATEPATH . '/searchform.php'); ?&gt;
   &lt;?php endif; ?&gt;
  &lt;/div&gt;
  &lt;!-- End Postwrap --&gt;
  &lt;?php get_sidebar(); ?&gt;
  &lt;!-- Container --&gt;
 &lt;/div&gt;
&lt;?php get_footer(); ?&gt;</pre>
<h3>Step 3</h3>
<p>Add some CSS style to your WordPress theme to style the ABC layout, the style I used was was:</p>
<pre>ol.snap_nav {
 display: inline;
 float: left;
 clear: both;
 list-style: none;
 font-size: 12px;
 letter-spacing: 3px;
}

ol.snap_nav li {
 display: block;
 float: left;
 padding: 0 2px 10px 0;
}

ol.snap_nav li a {
 font-weight: bold;
}

ol.snap_nav li.snap_selected a {
 font-weight: normal;
 font-size: 20px;
 text-decoration: none;
 color : #003399;
}</pre>
<h3>Step 4</h3>
<p>Now that the glossary is all setup, a few final tweaks. If I add a new term to the glossary category, I don&#8217;t want it appearing in the front page blog nor in the rss feeds. I looked around to find a way of omitting a certain category from the front page, and although there were a few plugins available, I found this an overkill for this one-off implementation. I finally found some code that can be used. All you need to do is add the following code anywhere in the theme <tt>functions.php</tt> file.</p>
<pre>/* Exclude Category from Main Page and RSS Feeds. Used for Glossary(ID=13) Category. */
function myFilter($query) {
	if ($query-&gt;is_feed || $query-&gt;is_home) {
		$query-&gt;set('cat','-13');
	}

return $query;
}

add_filter('pre_get_posts','myFilter');</pre>
<p>The code example above excludes the glossary category (13) from the RSS feed and main page. If you want to exclude multiple categories, simply add a comma (,) and a dash (-) followed by the category ID e.g. &#8216;-5,-6,-7&#8242;.</p>
<h3>Step 5</h3>
<p>So far so good. I now wanted the glossary link to appear as a page, i.e. I wanted it to look like a page and have the link at the top where my WordPress pages lived. There were several options available, all using various plugins or required creating pseudo pages and linking it back to a category, all of which looked to messy for me. So instead, I just modified my themes header.php file and created a physical link to the category page. I inserted the following code, just after the code for WordPress page links</p>
<pre>&lt;ul&gt;
 &lt;li&gt;&lt;a href="&lt;?php echo get_option('home'); ?&gt;/"&gt;Home&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;
  &lt;?php wp_list_pages('title_li=&amp;depth=1'); ?&gt;
 &lt;/li&gt;
 &lt;li&gt;&lt;a class="" href="http://www.grapii.com/?cat=13"&gt;&lt;span&gt;Glossary&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</pre>
<h3>Step 6</h3>
<p>Finally, as I had the glossary category as a page link, I wanted to hide the glossary category from the category widget. Once again, plenty of plugins available, but for me again this was an overkill. Having searched various forums I came across the best way to achieve this. This solution requires changes to the WordPress core file <tt>widgets.php</tt>. I know this is not ideal, and if I upgrade to the next version of WordPress I&#8217;d loose my changes, but hey, that&#8217;s what this article is for, so I can recreate the glossary fairly easy.</p>
<p>Find this line in <tt>/wp-includes/widgets.php</tt></p>
<pre>$cat_args = "orderby=name&amp;show_count={$c}&amp;hierarchical={$h}";</pre>
<p>In WordPress 2.7.1 its</p>
<pre>$cat_args = array('orderby' =&gt; 'name', 'show_count' =&gt; $c, 'hierarchical' =&gt; $h);</pre>
<p>and add the <tt>&amp;exclude</tt> (WordPress 2.7.1 = <tt>,'exclude'</tt>) to the end of it followed by the category ID, e.g to exclude category ID 13</p>
<pre>$cat_args = "orderby=name&amp;show_count={$c}&amp;hierarchical={$h}&amp;exclude=13";</pre>
<p>WordPress 2.7.1 :</p>
<pre>$cat_args = array('orderby' =&gt; 'name', 'show_count' =&gt; $c, 'hierarchical' =&gt; $h, 'exclude' =&gt; '13');</pre>
<p>to exclude multiple categories, enter the ID separated by commas (,). e.g exclude category ID&#8217;s 5, 6, &amp; 7</p>
<pre>$cat_args = "orderby=name&amp;show_count={$c}&amp;hierarchical={$h}&amp;exclude=5,6,7";</pre>
<h2>Summary</h2>
<p>You should now be set, I know there are a number of steps involved, but I hope you agree it&#8217;s well worth it. I know have a glossary that is managed by WordPress. All I need to do is create a new post and assign it to the glossary category, and I can manage the definitions as I would any other post within WordPress.</p>
<p align="center"><a title="WP-SNAP! Configuration" href="http://www.grapii.com/wp-content/uploads/2008/02/wp-snap-configuration.jpg" rel="lightbox[73]"><img src="http://www.grapii.com/wp-content/uploads/2008/02/wp-snap-configuration-150x150.jpg" alt="WP-SNAP! Configuration" /></a></p>
<p align="center"><a title="Grapii Glossary" href="http://www.grapii.com/wp-content/uploads/2008/02/grapii-glossary.jpg" rel="lightbox[73]"><img src="http://www.grapii.com/wp-content/uploads/2008/02/grapii-glossary-150x150.jpg" alt="Grapii Glossary" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.grapii.com/2008/02/create-a-glossary-with-wordpress/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
