<?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:rssdatehelper="urn:rssdatehelper"><channel><title>Refactored i.T</title><link>http://refactored.com.au</link><pubDate>2012-05-15T13:30:21</pubDate><generator>umbraco</generator><description>Refactored Information Technology articles, HOWTO's and news</description><language>en</language><item><title>Content Summaries with HtmlAgilityPack</title><link>http://refactored.com.au/blog/2012/5/15/content-summaries-with-htmlagilitypack/</link><pubDate>Tue, 15 May 2012 12:56:00 GMT</pubDate><guid>http://refactored.com.au/blog/2012/5/15/content-summaries-with-htmlagilitypack/</guid><description><![CDATA[ 
<p class="brush: c-sharp;">Recently I had a client ask me to modify
their Blog page to list only&nbsp;the first paragraph and the first
image found in each of their posts instead of the full post on the
default Blog Post List.</p>

<p>The site (<a href="http://deancambray.com.au" target="_blank"
title="Dean Cambray Photographer">http://deancambray.com.au</a>)
was built with Umbraco and utilises the Blog4Umbraco package along
with our Extensions package.&nbsp; The solution that we came up
with was to use the already available HtmlAgilityPack that's
included in the Umbraco distribution and write our own Razor Script
to list the Blog Posts.</p>

<p>While the entire script also incorporates other features such as
a custom numeric pager, I wanted to focus this time on just
extracting certain elements out of each post and displaying them in
a customised format.</p>

<h2>The helper: RenderSummary</h2>

<p>First things first: make sure you have a reference to the
HtmlAgilityPack library&nbsp;near the top of the script:</p>

<pre class="brush: c-sharp;">
@using HtmlAgilityPack;
</pre>

<p class="brush: c-sharp;">Our helper looks like this:</p>

<pre class="brush: c-sharp;">
@helper RenderSummary(dynamic node) {
    var doc = new HtmlDocument();
    doc.LoadHtml(node.BodyText.ToString());
    var imgNode = doc.DocumentNode.SelectSingleNode("//img[@src]"); 
    if (imgNode != null) {
        var url = imgNode.Attributes["src"].Value;
        string alt = string.Empty;
        string title = string.Empty;
        if (imgNode.Attributes["alt"] != null) { alt = imgNode.Attributes["alt"].Value; }
        if (imgNode.Attributes["title"] != null) { title = imgNode.Attributes["title"].Value; }
&lt;a href="@node.Url" title="Permalink to @node.Name"&gt;&lt;img src="@url" alt="@alt" title="@title" /&gt;&lt;/a&gt;
    }
    var para = doc.DocumentNode.SelectNodes("//p");
    if (para != null) {
        foreach (var p in para) {
            if (string.IsNullOrWhiteSpace(p.InnerText.Replace("&nbsp;", ""))) { continue; }
            
            &lt;p&gt;@Html.Raw(p.InnerText)&lt;/p&gt;
            break;                                         
        }
    }
}
</pre>

<p class="brush: c-sharp;">Our script uses a helper to render the
Summary of each post that was found, and instantiates a new
HtmlAgilityPack.<strong>HtmlDocument</strong> for each article by
loading the article content using <strong>LoadHtml</strong>.&nbsp;
Once that's done, we can then use standard xpath queries to select
the content that we want.&nbsp; In this case, we want to find the
first image that may be contained in the article and the first
non-empty paragraph.</p>

<p class="brush: c-sharp;">We can check that an image or paragraph
exists by the return value of the <strong>SelectSingleNode</strong>
or <strong>SelectNodes</strong> methods making it very easy to
conditionally display the image or a placeholder if desired, for
example.</p>

<p class="brush: c-sharp;">Once we have our image, it's a trivial
matter to extract the source url and other attributes using the
Attributes collection on the returned <strong>HtmlNode</strong> and
building our custom &lt;img&gt; tag.</p>

<p class="brush: c-sharp;">Because it is very easy to insert
paragraphs through TinyMCE that are empty, we want to find the
first paragraph that actually has visible content in it. Otherwise
our summary will look very empty indeed.&nbsp; Once we have found
the right paragraph, we can use the <strong>InnerText</strong>
property to extract just the textual elements and ignore things
like embedded images, lists and line breaks.&nbsp; This results in
a cleaner display and guarantees that the image (which may be found
within the first paragraph) is not shown twice.</p>

<p class="brush: c-sharp;">Note that you could also use the
<strong>InnerHtml</strong> property instead if you wanted to
include the extra format elements and other bits and pieces.</p>

<h2 class="brush: c-sharp;">Tying it together</h2>

<p class="brush: c-sharp;">OUr BlogListPosts script is intended to
replace the XSLT counterpart provided with Blog4Umbraco, so I've
taken the basic structure of that script and tidied it up somewhat
for clarity.&nbsp; I've removed part of it that does the filtering
and paging&nbsp;of the list items based on category and/or archive
folder.&nbsp; I wanted to focus on just the Summary rendering, so
here's a condensed version of the body of the script featuring the
use of the RenderSummary helper defined above:</p>

<pre class="brush: c-sharp;">
@{
    var list = Current.DescendantsOrSelf("BlogPost").Items.OrderByDescending(n =&gt; n.GetPropertyValue("PostDate"));

    foreach (dynamic post in list)
    {
        &lt;div class="post"&gt;
            &lt;h2 class="entry-title"&gt;&lt;a href="@post.Url" title="Permalink to @post.Name"&gt;@post.Name&lt;/a&gt;&lt;/h2&gt;

            &lt;div class="entry-date"&gt;
                &lt;small class="published"&gt;@post.PostDate.ToString("dddd, MMM dd, yyyy")&lt;/small&gt;
            &lt;/div&gt;

            &lt;div class="entry-content summary"&gt;
                @RenderSummary(post)
            &lt;/div&gt;
            &lt;div class="footer"&gt;
                &lt;small class="more"&gt;&lt;a href="@post.Url" title="Permalink to @post.Name"&gt;Read More...&lt;/a&gt;&lt;/small&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    }
    
}
</pre>

<p class="brush: c-sharp;">Find this post helpful?&nbsp; Why don't
you drop us a line in the comments below...</p>
]]></description></item><item><title>Reply: How not to use Linq</title><link>http://refactored.com.au/blog/2012/3/8/reply-how-not-to-use-linq/</link><pubDate>Thu, 08 Mar 2012 16:32:00 GMT</pubDate><guid>http://refactored.com.au/blog/2012/3/8/reply-how-not-to-use-linq/</guid><description><![CDATA[ 
<p>Recently (well, today) <a
href="http://www.codeproject.com/script/Mailouts/View.aspx?mlid=9472&amp;_z=5404596"
 target="_blank" title="The Code Project Insider">the CodeProject
