<?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>Andrew Rowland</title>
	<atom:link href="http://www.andrewrowland.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.andrewrowland.com</link>
	<description>I only want to help you</description>
	<lastBuildDate>Thu, 15 Sep 2011 22:00:34 +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>Entity Framework quick start</title>
		<link>http://www.andrewrowland.com/article/display/entity-framework-quick-start/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=entity-framework-quick-start</link>
		<comments>http://www.andrewrowland.com/article/display/entity-framework-quick-start/#comments</comments>
		<pubDate>Tue, 13 Sep 2011 11:53:25 +0000</pubDate>
		<dc:creator>Andy R</dc:creator>
				<category><![CDATA[.Net]]></category>

		<guid isPermaLink="false">http://www.andrewrowland.com/?p=159</guid>
		<description><![CDATA[Microsoft&#8217;s Entity Framework has been around a while, but with it&#8217;s latest incarnation it is really shaping up nicely. I&#8217;ve been enjoying the &#8216;code first&#8217; approach in version 4.1 of the framework. This allows you start your application design from POCOs, allowing the framework to infer the database design for you. For example, take the [...]]]></description>
			<content:encoded><![CDATA[<p>Microsoft&#8217;s Entity Framework has been around a while, but with it&#8217;s latest incarnation it is really shaping up nicely.  I&#8217;ve been enjoying the &#8216;code first&#8217; approach in version 4.1 of the framework.  This allows you start your application design from POCOs, allowing the framework to infer the database design for you.  For example, take the following Member entity model:</p>
<pre class="brush: csharp">
	class Member
	{
		public int Id { get; set; }
		public string FirstName { get; set; }
		public string LastName { get; set; }
	}
</pre>
<p><span id="more-159"></span><br />
The following class derives from the DbContext base class, and exposes our Member model:</p>
<pre class="brush: csharp">
	class EFDbContext : DbContext
	{
		public DbSet&lt;Member&gt; Members { get; set; }

		public EFDbContext()
		{
			Database.SetInitializer&lt;EFDbContext&gt;(new DbContextInitializer());
		}
	}
</pre>
<p>Note the <strong>SetInitializer</strong> call in the constructor.  This allows us to seed the database with some data, using the following class:</p>
<pre class="brush: csharp">
	class DbContextInitializer : DropCreateDatabaseIfModelChanges&lt;EFDbContext&gt;
	{
		protected override void Seed(EFDbContext Context)
		{
			new List&lt;Member&gt;
			{
				new Member {
					FirstName = &quot;Andrew&quot;,
					LastName = &quot;Rowland&quot;
				},
				new Member {
					FirstName = &quot;Roland&quot;,
					LastName = &quot;Browning&quot;
				},
			}.ForEach(m =&gt; Context.Members.Add(m));

			base.Seed(Context);
		}
	}
</pre>
<p>Now we need a simple repository class, so we can query the database:</p>
<pre class="brush: csharp">
	class MemberRepository
	{
		private EFDbContext Context = new EFDbContext();

		public IQueryable&lt;Member&gt; Members
		{
			get { return Context.Members; }
		}
	}
</pre>
<p>Standard practice is to use an interface, and obtain this concrete class using an IOC container, but it will do for demonstration purposes.</p>
<p>Due to lazy loading, nothing would happen until we actually run a query.  So finally, a console application to instantiate the repository, and display the data:</p>
<pre class="brush: csharp">
	class ConsoleApplication
	{
		static void Main(string[] args)
		{
			MemberRepository Repository = new MemberRepository();

			Repository.Members.ToList().ForEach(m =&gt; Console.WriteLine(String.Format(&quot;Member: {0} {1}&quot;, m.FirstName, m.LastName)));

			Console.ReadKey();
		}
	}
</pre>
<p>We can place all of the code into one console application.  Install EF4.1, create a console application in Visual Studio 2010, paste in the class below.  You may have to set the startup object in the project properties.</p>
<pre class="brush: csharp">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity;

namespace EFExample
{
	class Member
	{
		public int Id { get; set; }
		public string FirstName { get; set; }
		public string LastName { get; set; }
	}

	class EFDbContext : DbContext
	{
		public DbSet&lt;Member&gt; Members { get; set; }

		public EFDbContext()
		{
			Database.SetInitializer&lt;EFDbContext&gt;(new DbContextInitializer());
		}
	}

	class DbContextInitializer : DropCreateDatabaseIfModelChanges&lt;EFDbContext&gt;
	{
		protected override void Seed(EFDbContext Context)
		{
			new List&lt;Member&gt;
			{
				new Member {
					FirstName = &quot;Andrew&quot;,
					LastName = &quot;Rowland&quot;
				},
				new Member {
					FirstName = &quot;Roland&quot;,
					LastName = &quot;Browning&quot;
				},
			}.ForEach(m =&gt; Context.Members.Add(m));

			base.Seed(Context);
		}
	}

	class MemberRepository
	{
		private EFDbContext Context = new EFDbContext();

		public IQueryable&lt;Member&gt; Members
		{
			get { return Context.Members; }
		}
	}

	class ConsoleApplication
	{
		static void Main(string[] args)
		{
			MemberRepository Repository = new MemberRepository();

			Repository.Members.ToList().ForEach(m =&gt; Console.WriteLine(String.Format(&quot;Member: {0} {1}&quot;, m.FirstName, m.LastName)));

			Console.ReadKey();
		}
	}
}
</pre>
<p>Run the application, and the magic begins.  If you have an instance of SQL Server Express running, a database with a single Members table will be created, populated with data, and the results displayed.</p>
<p>Bit of a quick post this one, so feel free to ask a question.  I&#8217;m not certain I&#8217;ve added enough detail.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrewrowland.com/article/display/entity-framework-quick-start/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wolf CMS: Related pages plugin</title>
		<link>http://www.andrewrowland.com/article/display/wolf-cms-related-pages-plugin/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=wolf-cms-related-pages-plugin</link>
		<comments>http://www.andrewrowland.com/article/display/wolf-cms-related-pages-plugin/#comments</comments>
		<pubDate>Mon, 17 May 2010 21:29:23 +0000</pubDate>
		<dc:creator>Andy R</dc:creator>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://andrewrowland/?p=1</guid>
		<description><![CDATA[For many small projects I’ve been using Wolf CMS.  a really nice and fairly lightweight application for managing content.  What I like about it is that the core code is quite minimal, but allows you to extend using plugins. Recently I’ve been asked to build a site that requires a the ability to relate other [...]]]></description>
			<content:encoded><![CDATA[<p>For many small projects I’ve been using <a title="External site: Wolf CMS" href="http://www.wolfcms.org/">Wolf CMS</a>.   a really nice and fairly lightweight application for managing content.   What I like about it is that the core code is quite minimal, but allows  you to extend using plugins.</p>
<p>Recently I’ve been asked to build a site that requires a the ability  to relate other pages to the one an editor is currently editing.</p>
<p>The plugin can be <a title="Download plugin" href="http://www.andrewrowland.com/wp-content/uploads/2010/05/related_pages.zip">downloaded here</a>. <strong>Note</strong>: This version is for Wolf 0.7.2 and above.  The older plugin for Wolf 0.6 is <a title="Download older plugin" href="http://www.andrewrowland.com/wp-content/uploads/2010/05/related_pages_0_0_2.zip">also available</a>. Once installed in the plugins directory and enabled in the administration screen, the following tab is now available when editing pages: Once installed in the plugins directory and enabled in the  admininistration screen, the following tab is now available when editing  pages:</p>
<p><a href="http://www.andrewrowland.com/wp-content/uploads/2010/09/screenshot_related_pages.gif"><img class="alignnone size-full wp-image-21" title="screenshot_related_pages" src="/wp-content/uploads/2010/09/screenshot_related_pages.gif" alt="Related pages plug-in screenshot" width="478" height="450" /></a></p>
<p>See the documention screen for sample frontend code which lists the related pages.</p>
<p>Please be aware that I really did knock this together rather quickly,  but it works for me.  If anyone finds any bugs, please let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrewrowland.com/article/display/wolf-cms-related-pages-plugin/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>W3C validation of ASP.Net output</title>
		<link>http://www.andrewrowland.com/article/display/aspdotnet-and-w3c-validator/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=aspdotnet-and-w3c-validator</link>
		<comments>http://www.andrewrowland.com/article/display/aspdotnet-and-w3c-validator/#comments</comments>
		<pubDate>Sat, 25 Jul 2009 13:01:51 +0000</pubDate>
		<dc:creator>Andy R</dc:creator>
				<category><![CDATA[.Net]]></category>

		<guid isPermaLink="false">http://andrewrowland/?p=52</guid>
		<description><![CDATA[A while ago I had to make certain that a CMS driven site built in .Net met some validation criteria.  Specifically the XHTML markup.  Running it by the W3C validator service, the markup always failed. I fixed the obvious within the web.config.  For example, the following is needed to force the application to render XHTML: [...]]]></description>
			<content:encoded><![CDATA[<p>A while ago I had to make certain that a CMS driven site built in  .Net met some validation criteria.  Specifically the XHTML markup.   Running it by the <a title="External link: W3C Validator" href="http://validator.w3.org/">W3C validator</a> service, the markup always failed.</p>
<p>I fixed the obvious within the <strong>web.config</strong>.  For example, the following is needed to force the application to render XHTML:</p>
<pre class="brush: xml">
&lt;configuration&gt;
	...
	&lt;system.web&gt;
		...
		&lt;xhtmlConformance mode=&quot;Strict&quot; /&gt;
		...
	&lt;/system.web&gt;
	...
&lt;/configuration&gt;
</pre>
<p>If  I painfully cut and pasted the HTML into the Validator’s form field, it  passed.  The problem is, is that the service is not recognised by the  Web server, and so a helper file in the application is required.<br />
<span id="more-52"></span><br />
In your web root, create a <strong>App_Browsers</strong> directory.  Within this directory create a file called <strong>w3c.browser</strong>.  Paste the following contents into the file:</p>
<pre class="brush: xml">
&lt;browsers&gt;
	&lt;browser id=&quot;W3C_Validator&quot; parentID=&quot;default&quot;&gt;
		&lt;identification&gt;
			&lt;userAgent match=&quot;^W3C_Validator&quot; /&gt;
		&lt;/identification&gt;
		&lt;capabilities&gt;
			&lt;capability name=&quot;browser&quot; value=&quot;W3C Validator&quot; /&gt;
			&lt;capability name=&quot;ecmaScriptVersion&quot; value=&quot;1.2&quot; /&gt;
			&lt;capability name=&quot;javascript&quot; value=&quot;true&quot; /&gt;
			&lt;capability name=&quot;supportsCss&quot; value=&quot;true&quot; /&gt;
			&lt;capability name=&quot;tables&quot; value=&quot;true&quot; /&gt;
			&lt;capability name=&quot;tagWriter&quot; value=&quot;System.Web.UI.HtmlTextWriter&quot; /&gt;
			&lt;capability name=&quot;w3cdomversion&quot; value=&quot;1.0&quot; /&gt;
		&lt;/capabilities&gt;
	&lt;/browser&gt;
&lt;/browsers&gt;
</pre>
<p>You should now be able to pass the page by URL:</p>
<p><a title="External site: W3C Validator" href="http://validator.w3.org/check?uri=http%3A%2F%2Fwww.andrewrowland.com">http://validator.w3.org/check?uri=http%3A%2F%2Fwww.andrewrowland.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrewrowland.com/article/display/aspdotnet-and-w3c-validator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tridion Business Connector client</title>
		<link>http://www.andrewrowland.com/article/display/tridion-business-connector-client/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=tridion-business-connector-client</link>
		<comments>http://www.andrewrowland.com/article/display/tridion-business-connector-client/#comments</comments>
		<pubDate>Sun, 18 Jan 2009 23:08:38 +0000</pubDate>
		<dc:creator>Andy R</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Tridion]]></category>

		<guid isPermaLink="false">http://andrewrowland/?p=28</guid>
		<description><![CDATA[A bit of a niche entry this one. Will only be of interest to those who use Tridion, one of the more ‘heavyweight’ CMS solutions. I generally have a number of repetitive tasks that are extremely tedious to accomplish using the browser based GUI. So I constructed a simple command line tool that allows me [...]]]></description>
			<content:encoded><![CDATA[<p>A bit of a niche entry this one.  Will only be of interest to those who use Tridion, one of the more ‘heavyweight’ CMS solutions.</p>
<p>I generally have a number of repetitive tasks that are extremely tedious to accomplish using the browser based GUI.  So I constructed a simple <a title="Tridion command line tool" href="http://www.andrewrowland.com/wp-content/uploads/2009/01/bcclient.exe">command line tool</a> that allows me to script tasks using a SOAP interface known as the Tridion Business Connector.</p>
<p>The client takes the following arguments:</p>
<pre class="brush: text">
bcclient.exe /h [hostname] /u [user] /p [password] /d [domain] /x &quot;[request XML]&quot;
</pre>
<p>Why did I build this?  Very useful when called via scripting tools.  In my case, <a title="External link: Official Perl Home" href="http://www.perl.org">Perl</a>.<br />
<span id="more-28"></span><br />
A simple Perl script that will return the XML for a Tridion Component would look something like this:</p>
<pre class="brush: perl">
use strict;

my $requestXML = q{
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;
&lt;tcmapi:Message version=&quot;5.0&quot; from=&quot;AndyRowlandSoapClient&quot; failOnError=&quot;true&quot; xmlns:tcmapi=&quot;http://www.tridion.com/ContentManager/5.0/TCMAPI&quot;&gt;
&lt;tcmapi:Request ID=&quot;GetItemRequest&quot; preserve=&quot;true&quot;&gt;
&lt;tcmapi:GetItem itemURI=&quot;tcm:12-345&quot; /&gt;
&lt;/tcmapi:Request&gt;
&lt;/tcmapi:Message&gt;
};

$requestXML =~ s/&quot;/\\&quot;/g;

my $responseXML = `bcclient.exe /h MyTCMHost /u andyrowland /p mypassword /d MYDOMAIN /x &quot;$requestXML&quot;`;

print $responseXML;
</pre>
<p>We could add a layer of abstraction, and wrap up the SOAP call within a subroutine, something like:</p>
<pre class="brush: perl">
sub make_request {
my $messageXML = shift;
my $requestXML = &#039;&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;&lt;tcmapi:Message version=&quot;5.0&quot; from=&quot;AndyRowlandsSoapClient&quot; failOnError=&quot;true&quot; xmlns:tcmapi=&quot;http://www.tridion.com/ContentManager/5.0/TCMAPI&quot;&gt;&#039; . $messageXML . &#039;&lt;/tcmapi:Message&gt;&#039;;

$requestXML =~ s/&quot;/\\&quot;/g;

my $responseXML = `bcclient.exe /h MyTCMHost /u andyrowland /p mypassword /d MYDOMAIN /x &quot;$requestXML&quot;`;

return XML::Simple::XMLin($responseXML);
}
</pre>
<p>Note the use the module XML::Simple to convert the response XML into a Perl data structure.</p>
<p>We can then create a succession of subroutines to perform a variery of routine tasks.  To get a Tridion item:</p>
<pre class="brush: perl">
sub get_item {
my $URI = shift;

my $messageXML = qq{
&lt;tcmapi:Request ID=&quot;GetItemRequest&quot; preserve=&quot;true&quot;&gt;
&lt;tcmapi:GetItem itemURI=&quot;$URI&quot; /&gt;
&lt;/tcmapi:Request&gt;
};

my $ref = make_request($messageXML);

if ($ref-&gt;{&#039;tcmapi:Response&#039;}{&#039;success&#039;} eq &#039;true&#039;){
return $ref;
} else {
die &quot;ERROR: Could not get item $URI&quot;;
}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.andrewrowland.com/article/display/tridion-business-connector-client/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Happy Christmas</title>
		<link>http://www.andrewrowland.com/article/display/happy-christmas/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=happy-christmas</link>
		<comments>http://www.andrewrowland.com/article/display/happy-christmas/#comments</comments>
		<pubDate>Tue, 23 Dec 2008 19:04:03 +0000</pubDate>
		<dc:creator>Andy R</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://andrewrowland/?p=33</guid>
		<description><![CDATA[I’ve finally got some time off from work. Not managed to update the blog for a few months, which is a shame, because I quite enjoy doing it. I’ve also had a few emails from satisfied customers. Some of you out there actually take the time to post feedback. Much appreciated. Though I had to [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve finally got some time off from work.  Not managed to update the blog for a few months, which is a shame, because I quite enjoy doing  it.  I’ve also had a few emails from satisfied customers.  Some of you out there actually take the time to post feedback.  Much appreciated.   Though I had to code a spam filter for naughty stuff that had been  submitted.  Thankfully I now don’t have to go into the database, and bulk delete entries.</p>
<p>Now that I’ve got the time, I’m going to start writing again.  I start work again in the new year, and I’m looking forward to it.  As things never stand still in development, it’ll be time to pick up a few books, and gain some new skills.</p>
<p>More Content Management integration coming up for me next year (<a title="External link: Tridion" href="http://www.tridion.com/">Tridion</a>, possibly <a title="External link: Immediacy" href="http://www.immediacy.net/">Immediacy</a>), and more <a title="External link: ASP.Net resource" href="http://www.asp.net/">ASP.Net</a> work.  Also going to brush up on my <a title="External site: jQuery" href="http://www.jquery.com/">jQuery</a>, and <a title="External site: CodeIgniter" href="http://www.codeigniter.com/">CodeIgniter</a> knowledge.  Really would like to do more Open Source based project  work, as I’ve been mainly using proprietary applications during the pass  few months.  With the economy lower than a fat kids self esteem, I  can’t be choosy, just glad to be working.</p>
<p>Have a great Christmas, and I’ll see you a few pounds heavier in the new year.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrewrowland.com/article/display/happy-christmas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Validation groups in .Net</title>
		<link>http://www.andrewrowland.com/article/display/validation-groups-in-net/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=validation-groups-in-net</link>
		<comments>http://www.andrewrowland.com/article/display/validation-groups-in-net/#comments</comments>
		<pubDate>Sun, 24 Aug 2008 17:52:36 +0000</pubDate>
		<dc:creator>Andy R</dc:creator>
				<category><![CDATA[.Net]]></category>

		<guid isPermaLink="false">http://andrewrowland/?p=37</guid>
		<description><![CDATA[Evening all. Not posted in a while as I’ve plenty going on in the ‘real’ world. Anyway, last week I was building a search form whereby you could either search by reference code, or by using full search criteria. The problem I had is that both search ‘forms’ existed on one Web Form, and I [...]]]></description>
			<content:encoded><![CDATA[<p>Evening all.  Not posted in a while as I’ve plenty going on in the ‘real’ world.  Anyway, last week I was building a search form whereby you could either search by reference code, or by using full search criteria.</p>
<p>The problem I had is that both search ‘forms’ existed on one Web Form, and I was using Validation controls to check each.  So when using either submit button, both search groups were validated together.  Not useful when I wanted to submit each set of controls independently of each other.  So there I was, coding to disable either set of validation controls when a submit button is clicked.</p>
<p>“Validation groups!” I hear you cry.  Yes, I know that now.<br />
<span id="more-37"></span><br />
Add the ValidationGroup attribute to all controls, so you can group them together, and submit them separately from other groups.  Example:</p>
<pre class="brush: c#">
&lt;form id=&quot;form1&quot; runat=&quot;server&quot;&gt;

&lt;p&gt;
	&lt;asp:TextBox Id=&quot;TextBox1&quot; Runat=&quot;server&quot; ValidationGroup=&quot;First&quot; /&gt;
	&lt;asp:TextBox Id=&quot;TextBox2&quot; Runat=&quot;server&quot; ValidationGroup=&quot;First&quot; /&gt;
	&lt;asp:RequiredFieldValidator Id=&quot;RequiredFieldValidator1&quot; Runat=&quot;server&quot; ValidationGroup=&quot;First&quot; ErrorMessage=&quot;TextBox1 should not be blank&quot; ControlToValidate=&quot;TextBox1&quot; /&gt;

	&lt;asp:Button ID=&quot;Submit1&quot; Runat=&quot;server&quot; ValidationGroup=&quot;First&quot; Text=&quot;Submit 1&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;
	&lt;asp:TextBox Id=&quot;TextBox3&quot; Runat=&quot;server&quot; ValidationGroup=&quot;Second&quot; /&gt;
	&lt;asp:TextBox Id=&quot;TextBox4&quot; Runat=&quot;server&quot; ValidationGroup=&quot;Second&quot; /&gt;
	&lt;asp:RequiredFieldValidator Id=&quot;RequiredFieldValidator2&quot; Runat=&quot;server&quot; ErrorMessage=&quot; TextBox3 should not be blank&quot; ControlToValidate=&quot;TextBox3&quot; ValidationGroup=&quot;Second&quot; /&gt;

	&lt;asp:Button Id=&quot;Submit2&quot; Runat=&quot;server&quot; ValidationGroup=&quot;Second&quot; Text=&quot;Submit 2&quot; /&gt;
&lt;/p&gt;

&lt;/form&gt;
</pre>
<p>Aye, easy when you know.  Googling is a wonderful thing. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrewrowland.com/article/display/validation-groups-in-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using the Zend framework Lucene library – Part 2</title>
		<link>http://www.andrewrowland.com/article/display/using-zend-search-lucene-part-2/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=using-zend-search-lucene-part-2</link>
		<comments>http://www.andrewrowland.com/article/display/using-zend-search-lucene-part-2/#comments</comments>
		<pubDate>Fri, 04 Jul 2008 15:02:09 +0000</pubDate>
		<dc:creator>Andy R</dc:creator>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://andrewrowland/?p=40</guid>
		<description><![CDATA[Note: Since this article was written I&#8217;ve moved to WordPress, and have not implemented the example code listed below. In a previous article I talked about using a library from the Zend framework to create a site search.  As you try out this functionality using the search box, above right. I never finished the article, [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Note:</strong> Since this article was written I&#8217;ve moved to WordPress, and have not implemented the example code listed below.</p>
<p>In a previous <a title="Using the Zend framework Lucene library" href="http://www.andrewrowland.com/article/display/using-zend-search-lucene/">article</a> I talked about using a library from the Zend framework to create a site  search.  As you try out this functionality using the search box, above  right.</p>
<p>I never finished the article, so I’ll explain here how I implemented this using <a title="External site: CodeIngiter" href="http://www.codeigniter.com/">CodeIgniter</a>.  I’ll also detail how I built the ‘quick results’ tool (click in the search box).<br />
<span id="more-40"></span><br />
Below is an example controller class that shows how I constructed  the search index by pulling articles out of the database.  My actual  class calls security methods that require authentication before  performing any of these methods.  I left them out of the listing to keep  it short and sweet.  You will have to alter the code to allow for the  difference in database schema, and to suit your intended available  search criteria.</p>
<pre class="brush: php">
&lt;?php
class Search extends Controller {

	function Search()
	{
		parent::Controller();

		// Load Zend Lucene library.  See previous article.
		$this-&gt;load-&gt;library(&#039;zend&#039;);
		$this-&gt;zend-&gt;load( &#039;Zend/Search/Lucene&#039;);

		// Location of search index.  Used by all Search controller methods.
		$this-&gt;search_index = APPPATH . &#039;search/index&#039;;
	}

	function reindex()
	{
		// Create index.  Will delete any existing index.
		$index = Zend_Search_Lucene::create($this-&gt;search_index);

		// Obtain all articles.
		$query = $this-&gt;db-&gt;get(&#039;articles&#039;);

		// Loop through articles, adding an index for each one.
		foreach ($query-&gt;result() as $article)
		{
			// Create Lucene document for this article.
			$doc = new Zend_Search_Lucene_Document();

			// Add required fields.
			$doc-&gt;addField(Zend_Search_Lucene_Field::Text(&#039;title&#039;, $article-&gt;title));
			$doc-&gt;addField(Zend_Search_Lucene_Field::Text(&#039;subtitle&#039;, $subtitle));
			$doc-&gt;addField(Zend_Search_Lucene_Field::Text(&#039;category&#039;, $category_list));
			$doc-&gt;addField(Zend_Search_Lucene_Field::Text(&#039;path&#039;, &#039;/article/display/&#039; . $article-&gt;path));
			$doc-&gt;addField(Zend_Search_Lucene_Field::UnStored(&#039;content&#039;, $article-&gt;summary . $article-&gt;text));

			// Add docuument to index.
			$index-&gt;addDocument($doc);

			echo &#039;Added &#039; . $item-&gt;title . &#039; to index.&lt;br /&gt;&#039;;
		}

		$index-&gt;optimize();
	}

	function optimize()
	{
		$index = Zend_Search_Lucene::open($this-&gt;search_index);
		$index-&gt;optimize();

		echo &#039;&lt;p&gt;Index optimized.&lt;/p&gt;&#039;;
	}
}
</pre>
<p>To utilise the index a result method is required:</p>
<pre class="brush: php">
	function result()
	{
		// Create empty array, in case there are no results.
		$data[&#039;results&#039;] = array();

		// If a search_query parameter has been posted, search the index.
		if ($this-&gt;input-&gt;post(&#039;search_query&#039;))
		{
			$index = Zend_Search_Lucene::open($this-&gt;search_index);

			// Get results.
			$data[&#039;results&#039;] = $index-&gt;find($this-&gt;input-&gt;post(&#039;search_query&#039;));
		}

		// Load view, and populate with results.
		$this-&gt;load-&gt;view(&#039;search_result_view&#039;, $data);
	}
</pre>
<p>And, of course, a view is required to display the results:</p>
<pre class="brush: html">
&lt;html&gt;
&lt;head&gt;
	&lt;title&gt;Search results&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;		

&lt;h1&gt;Search results&lt;/h1&gt;

&lt;?php if (empty($_POST[&#039;search_query&#039;])):?&gt;
&lt;p&gt;No search query submitted.&lt;/p&gt;
&lt;?php else:?&gt;
	&lt;?php if (count($results)):?&gt;
&lt;p&gt;&lt;?php echo count($results) ?&gt; result(s) returned for query: &lt;?php echo $_POST[&#039;search_query&#039;];?&gt;&lt;/p&gt;
&lt;ul&gt;
	&lt;?php foreach($results as $result):?&gt;
	&lt;li&gt;&lt;?=anchor(site_url($result-&gt;path), $result-&gt;title);?&gt; (&lt;?php echo round($result-&gt;score, 2) * 100;?&gt;%)&lt;/li&gt;
	&lt;?php endforeach;?&gt;
&lt;/ul&gt;
	&lt;?php else:?&gt;
&lt;p&gt;No results were returned for query: &lt;?php echo $_POST[&#039;search_query&#039;];?&gt;&lt;/p&gt;
	&lt;?php endif;?&gt;
&lt;?php endif;?&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.andrewrowland.com/article/display/using-zend-search-lucene-part-2/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Linux Mint 5 Elyssa</title>
		<link>http://www.andrewrowland.com/article/display/mint/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mint</link>
		<comments>http://www.andrewrowland.com/article/display/mint/#comments</comments>
		<pubDate>Thu, 12 Jun 2008 21:54:27 +0000</pubDate>
		<dc:creator>Andy R</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://andrewrowland/?p=57</guid>
		<description><![CDATA[I’ve been using Ubuntu for the past couple of years now, and have found it a perfectly viable alternative to Windows.  As I mentioned in my very first post, I’m not a Linux zealot taking a political stance.  It’s just a simple preference.  If I was a zealot I’d be using a distribution like Gentoo, [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve been using Ubuntu for the past couple of years now, and have  found it a perfectly viable alternative to Windows.  As I mentioned in  my very first post, I’m not a Linux zealot taking a political stance.   It’s just a simple preference.  If I was a zealot I’d be using a  distribution like Gentoo, Slackware, or Linux From Scatch.  One for the  hard nuts, I just want something that works on my five year old laptop.   I’m too tight to upgrade, so that rules out Vista.  Now there’s an OS  that drives Linux fundamentalism.</p>
<p>In an attempt to challenge my OS of choice, but still keeping within my Ubuntu comfort zone, I installed <a title="External site: Linux Mint" href="http://www.linuxmint.com/">Linux Mint</a> last week.  Once slated as just a friendly, sexier version of Ubuntu, it now seems to be gaining in popularity.</p>
<p><a href="http://www.andrewrowland.com/wp-content/uploads/2010/09/mint.png"><img src="/wp-content/uploads/2010/09/mint_thumb.png" alt="Mint: Desktop" title="mint_thumb" width="500" height="375" class="alignnone size-full wp-image-67" /></a></p>
<p>I’m very impressed.  I installed the OS, development IDE (Eclipse based <a title="External site: Aptana Studio" href="http://www.aptana.com/">Aptana</a>),  Apache, PHP, MySQL, and had the development version of this site up and  running within a couple of hours.  No messing around getting Flash,  RealPlayer, and various audio/video codecs running.  Anything I did need  to install was a simple <em>apt-get</em> away in the Ubuntu repositories.<br />
<span id="more-57"></span><br />
<a href="http://www.andrewrowland.com/wp-content/uploads/2010/09/mint_rdp.png"><img src="/wp-content/uploads/2010/09/mint_rdp.png" alt="Mint: RDP" title="mint_rdp_thumb" width="500" height="375" class="alignnone size-full wp-image-66" /></a></p>
<p><a href="http://www.andrewrowland.com/wp-content/uploads/2010/09/mint_aptana.png"><img src="/wp-content/uploads/2010/09/mint_aptana_thumb.png" alt="Mint: Aptana Studio" title="mint_aptana_thumb" width="500" height="375" class="alignnone size-full wp-image-62" /></a></p>
<p><a href="http://www.andrewrowland.com/wp-content/uploads/2010/09/mint_gimp.png"><img src="/wp-content/uploads/2010/09/mint_gimp_thumb.png" alt="Mint: Gimp" title="mint_gimp_thumb" width="500" height="375" class="alignnone size-full wp-image-63" /></a></p>
<p><a href="http://www.andrewrowland.com/wp-content/uploads/2010/09/mint_oo.png"><img src="/wp-content/uploads/2010/09/mint_oo_thumb.png" alt="Mint: Open Office" title="mint_oo_thumb" width="500" height="375" class="alignnone size-full wp-image-64" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrewrowland.com/article/display/mint/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery UI Date Picker control issue with .Net</title>
		<link>http://www.andrewrowland.com/article/display/jquery-ui-date-picker-control-issue-with-net/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=jquery-ui-date-picker-control-issue-with-net</link>
		<comments>http://www.andrewrowland.com/article/display/jquery-ui-date-picker-control-issue-with-net/#comments</comments>
		<pubDate>Wed, 11 Jun 2008 13:51:13 +0000</pubDate>
		<dc:creator>Andy R</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://andrewrowland/?p=77</guid>
		<description><![CDATA[Aye, I do whitter on about jQuery.  It’s ace.  The newly released jQuery UI is pretty special too.  One of the many great widgets is the Date Picker control. I build many .net applications that require date entry, so I implement the Date Picker control often.  Unfortunately, there is a problem when it is used [...]]]></description>
			<content:encoded><![CDATA[<p>Aye, I do whitter on about <a title="External site: jQuery" href="http://www.jquery.com/">jQuery</a>.  It’s ace.  The newly released <a title="External site: jQuery UI" href="http://ui.jquery.com/">jQuery UI</a> is pretty special too.  One of the many great widgets is the Date Picker control.</p>
<p>I build many .net applications that require date entry, so I  implement the Date Picker control often.  Unfortunately, there is a  problem when it is used on a field that is validated using a .Net  validation control.  Upon clicking on a date, I get the following error:</p>
<pre>length is null or not an object</pre>
<p>This  only occurs when using Internet Explorer.  Currently, my only solution  is to edit the source code.  Locate the following code in <strong>jquery-ui.js</strong> or <strong>ui.datepicker.js</strong>:</p>
<pre class="brush: javascript">
inst.input.trigger(&#039;change&#039;)
</pre>
<p>Replace it with:</p>
<pre class="brush: javascript">
if (!$.browser.msie){inst.input.trigger(&#039;change&#039;)}
</pre>
<p>This prevents the change event firing in IE.</p>
<p>I wouldn’t normally advocate changing source code in this manner, as  it makes future upgrades tedious.  Hopefully it will be addressed in a  future release.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrewrowland.com/article/display/jquery-ui-date-picker-control-issue-with-net/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>Using jQuery selectors to reference .Net controls</title>
		<link>http://www.andrewrowland.com/article/display/selecting-dotnet-controls-with-jquery/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=selecting-dotnet-controls-with-jquery</link>
		<comments>http://www.andrewrowland.com/article/display/selecting-dotnet-controls-with-jquery/#comments</comments>
		<pubDate>Wed, 04 Jun 2008 11:40:32 +0000</pubDate>
		<dc:creator>Andy R</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://andrewrowland/?p=81</guid>
		<description><![CDATA[You place a control onto your page: &#60;asp:Content ID=&#34;Content1&#34; ContentPlaceHolderID=&#34;Content&#34; Runat=&#34;Server&#34;&#62; &#60;asp:TextBox Id=&#34;Firstname&#34; Runat=&#34;Server&#34; /&#62; &#60;/asp:Content&#62; The output is rendered as: &#60;input name=&#34;ctl00$Content$FirstName&#34; type=&#34;text&#34; id=&#34;ctl00_Content_FirstName&#34; /&#62; In the example above, the disparity in the rendered id attribute occurs because the TextBox control has been placed within a Content control, as the Page object inherits a [...]]]></description>
			<content:encoded><![CDATA[<p>You place a control onto your page:</p>
<pre class="brush: html">
&lt;asp:Content ID=&quot;Content1&quot; ContentPlaceHolderID=&quot;Content&quot; Runat=&quot;Server&quot;&gt;
	&lt;asp:TextBox Id=&quot;Firstname&quot; Runat=&quot;Server&quot; /&gt;
&lt;/asp:Content&gt;
</pre>
<p>The output is rendered as:</p>
<pre class="brush: html">
&lt;input name=&quot;ctl00$Content$FirstName&quot; type=&quot;text&quot; id=&quot;ctl00_Content_FirstName&quot; /&gt;
</pre>
<p>In  the example above, the disparity in the rendered id attribute occurs  because the TextBox control has been placed within a Content control, as  the Page object inherits a MasterPage.</p>
<p>So how can you robustly reference the control using client-side  JavaScript, regardless where the control resides?  Using jQuery it’s  fairly trivial:</p>
<pre class="brush: javascript">
var $firstname = $(&quot;[id$=FirstName]&quot;);
</pre>
<p>This little snippet makes use of the jQuery attributeEndsWith selector, as documented <a title="External site: jQuery documentation" href="http://docs.jquery.com/Selectors/attributeEndsWith#attributevalue">here</a>.  Bare in mind that an array is returned, as any control with an id that ends in FirstName will be selected.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrewrowland.com/article/display/selecting-dotnet-controls-with-jquery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

