<?xml version="1.0" encoding="utf-8"?>
			
			<rss version="2.0">
			<channel>
			<title>OscarArevalo.com - jQuery</title>
			<link>http://www.oscararevalo.com/index.cfm</link>
			<description>About ColdFusion and Developing Software</description>
			<language>en-us</language>
			<pubDate>Tue, 07 Sep 2010 17:21:53 -0500</pubDate>
			<lastBuildDate>Mon, 06 Apr 2009 18:57:00 -0500</lastBuildDate>
			<generator>BlogCFC</generator>
			<docs>http://blogs.law.harvard.edu/tech/rss</docs>
			<managingEditor>oarevalo@gmail.com</managingEditor>
			<webMaster>oarevalo@gmail.com</webMaster>
			
			<item>
				<title>Using jQuery.UI.layout to handle HomePortals layouts</title>
				<link>http://www.oscararevalo.com/index.cfm/2009/4/6/Using-jQueryUIlayout-to-handle-HomePortals-layouts</link>
				<description>
				
				&lt;b&gt;** Update: **&lt;/b&gt; Updated code examples and attached file to be compatible with HomePortals 3.1.570

A few days ago I found out (via tweeter) about &lt;a href=&quot;http://layout.jquery-dev.net/&quot;&gt;this plugin&lt;/a&gt; for jQuery. Apparently UI.Layout is a port or adaptation of &lt;a href=&quot;http://extjs.com/deploy/dev/examples/layout/complex.html&quot;&gt;extJS border-layout&lt;/a&gt; but done the jQuery way. Well, this is basically a plugin to create complex full-screen layouts, with resizable panels and everything... really cool stuff. So I started wondering if I could use this to leverage the way HomePortals deals with page layouts and see if I could use hp to declare the page modules/widgets/content but on a layout controlled by the UI.Layout plugin. It turns out in fact that I was able to mix both projects pretty easily. Here&apos;s how.

First of all, lets jump to the end and see what the finished product looks like

&lt;a href=&quot;http://www.oscararevalo.com/images//ui_layout_1.jpg&quot;&gt;&lt;img src=&quot;http://www.oscararevalo.com/images//ui_layout_1.jpg&quot; width=&quot;500&quot; border=&quot;0&quot;&gt;&lt;/a&gt;

And this is the corresponding HomePortals page:

&lt;code&gt;
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;Page&gt;
	&lt;title&gt;Using jquery UI Layout with HomePortals. Example 1&lt;/title&gt;
	&lt;layout&gt;
		&lt;location name=&quot;header1&quot; type=&quot;region&quot; class=&quot;ui-layout-north&quot; /&gt;
		&lt;location name=&quot;column1&quot; type=&quot;region&quot; class=&quot;ui-layout-west&quot;/&gt;
		&lt;location name=&quot;column2&quot; type=&quot;region&quot; class=&quot;ui-layout-center&quot;/&gt;
		&lt;location name=&quot;column3&quot; type=&quot;region&quot; class=&quot;ui-layout-east&quot;/&gt;
		&lt;location name=&quot;footer1&quot; type=&quot;region&quot; class=&quot;ui-layout-south&quot;/&gt;
	&lt;/layout&gt;
	&lt;eventListeners/&gt;
	&lt;body&gt;
		&lt;content id=&quot;c1&quot; href=&quot;../lorem.txt&quot; location=&quot;header1&quot; title=&quot;c1&quot; /&gt;
		&lt;content id=&quot;c2&quot; href=&quot;../lorem.txt&quot; location=&quot;column1&quot; title=&quot;c2&quot; /&gt;
		&lt;view id=&quot;c3&quot; href=&quot;../about.cfm&quot; location=&quot;column2&quot; title=&quot;c3&quot; /&gt;
		&lt;content id=&quot;c4&quot; href=&quot;../lorem.txt&quot; location=&quot;column3&quot; title=&quot;c4&quot; /&gt;
		&lt;content id=&quot;c5&quot; href=&quot;../lorem.txt&quot; location=&quot;footer1&quot; title=&quot;c5&quot; container=&quot;false&quot; /&gt;
	&lt;/body&gt;
&lt;/Page&gt;
&lt;/code&gt;

You can check out a live demo of this page &lt;a href=&quot;http://www.oscararevalo.com/uilayout/ex1/&quot;&gt;here&lt;/a&gt;.

So, did I pick your interest? well, if yes, then keep reading to find out how this was implemented. At the end of this post you can find a zip with the entire example, but let me go over the important bits here.

** Note that this example requires HomePortals 3.1, and will not work in earlier versions. You can get the latest release &lt;a href=&quot;http://www.homeportals.net/downloads.cfm&quot;&gt;here&lt;/a&gt;

First of all, we need to setup a HomePortals application for this example and set the appropriate environment. For the purpose of this example, our HomePortals application will live on a directory named &quot;uilayout&quot;. You can find the complete dir structure and required files on the attached zip file.

For the main settings we will use the standard config xml file.

&lt;b&gt;homePortals-config.xml.cfm&lt;/b&gt;
&lt;code&gt;
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;homePortals&gt;
	&lt;baseResources&gt;
		&lt;resource href=&quot;../includes/jquery.js&quot; type=&quot;script&quot;/&gt;
		&lt;resource href=&quot;../includes/ui.core.js&quot; type=&quot;script&quot;/&gt;
		&lt;resource href=&quot;../includes/ui.draggable.js&quot; type=&quot;script&quot;/&gt;
		&lt;resource href=&quot;../includes/jquery.layout.js&quot; type=&quot;script&quot;/&gt;
		&lt;resource href=&quot;init.js&quot; type=&quot;script&quot;/&gt;
	&lt;/baseResources&gt;
	&lt;renderTemplates&gt;
		&lt;renderTemplate href=&quot;pageTemplate.htm&quot; type=&quot;page&quot; name=&quot;page&quot; /&gt;
	&lt;/renderTemplates&gt;