Insider</a> featured a blog entry - How not to use Linq.&nbsp; It
was a short but interesting artile that prompted me to write a
comment but alas no comments can be written on the site.&nbsp; So I
thought I'd better answer it here instead.&nbsp; <a
href="http://compiledexperience.com/blog/posts/how-not-to-use-linq"
target="_blank" title="Compiled Experience: How not to use Linq">Go
have a read if you haven't already done so...</a></p>

<p>While I appreciate the intent and points of the article, I think
it's also important to note the benefits of .Select() and
.FirstOrDefault() as they have a place when used well.</p>

<p>With the former, it allows one to transform the results into
another kind of object or even an anonymous object if
required.&nbsp; With the latter, the second form of the extension
method is very powerful in that you can supply an object to use as
the default if there are no results from the query.</p>

<p>So for example:</p>

<pre class="brush: c-sharp;">
var product = products
     .Where(p =&gt; p.Id == 42)
    .Select(p =&gt; new SelectListItem{ Value = p.Id, Text = p.Name });
</pre>

<p>will produce an <strong>IEnumerable&lt;<a
href="http://msdn.microsoft.com/en-us/library/dd492754.aspx"
target="_blank"
title="MSDN: SelectListItem Class">SelectListItem</a>&gt;</strong>
that can be used for example to populate a Select List in ASP.Net
MVC templates.</p>

<pre class="brush: c-sharp;">
var product = products
     .Where(p =&gt; p.Id == 42)
    .FirstOrDefault(new Product());
</pre>

<p>could be used to return a default product instance instead of a
null.</p>

<pre class="brush: c-sharp;">
var id = products
     .Where(p =&gt; p.Available)
     .Select(p =&gt; p.Id)
    .FirstOrDefault(-1);
</pre>

<p>would either return <strong>-1</strong> if no available products
are found, or the first product Id.</p>

<p>Very powerful stuff ths Linq with Extension Methods...</p>

