<?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"
	>

<channel>
	<title>SkyBlueCanvas &#187; Showing Text Shreds Anywhere in SkyBlueCanvas - SkyBlueCanvas</title>
	<atom:link href="http://blog.skybluecanvas.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.skybluecanvas.com</link>
	<description>The Lightweight Blog</description>
	<pubDate>Fri, 29 Aug 2008 01:00:46 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>Showing Text Shreds Anywhere in SkyBlueCanvas</title>
		<link>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/showing-text-shreds-skybluecanvas/</link>
		<comments>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/showing-text-shreds-skybluecanvas/#comments</comments>
		<pubDate>Fri, 29 Aug 2008 00:48:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[SkyBlueCanvas CMS]]></category>

		<category><![CDATA[SkyBlueCanvas Docs]]></category>

		<guid isPermaLink="false">http://blog.skybluecanvas.com/?p=45</guid>
		<description><![CDATA[A recent visitor to the SkyBlueCanvas forum asked how to display individual blurbs of text in a specific spot on a SkyBlueCanvas page. If you are familiar with the SkyBlueCanvas Managers and Modules you probably recognize that this concept is very similar to the Teasers. In this post I will show you how to show individual Teasers anywhere you want.]]></description>
			<content:encoded><![CDATA[<p>A recent visitor to the SkyBlueCanvas forum asked how to display individual blurbs of text in a specific spot on a SkyBlueCanvas site page. If you are familiar with the SkyBlueCanvas Managers and Modules you probably recognize that this concept is very similar to the Teasers. The problem with using the Teasers module in this instance is, however, that the module will display all teasers in the page region where the module is displayed.</p>
<p class="info">
If you currently have the Teasers Module enabled and displaying on your site, this technique may display some content twice.
</p>
<h2>SkyBlueCanvas Plugins to the Rescue</h2>
<p>Since the creation of content and rendering of content is fairly well separated in SkyBlueCanvas, it is possible to display content in an unlimited number of ways. To solve this particular problem I chose to write a simple plugin to allow me to specify the specific Teaser I want to display and even restrict the display to an individual page or a list of pages.</p>
<p>The concept is actually pretty simple:</p>
<ul>
<li>Create a plugin that accepts a Teaser ID and Page ID as its arguments
<li>
<li>Add the Plugin Call to my template or page text</li>
</ul>
<h2>The Plugin Call</h2>
<p>The plugin will make more sense if we first examine the plugin call. If you need a refresher on the SkyBlueCanvas Plugin API see the post on <a href="">SkyBlueCanvas Plugins</a>.</p>
<p>There are two ways to explicitly call a SkyBlueCanvas Plugin:</p>
<p>An HTML comment plugin call:</p>
<pre class="html">
&lt;!--#plugin:myPluginFunction(arg1, arg2,...)--&gt;
</pre>
<p>Or a plugin call from within the text of a story:</p>
<pre class="html">
{plugin:myPluginFunction(arg1, arg2,...)}
</pre>
<p>For this plugin we are going to pass two arguments, the Teaser ID and the Page ID and we&#8217;ll use an HTML comment plugin call. The code below will be added to our HTML template (skin):</p>
<pre class="html">
&lt;!--#plugin:plgSnippet(2,1)--&gt;
</pre>
<p>The above plugin call will tells the Snippet Plugin that we will create next to display Teaser ID 2 on Page ID 1 (the home page). It won&#8217;t actually do anything yet, however. It is just an HTML comment and will not display on the page.</p>
<h2>The Plugin Code</h2>
<p>The PHP code below includes comments to explain each step of the process so I won&#8217;t repeat it.</p>
<pre class="php">
&lt;?php

  /**
  * Show an individual Teaser item in a page region indicated by
  * &lt;!--#plugin:plgSnippet($id, $pageId)--&gt;
  *
  * @param  array  An argument array
  * @return string The html of the snippet
  */

  function plgSnippet($args)
  {
    global $Core;

    /*
    *  If no arguments are passed, return a null value.
    */

    if (!count($args)) return null;
    $id = $args[0];

    /*
    * The second argument is optional. If you want to
    * only show the snippet on a specific page, pass
    * the page ID as the second arguemnt.
    */

    $pageId = count($args) == 2
      ? plgSnippetConvertArg($args[1])
      : null ;

    /*
    * Store the current page id in a variable.
    */

    $thisPageId = $Core-&gt;GetVar($_GET, &#8216;pid&#8217;, null);

    /*
    * The page id passed by the plugin call can be a single
    * page id or an array of page ids. If the page id is set,
    * make sure it matches the current page id.
    */

    if (is_array($pageId) &#038;&#038; !in_array($thisPageId, $pageId))
    {
      return null;
    }
    else if (!empty($pageId) &#038;&#038; $thisPageId !== $pageId)
    {
      return null;
    }

    /*
    * If we made it this far, we need to show the snippet.
    */

    $snippets = $Core-&gt;xmlHandler-&gt;parserMain(
        SB_XML_DIR . &#8216;teaser.xml&#8217;
      );
    $snippet = $Core-&gt;SelectObj($snippets, $id);
    if (!$snippet) return null;
    $html  = &#8220;&lt;div id=\&#8221;snippet-$id\&#8221;&gt;\n&#8221;;
    $html .= &#8220;&lt;h2&gt;{$snippet-&gt;name}&lt;/h2&gt;\n&#8221;;
    $html .= &#8220;&lt;p&gt;&#8221; .
      base64_decode($snippet-&gt;intro) .
      &#8220;&lt;/p&gt;\n&#8221;;
    $html .= &#8220;&lt;/div&gt;\n&#8221;;
    return $html;
  }

  /**
  * Convert an argument to an array if it contains the
  * &#8216;,&#8217; delimiter. Otherwise return the argument untouched.
  */

  function plgSnippetConvertArg($arg)
  {
    if (strpos($arg, &#8216;,&#8217;) == false) return $arg;
    $args = explode(&#8217;,', $arg);
    for ($i=0; $i&lt;count($args); $i++)
    {
      $args[$i] = trim($args[$i]);
    }
    return $args;
  }

?&gt;
</pre>
<h2>Putting It All Together</h2>
<p>Now, log into your SkyBlueCanvas Site Admin and go to: Collections &gt; Plugins</p>
<p>Click the Add button to create a new plugin. You can name the plugin anything you like but keep in mind that plugins must be named &#8216;plugin.your_plugin_name.php&#8217;. Let&#8217;s just name it plugin.snippet.php.</p>
<p>Next, paste the PHP code above into the text area on the Plugin Editor and click Save.</p>
<p>The plugin is created and is now active. The next step is to create a Teaser (or Teasers) to display so go to Collections &gt; Teasers. Click the Add button and give your Teaser a name. The name can be anything you like and may include spaces. Add the Teaser text. Be sure to leave the Link selector set to No Link. Click Save.</p>
<p>Next, go to Collections &gt; Collections Publishing and make sure that mod.teaser.php is not published on any pages.</p>
<p>Okay, we are down to the final step - calling our Snippet Plugin to display our snippet(s). Go to Main Dashboard &gt; Pages and click Edit in the task list next to your home page.</p>
<p>In the HTML editor, add the following code:</p>
<pre class="html">
{plugin:plgSnippet(2)}
</pre>
<p>Notice that we did not provide the second argument (the page id). Since we are calling the plugin from the Home Page text, we do not need the second argument.</p>
<p>Save your page and go to your site&#8217;s home page. You should see the Teaser name and text displayed on the page. The Snippet output has a unique id formatted as <strong>snippet-n</strong> where <strong>n</strong> is the Teaser ID. This allows you to write CSS rules specific to each Snippet.</p>
<p>The Snippet output will look like this:</p>
<pre class="html">
&lt;div id="snippet-2"&gt;
&lt;h2&gt;My Snippet Title&lt;/h2&gt;
&lt;p&gt;This is my first Snippet.&lt;/p&gt;
&lt;/div&gt;
</pre>
<h2>Alternative Display Techniques</h2>
<p>The Snippet Plugin gives you a couple of display options depending on which call method you use (i.e., HTML comment call or text-based call), and what arguments you pass to the plugin.</p>
<p>For instance, if you are using an HTML comment call, you can restrict the display of the snippet(s) to a single page or a list of pages.</p>
<pre class="html">
&lt;!--#plugin:plgSnippet(2, [1,2,3])&#8211;&gt;
</pre>
<p>The call to the Snippet plugin shown above tells the plugin to display Teaser ID 2 on pages 1, 2 and 3. To display the Teaser only on the first page, use the following format:</p>
<pre class="html">
&lt;!--#plugin:plgSnippet(2,1)--&gt;
</pre>
<p>That&#8217;s all there is to it. As you can see, the SkyBlueCanvas Plugin API gives you a lot of flexibility in what content is displayed on your site and how.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/showing-text-shreds-skybluecanvas/feed/</wfw:commentRss>
		</item>
		<item>
		<title>SkyBlueCanvas v1.1 Beta Release</title>
		<link>http://blog.skybluecanvas.com/skybluecanvas-press-releases/skybluecanvas-v11-beta-release/</link>
		<comments>http://blog.skybluecanvas.com/skybluecanvas-press-releases/skybluecanvas-v11-beta-release/#comments</comments>
		<pubDate>Sun, 17 Aug 2008 06:19:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Press Releases]]></category>

		<guid isPermaLink="false">http://blog.skybluecanvas.com/?p=44</guid>
		<description><![CDATA[The SkyBlueCanvas Development Team has announced the release of version 1.1 Beta of the SkyBlueCanvas Lightweight content management system (CMS). The new version includes improvements to the core functionality as well as several new features including single-click content publishing and re-ordering, an enhanced Plugin API (application programming interface) and simplified module placement and publishing.]]></description>
			<content:encoded><![CDATA[<p>Richmond, VA - The SkyBlueCanvas Development Team has announced the release of version 1.1 Beta of the SkyBlueCanvas Lightweight content management system (CMS). The new version includes improvements to the core functionality as well as several new features including single-click content publishing and re-ordering, an enhanced Plugin API (application programming interface) and simplified module placement and publishing.</p>
<p>“We have focused our efforts on responding to the great feedback we’ve received from our users”, says Scott Lewis, the creator and lead developer of SkyBlueCanvas. “Over the next several weeks we will be preparing a release candidate of the new version and creating good documentation for users and developers”.</p>
<p>SkyBlueCanvas runs on the Apache web server and is compatible with PHP versions 4-5. The system requires no configuration or special modules. You simply un-archive the package in your website directory and start creating your content.</p>
<p>The system is licensed under the GNU/GPL v3.0 License. Service packages for business owners including site setup, customization and design are also available from the development team.</p>
<p><a href="http://www.skybluecanvas.com/beta">Demo URL</a><br />
<a href="http://www.skybluecanvas.com/download-beta">Direct Download Link</a></p>
<p>The SkyBlueCanvas Development Team is made up of Scott Lewis, Todd Crowe and Steve Fister. Scott Lewis is a web applications developer in Richmond, VA and has 8 years of experience in web applications development for the advertising, information security and telecommunications industries. Todd Crowe is a former software developer for NetScape and AOL and has been writing software professionally for over 15 years. Todd has a diverse background in developing operating systems, desktop applications, and large scale web software. Steve Fister has been a professional internet application developer for 15 years, spending most of this time in San Francisco Bay Area. Steve has broad experience in large scale portal development, content management systems, e-learning systems development, and technical writing.</p>
<p>###<br />
Scott Lewis<br />
Lead Developer<br />
804-274-0683<br />
United States<br />
scott@skybluecanvas.com</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.skybluecanvas.com/skybluecanvas-press-releases/skybluecanvas-v11-beta-release/feed/</wfw:commentRss>
		</item>
		<item>
		<title>SkyBlueCanvas Lightweight CMS v1.1 Beta</title>
		<link>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/skybluecanvas-lightweight-cms-v11-beta/</link>
		<comments>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/skybluecanvas-lightweight-cms-v11-beta/#comments</comments>
		<pubDate>Sat, 09 Aug 2008 17:00:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[SkyBlueCanvas CMS]]></category>

		<guid isPermaLink="false">http://blog.skybluecanvas.com/?p=43</guid>
		<description><![CDATA[We are happy to announce that SkyBlueCanvas Lightweight CMS v1.1 Beta is now available for preview. The new version includes several bug fixes as well as improved usability and a host of new features that make SkyBlueCanvas even easier to use. You can view the demo of SkyBlueCanvas v1.1 Beta at <a href="http://www.skybluecanvas.com/beta/">www.skybluecanvas.com/beta/</a>.]]></description>
			<content:encoded><![CDATA[<p>We are happy to announce that SkyBlueCanvas Lightweight CMS v1.1 Beta is now available for preview. The new version includes several bug fixes as well as improved usability and a host of new features that make SkyBlueCanvas even easier to use. You can view the demo of SkyBlueCanvas v1.1 Beta at <a href="http://www.skybluecanvas.com/beta/">www.skybluecanvas.com/beta/</a>.</p>
<p>We had planned an incremental release numbered v1.0.4 but after a  lot of bug fixes, adding several new features and implementing WYMeditor v0.5, we decided that  this release merited a more significant release number. A lot of work went into  improving the over-all usability of SkyBlueCanvas in this release.  We also fixed a lot of bugs that had previously escaped our attention.</p>
<h2>For End Users</h2>
<p>The most visible change in SkyBlueCanvas v1.1 is to the Page Manager including the ability to publish Collections from from the page level rather than a separate manager. In addition users will also notice that we have implemented the latest version of WYMeditor - version 0.5. The new Page Manager also includes the ability to re-order and publish/unpublish items from the list view as well as many other improvements.</p>
<p>The Page Manager, as well as many other Managers now has the ability to re-order and publish/unpublish items from the default list view so you do not need to open the editor to change the order of an item. Simply use the task buttons in the list view.</p>
<p>You can also now add page-specific JavaScript files to your skins. For instance, if you have a layout skin named skin.alternate.html, you can add a JavaScript file that only loads on this page by creating a file named skin.alternate.js in /skyblue_root/data/skins/your_skin/js/.</p>
<p>We also added a new Banner Ads Manager so you can place banner ads through the Admin Console. Previously banner ads were required to be added via FTP only.</p>
<h2>For Developers</h2>
<p>SkyBlueCanvas has several major changes to the code that will interest developers. We added 3 new classes to the OOP hierarchy: SkyBlueObject, Observer and SkyBlueError. These classes add some default shared functionality in getters and setters and most importantly add support for custom events using the Observer Pattern. We will provide full documentation for using custom events and the other new classes as soon as possible.</p>
<h2>Upgrading From Previous Versions of SkyBlueCanvas</h2>
<p>The upgrade process for SkyBlueCanvas has not changed. You can read about the upgrade process on the <a href="http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/upgrading-skybluecanvas/">Upgrade Instructions page</a> on this blog.</p>
<p>The changes in v1.1 will not affect your existing data at all. We did not make any changes to the data storage. There were changes to the logic in a few of the plugins and modules but these changes should not impact the display of the plugin or module output.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/skybluecanvas-lightweight-cms-v11-beta/feed/</wfw:commentRss>
		</item>
		<item>
		<title>August 1, 2008 Update</title>
		<link>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/august-1-2008-update/</link>
		<comments>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/august-1-2008-update/#comments</comments>
		<pubDate>Fri, 01 Aug 2008 21:21:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[SkyBlueCanvas CMS]]></category>

		<guid isPermaLink="false">http://blog.skybluecanvas.com/?p=42</guid>
		<description><![CDATA[August 1, 2008 marks an exciting milestone for SkyBlueCanvas. As of today, SkyBlueCanvas has surpassed 5,000 downloads. This is an exciting milestone especially since SkyBlueCanvas was only officially released on March 28 of this year. The software is downloaded an average of every 36 minutes. The timing of reaching this milestone is a great time to share some more exciting news.]]></description>
			<content:encoded><![CDATA[<p>August 1, 2008 marks an exciting milestone for SkyBlueCanvas. As of today, SkyBlueCanvas has surpassed 5,000 downloads. This is an exciting milestone especially since SkyBlueCanvas was only officially released on March 28 of this year. The software is downloaded an average of every 36 minutes. The timing of reaching this milestone is a great time to share some more exciting news.</p>
<p>I am happy to introduce you all to Todd Crowe and Steve Fister. Todd and Steve are the newest members of the SkyBlueCanvas development team. Each has over 15 years of experience in software development and will be applying the fruits of that experience to SkyBlueCanvas. You can read more about Todd and Steve on the <a href="http://blog.skybluecanvas.com/topics/skybluecanvas-lightweight-cms/">blog</a>.</p>
<p>Next, we will be releasing version 1.0.4 of SkyBlueCanvas within the next few days. This is a minor version release that will fix a few bugs in the WYMeditor XHTML Editor and to some of the managers. This version will also include a few new minor features.</p>
<p>The development team is also working on SkyBlueCanvas v1.1, which is tentatively scheduled to be released November 1, 2008. Version 1.1 will be a fairly significant upgrade to SBC with improved usability, several new features and an improved development API. Version 1.1 will also include WYMeditor v0.5 (the current release).</p>
<p>Thank you and keep a look out for these two new releases.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/august-1-2008-update/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Steve Fister Joins the SBC Dev Team</title>
		<link>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/steve-fister-joins-sbc-dev-team/</link>
		<comments>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/steve-fister-joins-sbc-dev-team/#comments</comments>
		<pubDate>Thu, 31 Jul 2008 17:54:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[SkyBlueCanvas CMS]]></category>

		<guid isPermaLink="false">http://blog.skybluecanvas.com/?p=41</guid>
		<description><![CDATA[SkyBlueCanvas is happy to announce that a new developer has joined the development team to help with Developer Documentation. Steve Fister, an e-Learning Architect and Web Developer working in New England for TIBCO Software, Inc. headquartered in Palo Alto, CA.]]></description>
			<content:encoded><![CDATA[<p>SkyBlueCanvas is happy to announce that a new developer has joined the development team to help with Developer Documentation. Steve Fister, an e-Learning Architect and Web Developer working in New England for TIBCO Software, Inc. headquartered in Palo Alto, CA.</p>
<p>Steve has been a professional internet application developer for 15 years, spending most of this time in San Francisco Bay Area. Steve&#8217;s broad experience in large scale portal development, content management systems, e-learning systems development, and technical writing will bring additional and complimentary skills to the SBC team.</p>
<p>Steve is also an avid fisherman, both salt- and freshwater and finds his Zen place on the waters of the Block Island Sound.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/steve-fister-joins-sbc-dev-team/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Todd Crowe Joins SkyBlueCanvas Dev Team</title>
		<link>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/todd-crowe-joins-skybluecanvas-dev-team/</link>
		<comments>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/todd-crowe-joins-skybluecanvas-dev-team/#comments</comments>
		<pubDate>Thu, 31 Jul 2008 15:51:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[SkyBlueCanvas CMS]]></category>

		<guid isPermaLink="false">http://blog.skybluecanvas.com/?p=40</guid>
		<description><![CDATA[SkyBlueCanvas is happy to announce that a new developer has joined the development team. Todd Crowe, formerly a developer for NetScape and AOL will be joining the team to help with the PHP architecture and programming.]]></description>
			<content:encoded><![CDATA[<p>SkyBlueCanvas is happy to announce that a new developer has joined the development team. Todd Crowe, formerly a developer for NetScape and AOL will be joining the team to help with the PHP architecture and programming.</p>
<p>Todd is a website developer living on the Oregon Coast. He has been writing software professionally for over 15 years.  Todd&#8217;s diverse background in developing operating systems, desktop applications, and large scale web software brings a broad range of skills and experience to the project.</p>
<p>I am excited to have Todd join the team and he and I both look forward to working to make SkyBlueCanvas a great lightweight content management solution.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/todd-crowe-joins-skybluecanvas-dev-team/feed/</wfw:commentRss>
		</item>
		<item>
		<title>SkyBlueCanvas v1.1 Alpha Release</title>
		<link>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/skybluecanvas-v11-alpha-release-2/</link>
		<comments>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/skybluecanvas-v11-alpha-release-2/#comments</comments>
		<pubDate>Mon, 28 Jul 2008 14:47:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[SkyBlueCanvas CMS]]></category>

		<guid isPermaLink="false">http://blog.skybluecanvas.com/?p=39</guid>
		<description><![CDATA[As a way of saying thank you to those of you who have been following the blog, I have decided to release the alpha version of SkyBlueCanvas v1.1. The new version has some significant improvements to the code and also includes the latest version of WYMeditor (v0.5 Alpha).]]></description>
			<content:encoded><![CDATA[<p>As a way of saying thank you to those of you who have been following the blog, I have decided to release the alpha version of SkyBlueCanvas v1.1. The new version  has some significant improvements to the code and also includes the latest version of WYMeditor (v0.5 Alpha).</p>
<p>A word of caution, however - this is an alpha version and should not be used for production web sites. There are some known issues with the SBC implementation of WYMeditor v0.5 and IE 6 (selection is lost when the SkyBox overlay is activated). The software also has not been tested either so there are most likely some bugs. Additionally, there is no documentation of the new features except for the change log and that is not completely up-to-date.</p>
<p>All that not withstanding, if your php skills are a bit more advanced and you would like to bang on the new version, please feel free to so. I welcome any and all criticism and feedback. I would like to take SBC a step further towards maturity and your help would be a great service to me.</p>
<p>You can download the package from <a title="SkyBlueCanvas v1.1 Alpha Download" href="http://www.skybluecanvas.com/download-alpha">www.skybluecanvas.com/download-alpha</a></p>
<p>The login credentials for the admin control panel are demo/demo.</p>
<p>Cheers,<br />
Scott</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/skybluecanvas-v11-alpha-release-2/feed/</wfw:commentRss>
		</item>
		<item>
		<title>SkyBlueCanvas SiteVars Plugin</title>
		<link>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/skybluecanvas-sitevars-plugin/</link>
		<comments>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/skybluecanvas-sitevars-plugin/#comments</comments>
		<pubDate>Mon, 07 Jul 2008 19:45:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[SkyBlueCanvas CMS]]></category>

		<category><![CDATA[SkyBlueCanvas Docs]]></category>

		<guid isPermaLink="false">http://blog.skybluecanvas.com/?p=37</guid>
		<description><![CDATA[I have created a new plugin for SkyBlueCanvas that adds the ability to dynamically insert the values of properties of the site and page objects within the content of articles or from within the HTML of the site templates. The name of the new plugin is SiteVars and I think this is one of the coolest features to date.]]></description>
			<content:encoded><![CDATA[<p>I have created a new plugin for SkyBlueCanvas that adds the ability to dynamically insert the values of properties of the site and page objects within the content of articles or from within the HTML of the site templates. The name of the new plugin is SiteVars and I think this is one of the coolest features to date.</p>
<h2>Updated</h2>
<p>Download <a href="http://skybluecanvas.googlecode.com/files/plugin.sitevars.v2.zip">SkyBlueCanvas SiteVars Plugin</a></a></p>
<p>The SiteVars plugin adds a lot of flexibility and power to a SkyBlueCanvas site without requiring any knowledge of PHP or HTML. In fact, you do not even need a lot of knowledge about how the insides of SkyBlueCanvas work to use this plugin.</p>
<p>The plugin uses a simple ASCII-based syntax to insert values from properties that you set in the admin control panel. One of the biggest benefits of this approach is that if the values change, you do not need to update references to these values in your template or content.</p>
<p>There are three basic objects or domains that can be referenced by the plugin&#8217;s grammar. These are: site, page and page.link. The syntax is very simple and will always be written like this:</p>
<pre class="html" lang="html">
[[ object . property ]]
</pre>
<p>Notice the double square brackets enclosing the variable on the left and right sides. When you create these tokens, omit the spaces shown above.</p>
<h2>Site Variables</h2>
<table cellpadding="0" cellspacing="0" class="syntax-table">
<tr>
<th>Variable</th>
<th>Description</th>
</tr>
<p><!-- site.properties --></p>
<tr>
<td>site.name</td>
<td>Insert the name of the site as set in Admin - Settings - Default Info</td>
</tr>
<tr>
<td>site.url</td>
<td>Insert the URL of the site as set in Admin - Settings - Default Info</td>
</tr>
<tr>
<td>site.map</td>
<td>Dynamically insert a Site Map based on the site&#8217;s Page structure as set in Admin - Pages</td>
</tr>
<tr>
<td>site.contact_name</td>
<td>Insert the name of the default contact as set in Admin - Settings - Default Info</td>
</tr>
<tr>
<td>site.contact_title</td>
<td>Insert the title of the default contact as set in Admin - Settings - Default Info</td>
</tr>
<tr>
<td>site.contact_address</td>
<td>Insert the street address of the default contact as set in Admin - Settings - Default Info</td>
</tr>
<tr>
<td>site.contact_city</td>
<td>Insert the city of the default contact as set in Admin - Settings - Default Info</td>
</tr>
<tr>
<td>site.contact_state</td>
<td>Insert the state of the default contact as set in Admin - Settings - Default Info</td>
</tr>
<tr>
<td>site.contact_zip</td>
<td>Insert the postal code of the default contact as set in Admin - Settings - Default Info</td>
</tr>
<tr>
<td>site.contact_email</td>
<td>Insert the email address of the default contact as set in Admin - Settings - Default Info</td>
</tr>
<tr>
<td>site.contact_phone</td>
<td>Insert the phone number of the default contact as set in Admin - Settings - Default Info</td>
</tr>
<tr>
<td>site.contact_fax</td>
<td>Insert the fax number of the default contact as set in Admin - Settings - Default Info</td>
</tr>
</table>
<h3>Example Usage:</h3>
<pre class="html" lang="html">
Welcome to [[site&nbsp;.&nbsp;name]]
</pre>
<p><!-- page.properties --></p>
<h2>Page Variables</h2>
<table cellpadding="0" cellspacing="0" class="syntax-table">
<tr>
<th>Variable</th>
<th>Description</th>
</tr>
<tr>
<td>page.id</td>
<td>The ID of the current page</td>
</tr>
<tr>
<td>page.title</td>
<td>The Title of the current page</td>
</tr>
<tr>
<td>page.url</td>
<td>The URL of the current page (automatically uses SEF URLs if enabled for the site)</td>
</tr>
<tr>
<td>page.modified(date_format)</td>
<td>Insert the Modified date of the current page. The <em>date_format</em> parameter can be any PHP date format string. Example: &#8220;F d, Y h:i A&#8221;</td>
</tr>
<tr>
<td>page.parent.id</td>
<td>The ID of the parent page of the current page (if the current page is a sub-page)</td>
</tr>
<tr>
<td>page.parent.title</td>
<td>The Title of the parent page of the current page (if the current page is a sub-page)</td>
</tr>
</table>
<h3>Example Usage:</h3>
<pre class="html" lang="html">
Bread Crumbs: &lt;a href="index.php?pid=[[page . parent . id]]&#8221;&gt;
    [[page . parent . title]]&lt;/a&gt; / [[page . title ]]
</pre>
<p><!-- page.link.properties --></p>
<h2>Page Link Variables</h2>
<p>The <em>wrap_tag</em> parameter in each variable below can be any HTML element.</p>
<table cellpadding="0" cellspacing="0" class="syntax-table">
<tr>
<th>Variable</th>
<th>Description</th>
</tr>
<tr>
<td>page.link(*, wrap_tag)</td>
<td>Create links for all pages in the site.</td>
</tr>
<tr>
<td>page.link(1, 2, 3, wrap_tag)</td>
<td>Create links for any list of individual pages referenced by their ID.</td>
</tr>
<tr>
<td>page.link(parent, wrap_tag)</td>
<td>Create a link to the parent page of the current page.</td>
</tr>
<tr>
<td>page.link(children, wrap_tag)</td>
<td>Create links to all of the children of the current page.</td>
</tr>
<tr>
<td>page.link(first, wrap_tag)</td>
<td>Create a link to the first page as determined by the page order set in Admin - Pages.</td>
</tr>
<tr>
<td>page.link(last, wrap_tag)</td>
<td>Create a link to the last page as determined by the page order set in Admin - Pages.</td>
</tr>
<tr>
<td>page.link(next, wrap_tag)</td>
<td>Create a link to the next page as determined by the page order set in Admin - Pages.</td>
</tr>
<tr>
<td>page.link(previous, wrap_tag)</td>
<td>Create a link to the previous page as determined by the page order set in Admin - Pages.</td>
</tr>
<tr>
<td>page.redirect(url)</td>
<td>Redirects the page to another URL.</td>
</tr>
</table>
<h3>Example Usage:</h3>
<pre class="html" lang="html">
Pagination: [[page . link(first)]] -
    [[page . link(previous)]] -
    [[page . link(next)]] -
    [[page . link(last)]]
</pre>
<h3>Example Usage 2:</h3>
<pre class="html" lang="html">
&lt;h2&gt;Related Articles&lt;/h2&gt;
&lt;ul&gt;
    [[page . link(children, li)]]
&lt;/ul&gt;
</pre>
<h3>Example Usage 3:</h3>
<pre class="html" lang="html">
    [[page . redirect(http://www.skybluecanvas.com)]]
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/skybluecanvas-sitevars-plugin/feed/</wfw:commentRss>
		</item>
		<item>
		<title>A Pluggable jQuery Extension Architecture</title>
		<link>http://blog.skybluecanvas.com/jquery-javascript-library/pluggable-jquery-extension-architecture-2/</link>
		<comments>http://blog.skybluecanvas.com/jquery-javascript-library/pluggable-jquery-extension-architecture-2/#comments</comments>
		<pubDate>Wed, 25 Jun 2008 04:14:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://blog.skybluecanvas.com/?p=35</guid>
		<description><![CDATA[For the past couple of months I have been experimenting with a new architecture for the WYMeditor semantic XHTML editor. This article demonstrates an architecture to make WYMeditor and any other jQuery extension pluggable and very flexible.]]></description>
			<content:encoded><![CDATA[<p>For the past couple of months I have been experimenting with a new architecture for the WYMeditor semantic XHTML editor. When I was implementing WYMeditor v0.5 in SkyBlueCanvas, I found that the existing architecture was a bit limiting and would not allow me to easily add custom buttons and fuctionality (although it is possible to do so). I found myself wanting to add plugins to the base software without needing to alter the existing code in any way.</p>
<p>I decided the ideal architecture is one in which WYMeditor has no knowledge of plugins but rather provided the necessary hooks to attach and trigger plugins on specific state changes or custom events. It occurred to me that what I wanted was an architecture that implements the Observer Pattern so that I could subscribe to various state changes.</p>
<p>I also decided that I wanted to be smart about the design and make it so that other developers could also add additional functionality and not have to worry about collisions between the names of functions and properties used in their plugins and those of my or other plugins. So this requirement called for the ability to define custom name spaces.</p>
<p>This article proposes a new architecture that not only satisfies the requirements described above, but also makes even the core features of WYMeditor into plugins using the same API. The proposed architecture essentially converts WYMeditor into a robust editor plugin engine.</p>
<p><!-- google_ad_section_start -->There are several benefits to the architecture which this document describes. First, it makes the base code more maintainable. When bugfixes and upgrades to isolated parts of the code are needed, only part of the code needs to be replaced. Second, it gives third-party developers much more power and flexibility to be able to control the execution of their code. Finally, it allows developers to add much more robust features like database interaction, file uploading and even image editing capabilities. I believe the possibilities become almost endless through the new architecture and API.<!-- google_ad_section_end --></p>
<p><!-- google_ad_section_start -->It occurred to me after several weeks of working with various designs for the new architecture that this design could be implemented with any jQuery extension, thus turning the extension into a pluggable application built on top of the jQuery JavaScript framework.<!-- google_ad_section_end --></p>
<p>This article assumes that you have some familiarity with the Function.prototype concept and the $.extend() function. I will be using a generic application called MyApp to demonstrate the concept.</p>
<p>First, let&#8217;s begin by defining a new Object for our application.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>MyApp<span style="color: #009900;">&#41;</span> <span style="color: #003366; font-weight: bold;">var</span> MyApp <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p><!-- google_ad_section_start -->In JavaScript, the window object is the global scope, so we make the creation of the object conditional so that we do no end up with more than one instance of MyApp within the global space.<!-- google_ad_section_end --></p>
<p>Next, I am going to set up the base MyApp object with a few default properties and a base method I will call main.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript">$.<span style="color: #006600;">extend</span><span style="color: #009900;">&#40;</span>MyApp<span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
    target<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span>
    events<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
        init   <span style="color: #339933;">:</span> <span style="color: #3366CC;">'onInit'</span><span style="color: #339933;">,</span>
        run    <span style="color: #339933;">:</span> <span style="color: #3366CC;">'onRun'</span><span style="color: #339933;">,</span>
        finish <span style="color: #339933;">:</span> <span style="color: #3366CC;">'onFinish'</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    main<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>target<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> events <span style="color: #339933;">=</span> MyApp.<span style="color: #006600;">events</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> _self  <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">init</span><span style="color: #009900;">&#40;</span>target<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        $<span style="color: #009900;">&#40;</span>MyApp<span style="color: #009900;">&#41;</span>.<span style="color: #006600;">trigger</span><span style="color: #009900;">&#40;</span>events.<span style="color: #006600;">init</span><span style="color: #339933;">,</span> _self<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">run</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        $<span style="color: #009900;">&#40;</span>MyApp<span style="color: #009900;">&#41;</span>.<span style="color: #006600;">trigger</span><span style="color: #009900;">&#40;</span>events.<span style="color: #006600;">run</span><span style="color: #339933;">,</span> _self<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">finish</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        $<span style="color: #009900;">&#40;</span>MyApp<span style="color: #009900;">&#41;</span>.<span style="color: #006600;">trigger</span><span style="color: #009900;">&#40;</span>events.<span style="color: #006600;">finish</span><span style="color: #339933;">,</span> _self<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>In the code above, you will notice that I have three parts which are explained in turn below.</p>
<p>1. The target property</p>
<p>The target will be the DOM element or elements on which my application will operate. If you are familiar with jQuery you know that you specify the target of any action with selectors like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006600;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>...<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>In the above example, the target property of MyApp would refer to the &#8220;a&#8221; element passed to jQuery.</p>
<p>2. The events property</p>
<p>The events in MyApp will be the different states or state changes on which my plugins will be triggered. The number and names of events is up to you. For this demonstration I have kept it simple with init, run and finish events.</p>
<p>3. The main method</p>
<p>The main method is the base function of MyApp. It is possible to create a jQuery extension by creating MyApp as new Function rather than an Object, but using the Object allows me to namespace not only MyApp, but also to use different namespaces for each of MyPlugins within the MyApp namespace.</p>
<p>You will notice in the main function that I am setting a local variable named _self to an array containing a reference to the function itself. This is done to cut down on memory usage by avoiding calling the Array constructor each time the trigger method is called. The gains from this may be slight but since I like efficiency, I think every little bit of gain in execution time is positive gain.</p>
<p>At this point, MyApp does not do anything. I still need to define the three methods that are triggered on each of the state changes. For this demonstration my methods will be very simple: I will have them just append a message to the target of their actions.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript">MyApp.<span style="color: #006600;">main</span>.<span style="color: #006600;">prototype</span>.<span style="color: #006600;">init</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>target<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">target</span> <span style="color: #339933;">=</span> target<span style="color: #339933;">;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">target</span><span style="color: #009900;">&#41;</span>.<span style="color: #006600;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'MyApp.init Called'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
MyApp.<span style="color: #006600;">main</span>.<span style="color: #006600;">prototype</span>.<span style="color: #006600;">run</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>target<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    $<span style="color: #009900;">&#40;</span>target<span style="color: #009900;">&#41;</span>.<span style="color: #006600;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'MyApp.run Called'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
MyApp.<span style="color: #006600;">main</span>.<span style="color: #006600;">prototype</span>.<span style="color: #006600;">finish</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>target<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    $<span style="color: #009900;">&#40;</span>target<span style="color: #009900;">&#41;</span>.<span style="color: #006600;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'MyApp.finish Called'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p><!-- google_ad_section_start -->I have used JavaScripts prototype object to add functions within the scope of the main function. This is a cleaner way of doing this:<!-- google_ad_section_end --></p>

<div class="wp_syntax"><div class="code"><pre class="javascript">main<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> init <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// code goes here ...</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> run <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// code goes here ...</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> finish <span style="color: #339933;">=</span> funciton<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// code goes here ...</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>My code is much cleaner, easier to read and so easier to maintain.</p>
<p>The last step is to add my extension to jQuery:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #009966; font-style: italic;">/* Add the extension to jQuery */</span>
&nbsp;
$.<span style="color: #006600;">fn</span>.<span style="color: #006600;">myapp</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">new</span> MyApp.<span style="color: #006600;">main</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The code above adds a method called &#8216;myapp&#8217; to the jQuery.fn array so I can call</p>

<div class="wp_syntax"><div class="code"><pre class="javascript">$<span style="color: #009900;">&#40;</span>element<span style="color: #009900;">&#41;</span>.<span style="color: #006600;">myapp</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><!-- google_ad_section_start -->and MyApp will be passed the target element or elements found by jQuery&#8217;s search of the DOM. jQuery&#8217;s this.each method is used so that myapp will be executed on every element found matching my selector. It is important to return the result of the execution to jQuery to insure that jQuery&#8217;s method chaining functions correctly.</p>
<p>Now I have a fully functional, albeit a very simple, jQuery extension. Since the purpose of this article is to demonstrate a pluggable jQuery extension, I now need to create my plugin, which I will aptly name MyPlugin.<!-- google_ad_section_end --></p>
<p>MyPlugin will be created in similar fashion to MyApp except that I will use a new Function rather than an Object.</p>
<p>First I will create the MyPlugin function which will receive a reference to MyApp as its only argument. By passing a reference to MyApp to the plugin, I make all the properties and methods of MyApp available to MyPlugin. The MyPlugin constructor will extend MyApp with MyPlugin.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #009966; font-style: italic;">/* The Plugin code */</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> MyPlugin <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>app<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    $.<span style="color: #006600;">extend</span><span style="color: #009900;">&#40;</span>app<span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
        MyPlugin<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">init</span><span style="color: #009900;">&#40;</span>app<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>I now have a MyPlugin namespace within the MyApp namespace. This may seem a bit circular, but it is very flexible and useful. First, in this way I avoid any possible collisions between the methods with MyPlugin and MyApp as well as within other plugins. By extending MyApp in this way, I also make MyPlugin available to other plugins to MyApp. I could feasibly do something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript">MyApp.<span style="color: #006600;">MyPlugin2</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>app<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    app.<span style="color: #006600;">MyPlugin1</span>.<span style="color: #006600;">method</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>MyPlugin is not yet complete, however, so I will add a simple function to it again using the prototype Object.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript">MyPlugin.<span style="color: #006600;">prototype</span>.<span style="color: #006600;">init</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>app<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    $<span style="color: #009900;">&#40;</span>app.<span style="color: #006600;">target</span><span style="color: #009900;">&#41;</span>.<span style="color: #006600;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'MyPlugin fired'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>And lastly, I need to tell MyApp when it should run MyPlugin. I will do this using jQuery&#8217;s bind function. The bind/trigger combination in jQuery is, in my opinion, one of its most powerful features and the one that makes the architecture described in this article possible.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript">$<span style="color: #009900;">&#40;</span>MyApp<span style="color: #009900;">&#41;</span>.<span style="color: #006600;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'onRun'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #339933;">,</span> app<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">new</span> MyPlugin<span style="color: #009900;">&#40;</span>app<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The jQuery.bind() function takes the following form:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript">$<span style="color: #009900;">&#40;</span>scope<span style="color: #009900;">&#41;</span>.<span style="color: #006600;">bind</span><span style="color: #009900;">&#40;</span>event<span style="color: #339933;">,</span> callback<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The scope is the space in which the event will occur and the callback is the code that will be executed when the event occurs. It is important that the specified event actually exists or occurs within the specified scope. If you attempt to call the callback on an event that does not exist in the specified scope, nothing will happen or, you may get unexpected results if an event by the same name exists but in the wrong scope.</p>
<p>Now if we refer back to the base code for MyApp, you will notice the events I set up:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript">$.<span style="color: #006600;">extend</span><span style="color: #009900;">&#40;</span>MyApp<span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
    target<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span>
    events<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
        init   <span style="color: #339933;">:</span> <span style="color: #3366CC;">'onInit'</span><span style="color: #339933;">,</span>
        run    <span style="color: #339933;">:</span> <span style="color: #3366CC;">'onRun'</span><span style="color: #339933;">,</span>
        finish <span style="color: #339933;">:</span> <span style="color: #3366CC;">'onFinish'</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    main<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>target<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> events <span style="color: #339933;">=</span> MyApp.<span style="color: #006600;">events</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> _self  <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">init</span><span style="color: #009900;">&#40;</span>target<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        $<span style="color: #009900;">&#40;</span>MyApp<span style="color: #009900;">&#41;</span>.<span style="color: #006600;">trigger</span><span style="color: #009900;">&#40;</span>events.<span style="color: #006600;">init</span><span style="color: #339933;">,</span> _self<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">run</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        $<span style="color: #009900;">&#40;</span>MyApp<span style="color: #009900;">&#41;</span>.<span style="color: #006600;">trigger</span><span style="color: #009900;">&#40;</span>events.<span style="color: #006600;">run</span><span style="color: #339933;">,</span> _self<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">finish</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        $<span style="color: #009900;">&#40;</span>MyApp<span style="color: #009900;">&#41;</span>.<span style="color: #006600;">trigger</span><span style="color: #009900;">&#40;</span>events.<span style="color: #006600;">finish</span><span style="color: #339933;">,</span> _self<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>You will also notice in the main function this line:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript">$<span style="color: #009900;">&#40;</span>MyApp<span style="color: #009900;">&#41;</span>.<span style="color: #006600;">trigger</span><span style="color: #009900;">&#40;</span>events.<span style="color: #006600;">run</span><span style="color: #339933;">,</span> _self<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><!-- google_ad_section_start -->jQuery will then call MyPlugin passing the window&#8217;s event object and the reference to MyApp.main contained in the _self variable. As stated earlier, passing a reference to MyApp.main allows my plugin to have access to the properties and methods of main, including its target.<!-- google_ad_section_end --></p>
<p>Our demonstration is now complete. There is not space here to enumerate all of the benefits of this architecture but I hope that at least I have managed to demonstrate the possibilities this design creates.</p>
<p>You can download a working copy of this demonstration at <a href="http://www.skybluecanvas.com/jquery.myapp">myapp.zip</a> or see it in action at <a href="http://www.skybluecanvas.com/examples/jquery.myapp/">jquery.myapp</a>.</p>
<p>Please use the comment form below to let me know what you think and/or to ask any questions.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.skybluecanvas.com/jquery-javascript-library/pluggable-jquery-extension-architecture-2/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Skins and Tokens Explained</title>
		<link>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/skins-tokens-explained/</link>
		<comments>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/skins-tokens-explained/#comments</comments>
		<pubDate>Sun, 22 Jun 2008 22:53:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[SkyBlueCanvas CMS]]></category>

		<category><![CDATA[SkyBlueCanvas Docs]]></category>

		<guid isPermaLink="false">http://blog.skybluecanvas.com/?p=34</guid>
		<description><![CDATA[The SkyBlueCanvas template system, also referred to as the skin system, is a content token replacement technique. In this article I give a detailed explanation of how SkyBlueCanvas skins work, what each of the tokens are and how they are used.]]></description>
			<content:encoded><![CDATA[<p>The SkyBlueCanvas template system, also referred to as the skin system, uses a simple content token replacement technique. A content token is a placeholder that allows you to tell SkyBlueCanvas that a particular part of a page, usually an HTML element, will contain some type of content. That content can be an article of text, a list of links or a photo gallery.</p>
<p>SkyBlueCanvas is designed to make web site creation as simple as possible so unlike true template scripting languages like Smarty, the SkyBlueCanvas content token replacement system does not include any logic such as loops or conditionals. Stated very simply, the SkyBlueCanvas skin system uses basic string-replacement to allow you to specify which content will appear where in your HTML template.</p>
<h2>Structure of a Skin</h2>
<p>The simplest breakdown of a skin is what I refer to as the skeleton of a page. The skeleton includes elements that will appear on every web page, no matter what elements make up the body of the page. These common elements include the document type declaration, the HTML, HEAD, TITLE, META, SCRIPT, STYLE and BODY elements.</p>
<p>The code shown in Diagram 1 is the HTML skeleton that comes with SkyBlueCanvas.</p>
<h3>Diagram 1</h3>
<p>Located in /skyblue/rsrc/page.skeleton.html</p>
<p class="html">
&lt;!DOCTYPE&nbsp;html&nbsp;PUBLIC&nbsp;“-//W3C//DTD&nbsp;XHTML&nbsp;1.0&nbsp;Strict//EN&#8221;<br />
&nbsp;&nbsp;&#8221;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&#8221;&gt;<br />
&lt;html<span class="token">{doc:lang}</span>&gt;<br />
&nbsp;&nbsp;&lt;head&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;title&gt;<span class="token">{page:title}</span>&lt;/title&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;meta&nbsp;http-equiv=&#8221;Content-Type&#8221;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;content=&#8221;text/html;&nbsp;charset=iso-8859-1?<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/&gt;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span class="token">{region:meta}</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;meta&nbsp;http-equiv=&#8221;imagetoolbar&#8221;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;content=&#8221;no&#8221;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;script&nbsp;type=&#8221;text/javascript&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;base_uri&nbsp;=&nbsp;‘<span class="token">{page:base_uri}</span>‘;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/script&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span class="token">{region:links}</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span class="token">{region:styles}</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span class="token">{region:scripts}</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span class="token">{region:favicon}</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span class="token">{plugin:preloader}</span><br />
&nbsp;&nbsp;&lt;/head&gt;<br />
&nbsp;&nbsp;&lt;body<span class="token">{page:bodyid}</span><span class="token">{body:class}</span>&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;!–&nbsp;Begin&nbsp;Your&nbsp;Skin&nbsp;Code&nbsp;–&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="token">{page:body}</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;!–&nbsp;End&nbsp;Your&nbsp;Skin&nbsp;Code&nbsp;–&gt;<br />
&nbsp;&nbsp;&lt;/body&gt;<br />
&lt;/html&gt;
</p>
<p>This is the HTML that is used to render every page in a SkyBlueCanvas site. When a page is requested by a site visitor, the Skin Engine uses this HTML as the framework - or skeleton - for the page. You will notice that there are several tokens in the format <span class="token">{token-name}</span> where you might usually find literal values or HTML elements such as SCRIPT and META tags. These tokens represent variable elements and act as placeholders until SkyBlueCanvas determines the specific values of the items with which the tokens will be replaced.</p>
<h2>About the Tokens</h2>
<p>There are two types of tokens used in SkyBluecanvas: user-owned and system-owned tokens. By owned we mean that either the user - the person building/managing the web site - or the system has control over where the tokens in question appear and with what they will be replaced. I refer to the process of mapping content to tokens as &#8216;targeting&#8217; the content to a token.</p>
<p>It is very easy to distinguish between user-owned and system-owned tokens. Any token that appears in page.skeleton.html is system-owned. This means that the system will determine with what each of these tokens will be replaced. The complete list of system-owned tokens with their corresponding PHP constants are listed below.</p>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<th>HTML Token</th>
<th>PHP Constant</th>
</tr>
<tr>
<td class="token">{build}</td>
<td class="constant">TOKEN_BUILD</td>
</tr>
<tr>
<td class="token">{page:title}</td>
<td class="constant">TOKEN_PAGE_TITLE</td>
</tr>
<tr>
<td class="token">{inc:scripts}</td>
<td class="constant">TOKEN_SCRIPTS</td>
</tr>
<tr>
<td class="token">{analytics}</td>
<td class="constant">TOKEN_ANALYTICS</td>
</tr>
<tr>
<td class="token">{body:class}</td>
<td class="constant">TOKEN_BODY_CLASS</td>
</tr>
<tr>
<td class="token">{region:links}</td>
<td>REGION_LINKS</td>
</tr>
<tr>
<td class="token">{region:meta}</td>
<td>REGION_META</td>
</tr>
<tr>
<td class="token">{region:styles}</td>
<td>REGION_STYLES</td>
</tr>
<tr>
<td class="token">{region:scripts}</td>
<td>REGION_SCRIPTS</td>
</tr>
</tbody>
</table>
<p>The person building the site skin would probably not have any reason to ever use these tokens.* Most of them are non-displaying items for things such as meta, script and stylesheet tags.</p>
<p>User-owned tokens are any tokens that the person building the skin places in some HTML element as a placeholder for content. The complete list of user-owned tokens and their corresponding constants are listed below.</p>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<th>HTML Token</th>
<th>PHP Constant</th>
</tr>
<tr>
<td class="token">{region:main}</td>
<td class="constant">REGION_MAIN</td>
</tr>
<tr>
<td class="token">{region:top}</td>
<td class="constant">REGION_TOP</td>
</tr>
<tr>
<td class="token">{region:left}</td>
<td class="constant">REGION_LEFT</td>
</tr>
<tr>
<td class="token">{region:right}</td>
<td class="constant">REGION_RIGHT</td>
</tr>
<tr>
<td class="token">{region:footer}</td>
<td class="constant">REGION_FOOTER</td>
</tr>
<tr>
<td class="token">{region:pathway}</td>
<td class="constant">REGION_PATHWAY</td>
</tr>
</tbody>
</table>
<p>SkyBlueCanvas does not have any knowledge of the structure of the HTML of a page. It only looks for the content replacement tokens and replaces them with the content you specify in the SkyBlueCanvas administrator control panel. An in-depth explanation of how this &#8216;content targeting&#8217; is done can be found in the article on Content Publishing.</p>
<h2>A Simple Skin Example</h2>
<p>Perhaps a better understanding of the content token replacement can be gained by examining a simple skin example and a diagram of the regions represented by each token. Diagram 2 shows the HTML for a very simple skin. Diagram 3 uses the token names to demonstrate where content targeted to each token will appear.</p>
<h3>Diagram 2</h3>
<p class="html">&lt;div id=&#8221;wrapper&#8221;&gt;<br />
&lt;div id=&#8221;header&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&lt;h1&gt;<span class="token">{page:title}</span>&lt;/h1&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span class="token">{region:header}</span><br />
&lt;/div&gt;<br />
&lt;div id=&#8221;top&#8221;&gt;<span class="token">{region:top}</span>&lt;/div&gt;<br />
&lt;div id=&#8221;breadcrumbs&#8221;&gt;<span class="token">{region:pathway}</span>&lt;/div&gt;<br />
&lt;div id=&#8221;left&#8221;&gt;<span class="token">{region:left}</span>&lt;/div&gt;<br />
&lt;div id=&#8221;main&#8221;&gt;<span class="token">{region:main}</span>&lt;/div&gt;<br />
&lt;div id=&#8221;right&#8221;&gt;<span class="token">{region:right}</span>&lt;/div&gt;<br />
&lt;div id=&#8221;footer&#8221;&gt;<span class="token">{region:footer}</span>&lt;/div&gt;<br />
&lt;/div&gt;</p>
<h3>Diagram 3</h3>
<p class="diagram"><img src="/images/diagram.regions.gif" alt="Diagram of SkyBlueCanvas template regions" width="464" height="340" /></p>
<p>Look closely at each token in the HTML example then find it in the image in Diagram 3. When you include one of these tokens in your Skin HTML then log into the administrator control panel and go to Collections Publishing [Diagram 4], these tokens are the options that appear in the &#8216;Region&#8217; selector next to each page.</p>
<h3>Diagram 4</h3>
<p class="diagram"><img src="/images/diagram.publishing.gif" alt="Diagram of SkyBlueCanvas publishing regions" width="464" height="180" /></p>
<h2>Multiple Page Layouts</h2>
<p>SkyBlueCanvas makes it possible to use different layouts on different pages. You can make use of this feature by creating additional HTML template files in /skyblue/data/skins/yourskin/.</p>
<div class="note">
<p>There are two strict rules regarding layout files:</p>
<ol>
<li>There must be a file named skin.default.html present in your skin directory</li>
<li>Additional layouts must follow the skin.[name].html format</li>
</ol>
</div>
<h3>Diagram 5</h3>
<p class="diagram"><img src="/images/diagram.pages.gif" alt="Diagram of SkyBlueCanvas page layout selection" width="464" height="180" /></p>
<p>If you refer to Diagram 5, you will see the Page Manager interface. When you include more than one HTML layout file in your skin directory, these skins are loaded as the choices in the selector highlighted in blue in Diagram 5.</p>
<p>This next bit will be a little tricky so follow me closely. Refer again to Diagram 4. In this diagram you will see the Collections Publishing Manager interface. When you open the collections publisher, the publisher creates a composite list of all tokens in all of your template HTML files. This composite list are the choices in the Region selector highlighted in blue in Diagram 4.</p>
<p>When you select a region for a particular collection to appear in, SkyBlueCanvas saves this selection as part of the collection publishing objects parameters. Now we have come full circle back to the Skin Engine and how a page is rendered in SkyBlueCanvas. When a specific page is requested by a site visitor, the Skin Engine loads the skeleton, the page data object and all collections associated with that page into memory.</p>
<p>The Skin Engine then parses the template file specified for the page requested by your site visitor. The parsing of the template is a fancy way of saying it looks to see which tokens appear in that template file.</p>
<p>Next, the Skin Engine loads the collection publishing data file and looks for Collections that you indicated are to appear on this page. As the Skin Engine goes through the list of collections it determines whether each collection appears on the current page and if it does, in which region it is to appear. When the page HTML is built, it replaces the token for that region with the output of whichever collection or collections you specified appear in that region. If a token does not have any content specified to replace it, it is replaced with an empty string.</p>
<h2>A Word About Collections Output</h2>
<p>A full explanation of Collections and their output is beyond the scope of this article. However, a brief word about this subject is warranted.</p>
<p>The output of a Collection is defined in the module file for each collection. These module files can be found in /skyblue/data/modules/. For instance, the HTML output of the Links Collection is created by the /skyblue/data/modules/mod.links.php file.</p>
<p>For information about additional features related to building SkyBlueCanvas templates, go to <a href="http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/skybluecanvas-sitevars-plugin/">http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/skybluecanvas-sitevars-plugin/</a>.</p>
<p>* More advanced programmers can manipulate the system-owned content tokens, which will be the subject of a future article.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/skins-tokens-explained/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