&lt;/homePortals&gt;
&lt;/code&gt;

Here we declare all the necessary jQuery javascript files. These are ones required by the UI.Layout plugin plus one additional &quot;init.js&quot; to handle our jQuery initialization routine for this page.

&lt;b&gt;init.js&lt;/b&gt;
&lt;code&gt;
$(document).ready(function () {
	$(&apos;body&apos;).layout({ applyDefaultStyles: true });
});
&lt;/code&gt;

The only thing this does is to initialize the layout plugin.

Then finally the final bit of configuration that we need to add is to define a &quot;page&quot; render template. This is because the overall HTML markup needed by the UI.Layout is way much simpler than the default HTML structure that comes out of the box in HomePortals. The &quot;page&quot; render template controls the overall HTML structure that will be used to render all HomePortals pages.

&lt;b&gt;pageTemplate.htm&lt;/b&gt;
&lt;code&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
	&lt;head&gt;
		&lt;title&gt;$PAGE_TITLE$&lt;/title&gt;
		$PAGE_HTMLHEAD$
	&lt;/head&gt;
	&lt;body onLoad=&quot;$PAGE_ONLOAD$&quot;&gt;
		$PAGE_CUSTOMSECTION[&quot;HEADER&quot;]$
		$PAGE_LAYOUTSECTION[&quot;REGION&quot;][&quot;DIV&quot;]$
		$PAGE_CUSTOMSECTION[&quot;FOOTER&quot;]$
	&lt;/body&gt;
&lt;/html&gt;
&lt;/code&gt;

The relevant part here is the &lt;b&gt;$PAGE_LAYOUTSECTION[&quot;REGION&quot;][&quot;DIV&quot;]$&lt;/b&gt; line. This just tells the HomePortals renderer to render all &quot;region&quot; sections one after another and use DIV tags around them. The HEADER and FOOTER custom sections are really not needed and not even used on this example.

The UI.Layout plugin uses CSS class names on DIV elements to determine the type of layout region. There are five types: center, north, south, east and west; each one with its own specific class name. So, since all our layout regions will be rendered the same, we will need only &quot;one&quot; kind of layout region. We will name this a &quot;region&quot;.

So, once that is in place, we can just declare our pages and use the UI.Layout class definitions to create the layout. Like this:

&lt;b&gt;default.xml&lt;/b&gt;
&lt;code&gt;
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;Page&gt;
	&lt;title&gt;Using jquery UI Layout with HomePortals. Example 1&lt;/title&gt;
	&lt;layout&gt;
		&lt;location name=&quot;header1&quot; type=&quot;region&quot; class=&quot;ui-layout-north&quot; /&gt;
		&lt;location name=&quot;column1&quot; type=&quot;region&quot; class=&quot;ui-layout-west&quot;/&gt;
		&lt;location name=&quot;column2&quot; type=&quot;region&quot; class=&quot;ui-layout-center&quot;/&gt;
		&lt;location name=&quot;column3&quot; type=&quot;region&quot; class=&quot;ui-layout-east&quot;/&gt;
		&lt;location name=&quot;footer1&quot; type=&quot;region&quot; class=&quot;ui-layout-south&quot;/&gt;
	&lt;/layout&gt;
	&lt;body&gt;
		&lt;content id=&quot;c1&quot; href=&quot;../lorem.txt&quot; location=&quot;header1&quot; title=&quot;c1&quot; /&gt;
		&lt;content id=&quot;c2&quot; href=&quot;../lorem.txt&quot; location=&quot;column1&quot; title=&quot;c2&quot; /&gt;
		&lt;view id=&quot;c3&quot; href=&quot;../about.cfm&quot; location=&quot;column2&quot; title=&quot;c3&quot; /&gt;
		&lt;content id=&quot;c4&quot; href=&quot;../lorem.txt&quot; location=&quot;column3&quot; title=&quot;c4&quot; /&gt;
		&lt;content id=&quot;c5&quot; href=&quot;../lorem.txt&quot; location=&quot;footer1&quot; title=&quot;c5&quot; container=&quot;false&quot; /&gt;
	&lt;/body&gt;
&lt;/Page&gt;
&lt;/code&gt;

The &lt;b&gt;layout&lt;/b&gt; section is where we declare the page layout using the UI.Layout class names for the different regions. So if we want to customize the layout, say, do not have a footer, or have only one left column, we can change that here easily by just removing the location tags that we don&apos;t need.

The next section &lt;b&gt;body&lt;/b&gt; is where we declare what goes into which layout region. the &lt;b&gt;content&lt;/b&gt; tags just display plain text or html content while the &lt;b&gt;view&lt;/b&gt; tag does a cfinclude of a CFML template. Of course you can now use the whole HomePortals framework features to create your own tags and do whatever you need.

And since jQuery is so awesome, &lt;a href=&quot;http://www.oscararevalo.com/uilayout/ex2/&quot;&gt;here&lt;/a&gt; is another example that uses pretty much the same setup but adds some drag &amp; drop funkyness. 
				</description>
				
				<category>Homeportals</category>				
				
				<category>jQuery</category>				
				
				<category>Coldfusion</category>				
				
				<category>frameworks</category>				
				
				<pubDate>Mon, 06 Apr 2009 18:57:00 -0500</pubDate>
				<guid>http://www.oscararevalo.com/index.cfm/2009/4/6/Using-jQueryUIlayout-to-handle-HomePortals-layouts</guid>
				
				<enclosure url="http://www.oscararevalo.com/enclosures/uilayout-updated.zip" length="135475" type="application/octet-stream"/>
				
			</item>
			</channel></rss>