<p>Any comments? Feel free to post your views on this topic...</p>
]]></description></item><item><title>Retrieving DropDownList Values in Razor or C#</title><link>http://refactored.com.au/blog/2012/2/27/retrieving-dropdownlist-values-in-razor-or-c/</link><pubDate>Mon, 27 Feb 2012 13:28:00 GMT</pubDate><guid>http://refactored.com.au/blog/2012/2/27/retrieving-dropdownlist-values-in-razor-or-c/</guid><description><![CDATA[ 
<p>Recently I needed to update the value of an Umbraco DropDownList
property in code based on a value instead of the key that's
automatically assigned by the Prevalue Editor.&nbsp; I came across
<a
href="http://www.blogfodder.co.uk/2009/12/22/getting-dropdown-list-datatype-values-in-your-html"
 target="_blank"
title="Getting Dropdown List DataType Values In Your HTML">this</a>
but it discusses retrieving values for XSLT specifically.&nbsp; In
my scenario I needed to find a specific key.</p>

<p>The simplest way to do this is with XML to Linq.&nbsp; In the
example below I'm using the property's DataTypeDefinition to
retrieve the relevant prevalue collection instead of hard-coding
the Id of the DropDownList.&nbsp; This means I have full
flexibility in case something changes in the future:</p>

<pre class="brush: c-sharp;">
if (p.getProperty("status") != null)
{
    var status = p.getProperty("status");

    status.Value = XElement.Parse(library.GetPreValues(status.PropertyType.DataTypeDefinition.Id).Current.OuterXml)
                           .Descendants("preValue").FirstOrDefault(pv =&gt; pv.Value == "On Offer").Attribute("id").Value;

    p.Save();
}
</pre>

<p>Note I could also have written it like this in Linq
notation:</p>

<pre class="brush: c-sharp;">
status.Value = (from pv in XElement.Parse(library.GetPreValues(status.PropertyType.DataTypeDefinition.Id).Current.OuterXml).Descendants("preValue")
                       where pv.Value == "On Offer"
                       select pv.Attribute("id").Value).FirstOrDefault();
</pre>

<p>&nbsp;That's all there is to it.</p>
]]></description></item><item><title>Windows 8 DP with Boot Camp 4.0</title><link>http://refactored.com.au/blog/2011/12/16/windows-8-dp-with-boot-camp-40/</link><pubDate>Fri, 16 Dec 2011 20:58:00 GMT</pubDate><guid>http://refactored.com.au/blog/2011/12/16/windows-8-dp-with-boot-camp-40/</guid><description><![CDATA[ 
<p><strong>UPDATE 1st March 2012:</strong> Installing Boot Camp 4.0
has been verified to work with Windows 8 Consumer Preview that has
just been released.</p>

<p>Today I downloaded the Apple Boot Camp 4.0 using the BootCamp
Assistant in OSX Lion with the intention of installing it on my
Windows 8 Developer Preview.&nbsp; After burning it to CD and
re-booting in Windows 8, I discovered that Boot Camp 4.0 only
supports Windows 7, and promptly refused to install under Windows
8.</p>

<p>After searching the 'net for a solution to no avail (the best
advice on offer was to go into the Drivers directory and install
each one individually), I tried something radical.&nbsp; I turned
on the Compatibility settings for the actual BootCamp64.MSI. Lo and
behold, it worked! Boot Camp proceeded to install itself and the
relevant drivers without a hitch.</p>

<p><strong>Note:</strong> You will need a mouse with a dedicated
Right Mouse Button so that you can bring up the properties on the
setup file.</p>

<p><strong>Consumer Preview Note:</strong> This procedure has been
updated for the Windows 8 Consumer Preview.</p>

<p>So here's the process:</p>

<ol>
<li>Navigate to the folder containing the BootCamp MSI files</li>

<li>Right-click on the Setup executable</li>

<li>Open up the Properties dialog and go to the Compatibility
tab.</li>

<li>Turn Compatibility Mode on (select "Run this program in
compatility mode for:") and choose"<em>Windows 7</em>" in the drop
down.</li>

<li>Click OK, and go run the installer again.</li>

<li>Restart your computer, and enjoy.</li>
</ol>

<p>That's about it.</p>

<p>&nbsp;</p>
]]></description></item><item><title>Introducing the Umbraco View Counter</title><link>http://refactored.com.au/blog/2011/11/14/introducing-the-umbraco-view-counter/</link><pubDate>Mon, 14 Nov 2011 01:12:00 GMT</pubDate><guid>http://refactored.com.au/blog/2011/11/14/introducing-the-umbraco-view-counter/</guid><description><![CDATA[ 
<p>Over the last couple of days we've been busy creating an Umbraco
package that deals with Content View Counters - it enables the web
master to track the number of times content has been viewed on the
site.</p>

<p>The Documentation and package has just been uploaded to the
Umbraco Project Repository and can be downloaded from <a
href="http://our.umbraco.org/projects/website-utilities/refactored-content-views"
 target="_blank" title="Refactored Content Views">here</a>.&nbsp;
This post deals with a few of the features of the package, which
was built agains Umbraco 4.7 and dotNet 4.0</p>

<h2>Introduction</h2>

<p>TheRefactored Content Viewspackage is essentially a content
views (number of times&nbsp; viewed) counter.&nbsp; The current
functionality offered by this package includes:</p>

<ul>
<li>Optional Data Type that allows for configuring view counters
with various categories and the ability to instruct Macros etc. to
"hide" the view Count yet still increment it.</li>

<li>Optional incrementing when displaying the view count (useful
when you want to display the view count in a content listing, for
example)</li>

<li>Example Razor Script and Macro.</li>

<li>Library methods to manipulate the counters and retrieve details
as an XML fragment for use with XSLT.</li>
</ul>

<h2>Basic Usage.</h2>

<p>To simply retrieve and/or increment the counter for a specific
content item, call the following library method.&nbsp; The category
and increment parameters are optional, with default values shown
initalics:</p>

<pre class="brush: c-sharp;">
ViewCount.GetViewCount(nodeId, category: "&lt;empty string&gt;", increment: false);
</pre>

<p>There is no requirement to configure a DataType; supplying the
node id of any valid Content-based node (Member, Document, Media,
etc.) will create the Views record in the database if it doesn't
exist.&nbsp; However configuring and using a DataType will allow
you to control the advanced features of the counter.</p>

<h2>Out of the box</h2>

<p>Out of the box you get a default DataType (View Count) and a
sample Razor Macro that displays the current View Count of the node
being displayed.&nbsp; If you have set up the Document Type with
the View Count DataType, the macro will check whether the View
Count should be displayed or not.</p>

<h3>Macro Parameters for Page Views:</h3>

<ul>
<li>Category (text) - optionally specifies the Category to record
the Page Count against.</li>

<li>Increment (bool) - set to true to increment the Page Count when
the macro is called.</li>
</ul>

<h3>Macro Script Contents:</h3>

<pre class="brush: c-sharp;">
@inherits umbraco.MacroEngines.DynamicNodeContext
@using umbraco.MacroEngines;
@using umbraco.NodeFactory;
@using Refactored.UmbracoViewCounter;

@if (!ViewCount.HideCounter(Model.Id, category: Parameter.Category)) {
  &lt;span&gt;# Views:@ViewCount.GetViewCount(@Model.Id, category: @Parameter.Category, increment: @Parameter.Increment == "1").ToString("N0")&lt;/span&gt;
} else {
  ViewCount.Increment(Model.Id, category: Parameter.Category);
}
</pre>

<h2>&nbsp;Setting up a Data Type</h2>

<p>The Data Type has the following Parameters:</p>

<p><img src="/media/3098/fig_1_499x273.jpg"  width="499"  height="273" alt="View Count DataType" style="display: block; margin-left: auto; margin-right: auto;"/></p>

<ul>
<li>Category- Specifyinga different category for multiple DataTypes
allows you to differentiate between multiple View Counts in a
single content item.&nbsp; You can then render the content in
different views and have a different View Count for each
rendering.</li>

<li>Hide View Count- Allows you to control (in conjunction with the
API and Razor or XSLT macros, for example) whether to hide or show
the view count at a Data Type level.</li>

<li>Enable View History- Turns on recording of View Count History
data including the time the view was incremented.&nbsp; Also
recorded is Reset command events.&nbsp; This data is stored in the
refViewCountHistory table and persists even if the current view
count is reset.&nbsp; This is off by default.</li>

<li>Disable Counter Reset- Turning this on disables the Reset
action on Content configured with a View Count DataType.</li>
</ul>
]]></description></item><item><title>The Playground - interactive Canvas goodness</title><link>http://refactored.com.au/blog/2011/8/31/the-playground-interactive-canvas-goodness/</link><pubDate>Wed, 31 Aug 2011 02:55:00 GMT</pubDate><guid>http://refactored.com.au/blog/2011/8/31/the-playground-interactive-canvas-goodness/</guid><description><![CDATA[ 
<p>We've just created a <a href="#" target="_blank"
title="The Playground">Playground</a> for testing out Javascript
and the Canvas tag with <a href="http://raphaeljs.com/index.html"
target="_blank" title="Raphaël-JavaScript Library">Raphaël</a> and
<a href="http://easeljs.com/" target="_blank"
title="EaselJS: A Javascript Library for Working with the HTML5 Canvas Element.">
EaselJS</a>... At the moment, we're still loading example code to
use with the playground, however there is also a default "blank"
sandbox that you can use to test your own code in provided as
well.</p>

<p>The feature set will grow over time, including contributing your
own examples; however for now feel free to have a play and leave a
comment here with any suggestions for features or code samples you
may like to share.</p>

<p>Enjoy!</p>
]]></description></item><item><title>High School Students and the Internet - not just consumers</title><link>http://refactored.com.au/blog/2011/8/25/high-school-students-and-the-internet-not-just-consumers/</link><pubDate>Thu, 25 Aug 2011 07:22:00 GMT</pubDate><guid>http://refactored.com.au/blog/2011/8/25/high-school-students-and-the-internet-not-just-consumers/</guid><description><![CDATA[ 
<p>Yesterday I met with the local High School to discuss the
possibilities of getting involved by running programs for
interested students in the areas of web and games
development.&nbsp; During the course of the meeting, I was asked to
come up with a few paragraphs that the staff could use when
promoting these programs, so I thought I'd put it up here (partly
to help consolidate my thoughts into a hopefully cohesive
introduction rather than just rambling on...).&nbsp; So here
goes.&nbsp; Any constructive comments or suggestions are entirely
welcome, so please don't be shy - jump right in to the
conversation!</p>

<p>First a little background.&nbsp; The school, Lara Secondary
College in Victoria, Australia is really what you would call a
regional school - Lara is situated outside of the nearest large
city (Geelong) and is considered to be "The country between the
cities" to quote one local resident.&nbsp; While Lara is by no
means a small country town and is rapidly growing, it still retains
that small town community atmosphere.&nbsp; The school itself has a
Connections program for Year 9 Students running for a good part of
the year one day a week, in which students are encouraged to take
on projects that directly benefit the community in some way.</p>

<p>My original vision for setting up a what might look like a club
within the school was to teach students some of the more cutting
edge web technologies focussing on two areas:</p>

<ol>
<li>Web page layout and design utilising HTML5 and CSS3, and</li>

<li>Online Games development utilising open source javascript
frameworks and tools.</li>
</ol>

<p>We would do this by coming up with a project that would benefit
the community in some way - perhaps by re-desiging one of the local
not-for-profit community organisations, or by designing a game with
an educational focus to be used by the wider school community (and
even by other schools)</p>

<p>So this is what I have come up with to introduce students to the
idea and to generate some interest:</p>

<p style="text-align: center;">. o o o 0 0 <strong>O</strong> 0 0 o
o o .</p>

<p>Online Computing these days is pervasive in all areas of our
daily lives - whether it be reading emails or chatting on Facebook,
or perhaps playing your favourite game of Pac Man, the humble Web
Browser is fast becoming less of an application in its own right
and taking a seat in the background while it acts as simply a host
to highly interactive and expressive web-based applications.&nbsp;
These days you can play games and watch movies; connect with people
from across the globe; or just write that business document - all
from within one of the popular Web Browsers without having to
install a thing.</p>

<p>Today we have tools freely available within our grasp to not
only create visually compelling web sites, but also make those
websites dynamically interactive with video, sound, and
animation.&nbsp; There are tools and frameworks upon which games
are being built, and high quality graphics can be rendered right
within the browser window.&nbsp; In fact, you can author a complete
website&nbsp; from scratch without having to open anything more
than your favourite browser.</p>

<p>JavaScript - the programming language of the web browser - can
be used to program a website to pull information and present it
from sources all over the web - want your Facebook status displayed
on your website? no problem.&nbsp; Perhaps you have uploaded a new
YouTube video and want to embed it on your site. Easy.&nbsp; Or
maybe you want to be able to plot geographical data and connect the
dots with Google Maps.&nbsp; JavaScript can be used to do all this
and more.</p>

<p>We are looking for a group of students with an interest in
computing, and who have a passion to do more than just use the web
- they want to build it.&nbsp; Students will gain an understanding
of the building blocks of a website, and we then go beyond that to
examine what it takes to create a game from scratch that can be
used to deliver value to the wider community.&nbsp; We will also
have professionals who are experts in their field come in and hold
workshops in the areas of Graphic Design and Web Development.</p>

<p style="text-align: center;">. o o o 0 0 <strong>O</strong> 0 0 o
o o .</p>

<p>That's it.&nbsp; If anyone has anything to add, or any other
comments, suggestions or thoughts, please, drop me a line...</p>
]]></description></item><item><title>Blog 4 Umbraco Extensions Documentation</title><link>http://refactored.com.au/blog/2011/6/30/blog-4-umbraco-extensions-documentation/</link><pubDate>Thu, 30 Jun 2011 18:38:00 GMT</pubDate><guid>http://refactored.com.au/blog/2011/6/30/blog-4-umbraco-extensions-documentation/</guid><description><![CDATA[ 
<p>Finally, some 8 months after the Blog4Umbraco Extensions library
became available, I decided to post it to the package repository on
<a
href="http://our.umbraco.org/projects/collaboration/refactored-blog4umbraco-extensions"
 target="_blank"
title="Our.Umbraco - Refactored Blog4Umbraco Extensions">our.umbraco.org</a>
and create some actual documentation for it - this is the
result...</p>

<p>This document may also be downloaded as a PDF from <a
href="/media/2950/blog4umbraco_extensions_post_installation_guide.pdf"
 target="_blank">here</a>.</p>

<h2>Introduction</h2>

<p>The Refactored Blog4Umbraco Extensions came about because the
current version of Blog4Umbraco (currently 2.0.26) had some issues
when it came to creating multiple blogs within a single website,
and in addition under some circumstances creating a new blog entry
would cause a "Yellow Screen of Death" (YSod).</p>

<p>In order to address these shortcomings this package was created,
and later extended with other functionality.&nbsp; The current
functionality offered by this package includes:</p>

<ul>
<li>Allowing Comments to be Disabled at the Blog Level</li>

<li>Enable setting a Blog-wide Category and having Tags bound to
that Category</li>
</ul>

<p>An additional Datatype called Blog Tags and derived from the
built in Tags Datatype is also provided which is the basis upon
which the Blog-wide Category is built.</p>

<p>For a more detailed and technical description of the package,
the reader is directed to the blog entries found at <a
href="/blog">/blog</a>:</p>

<ul>
<li><a
href="/blog/2010/10/19/blog-categories-in-blog4umbraco-take-two/">Blog
Categories in Blog4Umbraco - Take Two</a></li>

<li><a
href="/blog/2010/10/18/adding-a-blog-category-to-blog4umbraco/">Adding
a Blog Category to Blog4Umbraco</a> (the method described here is
not recommended, but provides additional background
information).</li>
</ul>

<h2>The Future</h2>

<p>Work is currently underway to release a version 3 of
Blog4Umbraco (B4U) which will address the issues discussed here and
add other much needed functionality including Trackbacks and
Comment Notifications.</p>

<h2>Post-Installation Steps</h2>

<p>After installing the package, additional steps are required in
order to activate the features.&nbsp; These involve modifying the
Blog-related document types as follows:</p>

<h3>Globally Disabling Comments</h3>

<p>In order to be able to globally disable comments, edit the Blog
Document Type by adding a new property based on the True/False data
type as follows:</p>

<p style="text-align: center;"><img src="/media/2927/blogdisablecomments.png" width="474" height="299" alt="Blog DisableComments Property"/>&nbsp;</p>

<p>If the Disable Comments checkbox is checked on a Blog page then
the Close comments field will be also become checked when it is
saved.</p>

<h3>Blog Categories</h3>

<h4>Updating the Blog Document Type</h4>

<p>In order to facilitate Blog Categories, an additional property
needs to be added to the Blog Document Type as follows:</p>

<p style="text-align: center;"><img src="/media/1976/blogcategory.png" width="404" height="299" alt="BlogCategory"/>&nbsp;</p>

<p>Coupled with the change to the Blog Post Document type below,
this will cause tags added to blog posts to use the category set in
this property of the corresponding Blog.</p>

<h4>Updating the Blog Post Document Type</h4>

<p>Change the Tags property in the Blog Post Document so that it
uses the "Blog Tags" type instead of the built-in "Tags" data
type:</p>

<p style="text-align: center;">&nbsp;<img src="/media/2933/blogposttags.png" width="421" height="150" alt="blogPost Blog Tags"/></p>

<h3>Enabling Time fields in the Blog Entry Post Date</h3>

<p>In the original Blog4Umbraco package, there is no way to enable
the Post Date to use time as well as date, which results in all
posts being set as being posted at midnight.&nbsp;</p>

<p>The updated Umlaut.Umb.Blog.dll file included in this package
addresses this issue, but you still need to modify the Blog Post
document type in order to take advantage of the change.&nbsp; In
order to do so, change the Post Date property type from "Date
Picker" to "Date Picker with time":</p>

<p style="text-align: center;"><img src="/media/2939/blogpost_postdate.png" width="404" height="152" alt="blogPost PostDate Property"/>&nbsp;</p>

<h2>Other Issues:</h2>

<h3>Blog for Umbraco generates the following error when attempting
to create a new Blog:</h3>

<p><strong>Issue # 5612 - <a
href="http://blog4umbraco.codeplex.com/workitem/5612"
target="_blank">http://blog4umbraco.codeplex.com/workitem/5612</a></strong></p>

<pre>
Operand type clash: int is incompatible with ntext<br />
 Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.<br />
<br />
 Exception Details: System.Data.SqlClient.SqlException: Operand type clash: int is incompatible with ntext
</pre>

<h4>Workaround:</h4>

<p>If you encounter this type of error, double-check the Author
Picker and make sure that the datatype is set tointinstead
ofntext.</p>
]]></description></item><item><title>Conditionally disabling Ajax in MVC3 Forms</title><link>http://refactored.com.au/blog/2011/6/6/conditionally-disabling-ajax-in-mvc3-forms/</link><pubDate>Mon, 06 Jun 2011 01:55:00 GMT</pubDate><guid>http://refactored.com.au/blog/2011/6/6/conditionally-disabling-ajax-in-mvc3-forms/</guid><description><![CDATA[ 
<p>While working with MVC3 and Razor views recently, we came across
the need to disable the Ajax behaviour in a form when the user
pressed a certain submit button.&nbsp; To give you some background,
we were working on a Shopping Cart whereby the user had the
following possible actions:</p>

<ul>
<li>Edit an item,</li>

<li>Delete an item</li>

<li>Update the quantity of an item,</li>

<li>Submit the cart to Checkout</li>

<li>Clear the cart</li>

<li>Refresh the cart.</li>
</ul>

<p>Now, for most cases, we wanted the cart to be refreshed without
the user having to see a post back, so Ajax was the best way to
handle this, of course.&nbsp; Although the application is based on
the Umbraco CMS, we developed the e-Commerce side of things in MVC3
from scratch and integrated it with Umbraco using the excellent <a
href="http://our.umbraco.org/projects/developer-tools/mvcbridge"
target="_blank" title="MvcBridge">MVCBridge</a> add-on.&nbsp; This
allowed us to take advantage of all MVC has to offer.&nbsp;
However, the solution that follows is not dependant on Umbraco or
MVCBridge at all.</p>

<p>Because this is a new project and has no legacy MVC code in it,
we are able to take full advantage of the new <a
href="http://bradwilson.typepad.com/blog/2010/10/mvc3-unobtrusive-ajax.html"
 target="_blank"
title="Unobtrusive Ajax in ASP.NET MVC 3">Unobtrusive Ajax</a>
style for binding Ajax to the form.&nbsp; This means that under the
hood we are using jquery's ajax engine only, and not the legacy
Microsoft one.&nbsp; Here's the basic form:</p>

<pre class="brush: xhtml;">
@using (Ajax.BeginForm(new AjaxOptions
{
    OnSuccess = "updateCart"
}))
{

    @Html.RenderFormToken();
&lt;section id="shoppingCart"&gt;
    &lt;h1&gt;Items in your Shopping Cart&lt;/h1&gt;
    &lt;table cellpadding="0" cellspacing="0"&gt;
    @foreach (var item in Model.Items.Values)
    {
        // Render the items, including the Edit, Delete and Update submit buttons...
    }
    &lt;tr&gt;
        &lt;td colspan="3" class="totalValue"&gt;Total Value:&lt;/td&gt;
        &lt;td class="totalValue"&gt;@Html.DisplayFor(model =&gt; model.TotalIncTax)
        @Html.HiddenFor(model =&gt; model.TotalItemCount)
        @Html.HiddenFor(model =&gt; model.TotalIncTax)&lt;/td&gt;
        &lt;td class="totalValue"&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;/table&gt;
    &lt;span class="submit"&gt;&lt;input type="submit" value="Refresh Cart" name="refresh" id="refresh" /&gt;
    &lt;input type="submit" value="Clear" name="reset" id="reset" /&gt;
    &lt;input type="submit" value="Checkout" name="checkout" id="checkout" /&gt;&lt;/span&gt;
&lt;/section&gt;
}
</pre>

<p><br />
 Now, when a user presses any of the submit buttons, the form will
be posted back to the server, and the new page content will be
returned to the updateCart function so that we can update the
user's view without having to refresh the page.</p>

<p>But we want the item Edit and the Checkout buttons to re-direct
to a new page instead of submitting back to the shopping
cart.&nbsp; For that to happen, we need to do two things (let's
focus on the Checkout button, which we want to re-direct to the
Checkout page):</p>

<ol>
<li>In the ShoppingCartController we need to check which submit
button was pressed by inspecting the form elements, and do a
Resonse.Redirect() to the appropriate page if the user pressed the
Checkout button, for example; and</li>

<li>Disable the Ajax behaviour when the user presses the Checkout
button.</li>
</ol>

<p>The code to handle the second step is as follows:</p>

<pre class="brush: javascript;">
   // These variables are defined here as they may be referenced in other code blocks.
   // The $().ready function is used to populate them.
    var cartSection = null;
    var eShopCartForm = null;

    $(document).ready(function () {
        cartSection = $("#shoppingCart");
        eShopCartForm = cartSection.closest("form");

        // Disable the ajax behaviour if the checkout button is pressed.  We want the form
        // to submit normally so that the page can be redirected. 
        var checkoutSubmit = cartSection.find("#checkout");

        // We supply our own handler for this button to remove the form's ajax submit handler.
        checkoutSubmit.live("click", function (evt) {
            // Setting this attribute to false means the ajax form submit handler won't be triggered...
            eShopCartForm.attr("data-ajax", "false");
        });
    });
</pre>

<p>If you care to dig deeper, then I recommend taking a look
through the jquery.unobtrusive-ajax.js file that is bundled with
the MVC3 projects.&nbsp; Basically though we are changing the
data-ajax attribute that is generated on the form element when the
user clicks the checkout button so that the ajax submit handler
doesn't trigger.</p>

<p>There you have it.&nbsp; Any questions, suggestions, remarks,
please leave a comment...</p>
]]></description></item><item><title>Resetting IE9's Javascript Engine</title><link>http://refactored.com.au/blog/2011/5/19/resetting-ie9's-javascript-engine/</link><pubDate>Thu, 19 May 2011 17:25:00 GMT</pubDate><guid>http://refactored.com.au/blog/2011/5/19/resetting-ie9's-javascript-engine/</guid><description><![CDATA[ 
<p>Quick post this time - lately I've come across this obscure
error in Javascript with Internet Explorer 9 whenever I tried to
run a jQuery ligthbox script:</p>

<pre>
appendChildOriginal(element);<br />
<br />
jscript debugger<br />
breaking on jscript runtime error - invalid calling object
</pre>

<p>after tearing my hair out and "researching" the problem on
Google, I came across this obscure solution:</p>

<pre>
IE:&nbsp; Tools-&gt;Options Advanced Settings "Reset"
</pre>

<p>(found here: "<a href="http://forums.asp.net/t/1664964.aspx/1"
target="_blank" title="Microsoft J">Microsoft J</a>")</p>

<p>Seems that all that is needed to fix the problem is resetting
the Internet Explorer settings fixes the problem.</p>

<p>A translation of the line above is as follows:</p>

<p>In Internet Explorer 9, Open the "Internet Options" either from
the Tools menu (hit ALT to make the menu appear) or the "Cog" icon
drop down.</p>

<p>Go to the Advanced Tab, and hit the "Reset..." button.&nbsp; On
the dialog that pops up, hit "Reset" again.</p>

<p>That's it. problem solved.&nbsp; No need to reinstall IE 9.</p>
]]></description></item></channel></rss>
