<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SkyBlueCanvas&#187; Plugins Archives  &#8211; SkyBlueCanvas</title>
	<atom:link href="http://blog.skybluecanvas.com/topics/skybluecanvas-lightweight-cms/plugins/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.skybluecanvas.com</link>
	<description>The Lightweight Blog</description>
	<lastBuildDate>Tue, 20 Jul 2010 15:47:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Fragmentor Plugin for SkyBlueCanvas</title>
		<link>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/plugins/fragmentor-plugin-skybluecanvas/</link>
		<comments>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/plugins/fragmentor-plugin-skybluecanvas/#comments</comments>
		<pubDate>Sun, 08 Mar 2009 01:19:46 +0000</pubDate>
		<dc:creator>scott</dc:creator>
				<category><![CDATA[Extensions]]></category>
		<category><![CDATA[Fragments]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[fragment]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[s]]></category>
		<category><![CDATA[skin]]></category>
		<category><![CDATA[skins]]></category>
		<category><![CDATA[templates]]></category>
		<category><![CDATA[variable]]></category>
		<category><![CDATA[views]]></category>
<category>extensions</category><category>fragments</category><category>plugins</category><category>skins</category><category>templates</category><category>themes</category>
		<guid isPermaLink="false">http://blog.skybluecanvas.com/?p=59</guid>
		<description><![CDATA[Fragmentor is a plugin to be used instead of or alongside the default Fragment Plugin in SkyBlueCanvas. Fragmentor provides template and fragment developers an alternative and much more flexible syntax for loading dynamic content views (fragments) into SkyBlueCanvas web pages. Since the plugin uses a different syntax from the default fragment plugin, it will not conflict with it. With Fragmentor, you can pass an arbitrary number of key=&#60; value pairs of data from your article text or template file.]]></description>
			<content:encoded><![CDATA[<p>For a really cool Fragmentor usage example, check out my blog post on the <a href="http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/editable-sidebar-content-hack/" title="Editable Sidebar Hack">Editable Sidebar Content Hack</a></p>
<h2>System Requirements</h2>
<ul>
<li>SkyBlueCanvas v1.1</li>
<li>PHP 5 (Not tested with PHP 4)</li>
<li>Apache Web Server</li>
</ul>
<div class="msg-info">
<h2>Important</h2>
<p>Unlike most SkyBlueCanvas Plugins, the Fragmentor Plugin <strong><em>must</em></strong> be installed manually via FTP. If you install this Plugin through the admin console, it will not function properly.</p>
</div>
<h2>Installation Instructions</h2>
<ol>
<li>Connect to your SkyBlueCanvas web site using the FTP Client of your choice.</li>
<li>Locate the Fragmentor Plugin file in <span style="text-decoration: underline;">source/plugin_fragmentor/plugin.fragmentor.php</span> in this download.</li>
<li>Upload the Fragmentor Plugin file to <span style="text-decoration: underline;">/skyblue_root/data/plugins/</span>.</li>
</ol>
<h2>Usage</h2>
<p>The Fragmentor Plugin allows you to pass a standard query string, similar to a URL query string, to your custom SkyBlueCanvas fragments. A query string is simply a string of key=&gt;value pairs in the format:</p>
<pre class="html">key1=value1&amp;key2=value2</pre>
<h2>Reserved Keywords</h2>
<p>The Fragmentor Plugin has 2 reserved keywords:</p>
<ol>
<li> name<em> &#8211; name</em> tells Fragmentor which Fragment to laod.</li>
<li> view<em> &#8211; view</em> tells Fragmentor which Fragment View to load.</li>
</ol>
<h2>Syntax</h2>
<p>You can use one of or a mix of two call syntaxes to call the Fragmentor Plugin:</p>
<h3>HTML Comment Syntax:</h3>
<pre class="html">&lt;!--fragment(name=fragment_name&amp;view=view_name&amp;key1=value1)--&gt;</pre>
<p>Use this syntax to add Fragmentor calls to your HTML skin templates.</p>
<h3>In-line Text Syntax:</h3>
<pre class="html">{fragment(name=fragment_name&amp;view=view_name&amp;key1=value1)}</pre>
<p>Use this syntax to add Fragmentor calls in-line in your page article text.</p>
<p>If you are familiar with SkyBlueCanvas Fragments, you know that the default Fragment Plugin attempts to load any data objects associated with the fragment automatically. The plugin determines the data to load based on the name of the fragment. For instance, if you have the Links Manager installed on your SkyBlueCanvas site, and you create a fragment named <em>links</em>, the Fragment Plugin will automatically load the <em>links</em> data objects. The data objects are passed to your fragment in a variable named $data;</p>
<p>Fragmentor maintains this automatic data loading and your data is still passed in the $data variable. Fragmentor, however, adds a new variabled named $params which is a keyed (associative) array corresponding to the key=&gt;value pairs of your query string.</p>
<p>Your query string can contain as many key=&gt;value pairs as you like and your key names can be anything you like. The only limitations are:</p>
<ol>
<li>The <em>name</em> and <em>view</em> keywords are reserved by the plugin</li>
<li>Your query string must be a well-formed query string meaning it must follow the rules or a standard URL query string (no spaces, no special characters, etc.)</li>
</ol>
<div class="msg-info">
<h2>Important</h2>
<p>Existing SkyBlueCanvas fragments are not currently configured to work with the Fragmentor Plugin. Fragmentor is intended to give you more flexibility in creating<strong><em> your custom plugins</em></strong>. We may eventually merge Fragmentor with the core SkyBlueCanvas code but at the present time it should be considered and treated like any other third-party add-on.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/plugins/fragmentor-plugin-skybluecanvas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Editable Sidebar Content Hack</title>
		<link>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/editable-sidebar-content-hack/</link>
		<comments>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/editable-sidebar-content-hack/#comments</comments>
		<pubDate>Sun, 08 Mar 2009 00:27:48 +0000</pubDate>
		<dc:creator>scott</dc:creator>
				<category><![CDATA[Extensions]]></category>
		<category><![CDATA[Fragments]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[SkyBlueCanvas CMS]]></category>
		<category><![CDATA[fragment]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[region]]></category>
<category>content</category><category>fragments</category><category>hack</category><category>hacks</category><category>plugins</category><category>region</category>
		<guid isPermaLink="false">http://blog.skybluecanvas.com/?p=58</guid>
		<description><![CDATA[A few nights ago, Steve Fister, one of the SkyblueCanvas Development Team Members posed the question again and offered a few ideas on how to pull it off. After thinking about Steve's suggetions, I realized that this is actually quite easy to do. In fact, with Steve's idea, you can add an editable text block anywhere on a web page. What's more, with a little SkyBlueCanvas Skin Magic, you can build page-specific text blocks, so if you want a different block of text to appear on different pages, you can do it with this trick.]]></description>
			<content:encoded><![CDATA[<p>
Several users of the <a href="http://forum.skybluecanvas.com/" rel="nofollow"  title="SkyBlueCanvas Forum">SkyBlueCanvas Forum</a> have asked how to add an editable text block to the sidebar of their site. I puzzled over this question and to date had informed folks that unfortunately it cannot be done.
</p>
<p>
A few nights ago, Steve Fister, one of the SkyblueCanvas Development Team Members posed the question again and offered a few ideas on how to pull it off. After thinking about Steve&#8217;s suggetions, I realized that this is actually quite easy to do. In fact, with Steve&#8217;s idea, you can add an editable text block anywhere on a web page. What&#8217;s more, with a little SkyBlueCanvas Skin Magic, you can build page-specific text blocks, so if you want a different block of text to appear on different pages, you can do it with this trick.
</p>
<p>
Out-of-the-box, this is still not possible with SkyBlueCanvas, but I have been working on a new Plugin that &#8211; unbeknownst to me when I built it &#8211; is the missing piece. The plugin is called <strong>Fragmentor</strong> and is a super-charged version of the <strong>Fragment Plugin</strong> that comes pre-installed with SkyBlueCanvas.
</p>
<h2>About Fragmentor</h2>
<p>
The existing <strong>Fragment Plugin</strong> has one design limitation: it uses pre-defined parameters whose meaning is determined by both position and name. I built the super-charged <strong>Fragmentor Plugin</strong> to correct this design mistake and to make the plugin much more flexible.
</p>
<p>
Whereas one would load a Fragment with the old <strong>Fragment Plugin</strong> with a call like this:
</p>
<pre class="html" style="font-size: 10px">
&lt;!--#plugin:fragment(fragment_name,view_name,
    match_param[id1,id2,...],
    page=[id1,id2,...]})--&gt;
</pre>
<p>
The new plugin uses a query string of key=&gt;value pairs much like a URL query string that looks like this:
</p>
<pre class="html" style="font-size: 10px">
{fragment(name=fragment_name&#038;view=view_name
    &#038;param1=value1&#038;param2=value2)}
</pre>
<div class="msg-info">
<h2>Note:</h2>
<p>
You cannot break fragment call tokens onto more than one line. They are broken onto multiple lines in this example to fit the format of this page.
</p>
</div>
<p></p>
<p>
There are 3 benefits of this approach:
</p>
<ol>
<li>The position of parameters is irrelevant</li>
<li>The query string can contain an arbitrary number of key=&gt;value pairs</li>
<li>Only your fragment needs to understand the optional parameters*</li>
</ol>
<p>
* There are two exceptions to this rule: the <em>name</em> and <em>view</em> keywords are reserved. Some might call this a shortcoming but I tend to disagree. Every language, whether for markup or code execution, uses reserved keywords so we are not introducing a new concept by reserving these two keywords.
</p>
<h2>The <strong>Editable Text Anywhere</strong> Trick.</h2>
<h3>What You Will Need</h3>
<ul>
<li>The <a href="http://www.skybluecanvas.com/exts/82" rel="nofollow"  title="Editable Region Hack Download">Editable Region Hack Package Download</a></li>
<li>Basic PHP and HTML know-how</li>
<li>A SkyBlueCanvas web site</li>
<li>FTP access to your site</li>
<li>A text editor</li>
</ul>
<p>
First, <a href="http://www.skybluecanvas.com/exts/82" rel="nofollow"  title="Download Fragmentor Plugin">download the Editable Region Hack Package</a>. Follow the installation instructions included with the download.
</p>
<p>
Next, open one of your <strong>SkyBlueCanvas Skins</strong> in a text editor. We are going to use the sidebar for this demonstration, so in the sidebar of your template, add the following code:
</p>
<pre class="html">
{fragment(name=region&#038;view=view
    &#038;content_id=
    &lt;?php $this->get_page_name(); ?&gt;-sidebar)}
</pre>
<p>
For the time being, don&#8217;t worry about what this code means. After we have created our content item to display in the region, I will explain how this code works.
</p>
<h2>Now for the Trick</h2>
<p>
We are actually going to use a SkyBlueCanvas Page for our editable content that goes in this region. However, we will only be using the <strong>Page Menu Text</strong> and the <strong>Page Article Text</strong> in the region. The reason we created an empty Skin File was so our page does not get rendered as a full HTML document.
</p>
<p>
The <strong>Page Menu Text</strong> is what SkyBlueCanvas&#8217;s <strong>Router Class</strong> uses as it&#8217;s unique identifier, so we will need to use this as well. The Fragment code I told you not to worry about earlier comes into play now. If you look at the code, you will see a PHP call embedded in the Fragment call. When this page is loaded, the template PHP will be parsed before the Plugins are fired, so when the <strong>Fragmentor Plugin</strong> sees this page, the PHP code will be replaced by the <strong>Menu Text</strong> or unique identifier of the current page. So if we are currently viewing the &#8220;Home Page&#8221;, the final key=&gt;value pair in our query string will actually read:
</p>
<pre class="html">
content_id=home-page-sidebar
</pre>
<p>
This is critical in order for the trick to work.
</p>
<h2>The Finale</h2>
<p>
With all of our pieces in place, log into the admin section of your site and navigate to <strong>Admin &gt; Pages</strong> and click the <em>Add Page</em> button. Once in the <em>Page Form View</em>, click the <em>Meta Tab</em> and name your content item <strong>Home Page Sidebar</strong>.
</p>
<p>
In the selector labeled <em>Layout</em>, select <em>Region</em>. This tells SkyBlueCanvas to use our empty Region Skin to build this page. Since the Region Skin is empty, the only output of the page will be the article cotnent.
</p>
<p>
In the selector labeled <em>Menu</em>, select <em>No Menu</em> (this is important).
</p>
<p>
Set <em>Published</em> to <em>No</em>.
</p>
<p>
You can choose to syndicate this content item.
</p>
<p>
Finally, click the <em>Article Text</em> tab and enter text and images the same as you would on a SkyBlueCanvas page. Once you have finished entering your text, click the <em>Save button</em>, then view your home page. You should see your newly created content in the side bar.
</p>
<h3>Important</h3>
<p>
We are exploiting SkyBlueCanvas&#8217;s Unique Identifier format to match content items with the including page so it is critical that your editable region content Menu Text match the Menu Text of the including page exactly, except for the additional &#8217;sidebar&#8217; bit.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/editable-sidebar-content-hack/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>MyVars String Replacement Extension</title>
		<link>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/plugins/myvars-string-replacement/</link>
		<comments>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/plugins/myvars-string-replacement/#comments</comments>
		<pubDate>Sun, 22 Feb 2009 07:28:25 +0000</pubDate>
		<dc:creator>scott</dc:creator>
				<category><![CDATA[Extensions]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[manager]]></category>
		<category><![CDATA[myvar]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[sitevars]]></category>
		<category><![CDATA[variable]]></category>
<category>extensions</category><category>managers</category><category>myvars</category><category>plugins</category><category>sitevars</category>
		<guid isPermaLink="false">http://blog.skybluecanvas.com/?p=57</guid>
		<description><![CDATA[The new MyVars extension allows you to create custom search variables/tokens that will be replaced with the values you specify
when your web page is rendered in the browser. This feature can be helpful when you want to be able to easily change
bits of informatin such as phone numbers, emails, web page URLs or image paths. You set the value once, and it is displayed
anywhere in your site you choose. If the value changes, you only make the change in one place.]]></description>
			<content:encoded><![CDATA[<p>The new MyVars extension allows you to create custom search variables/tokens that will be replaced with the values you specify when your web page is rendered in the browser. This feature can be helpful when you want to be able to easily change bits of informatin such as phone numbers, emails, web page URLs or image paths. You set the value once, and it is displayed anywhere in your site you choose. If the value changes, you only make the change in one place.</p>
<h2><a href="http://www.skybluecanvas.com/exts/78" rel="nofollow" >Download It Now</a></h2>
<h3>How It Works</h3>
<p>Let&#8217;s say you have your phone number littered throughout your web site. If your phone number ever changes, you would normally have to find and change every instance of the phone number on your site. With the MyVars extension and plugin, you can set your phone number in one place, and use a simple string replacement token to have the phone number automatically update immediately throughout your site.</p>
<p>MyVars has three possible variable types:</p>
<h4>Variables</h4>
<p>Variables are single word tokens that you can use anywhere in your page text, template HTML or even field inputs such as page titles, menu text or link text. The tokens are formatted as <strong>[[search_value]]</strong>. For instance, if you create a <strong>phone_number</strong> variable, you simply insert the <strong>[[phone_number]]</strong> token anywhere on your site, and the <strong>MyVars Plugin</strong> will automatically replace the token with the value you enter in the<strong> MyVars Manager</strong>.</p>
<h4>Example:</h4>
<p>Let&#8217;s say you create a variable with the search value <strong>phone_number</strong> and give it the replacement value <strong>(555) 555-1234</strong>.</p>
<p>In your page text, you enter:</p>
<p><em>For more information, please contact us at <strong>[[phone_number]]</strong></em>.</p>
<p>Your page will appear as:</p>
<p><em>For more information, please contact us at <strong>(555) 555-1234</strong></em>.</p>
<h4>Strings</h4>
<p>Strings are any string of text, of any length that you want to replace throughout your site. For instance, let&#8217;s say the name of your company changes from Acme Industries, LLC to Acme Global Industries, Inc. Rather than search throughout your entire site for every instance of the old name, you can create a string search value in <strong>MyVars Managers</strong> where the old name is the<strong> search value</strong> of the variable, and the new name is the <strong>replacement value</strong>. When your pages are rendered, the old name will be automatically replaced with the new value.</p>
<h4>Example:</h4>
<p>Let&#8217;s say you create a string search value <strong>Acme Industries, LLC</strong> and specify the replacement value <strong>Acme Global Industries, Inc.</strong>.</p>
<p>Your original page text contains:</p>
<p><em>Welcome to <strong>Acme Industries, LLC</strong>&#8230;</em>.</p>
<p>Your page will appear as:</p>
<p><em>Welcome to <strong>Acme Global Industries, Inc.</strong>&#8230;</em>.</p>
<h4>Regular Expressions (Advanced Users)</h4>
<p>Regular Expressions is a pattern matching language to allow you to match patterns or letters and/or numbers. MyVars allows you to specify a Regular Expression as a variable name to be replaced with the value you choose. For instance, if you want to add an area code to all instances of your phone number on your web site, you can specify<strong> /[0-9]{3}-[0-9]{4}/</strong> as the search value, enter <strong>(555) $0</strong> as the replacement value, and MyVars will automatically add the area code to each matching phone number.</p>
<h4>Example:</h4>
<p>Let&#8217;s say you create a Regular Expression search value <strong>/[0-9]{3}-[0-9]{4}/</strong> and give it the<br />
replacement value <strong>+1 (555) $0</strong>.</p>
<p>Your original page text contains:</p>
<p><em>Please contact us today at <strong>555-1234</strong>&#8230;</em>.</p>
<p>Your page will appear as:</p>
<p><em>Please contact us today at <strong>+1 (555) 555-1234</strong>&#8230;</em>.</p>
<h2>MyVars Extension Installation</h2>
<h3>System Requirements</h3>
<ul>
<li>SkyBlueCanvas v1.1</li>
<li>PHP 4 or above</li>
<li>Apache Web Server</li>
</ul>
<h3>Installation Instructions</h3>
<ol>
<li>Log into the <strong>Admin</strong> section of your SkyBlueCanvas site at <span style="text-decoration: underline;">www.yoursite.com/admin.php</span>.</li>
<li>Navigate to <strong>Admin &gt; Collections &gt; Installer</strong>.</li>
<li>
<ul>
<li>Click on the <strong>Managers</strong> tab.</li>
<li>Click the button labeled <strong>New</strong> in the upper-right corner of the admin page.</li>
<li>Click the button labeled <strong>Browse</strong>.</li>
<li>Using the file browser that appears, locate the MyVars Manager ZIP file in <span style="text-decoration: underline;">ext_myvars/packages/manager/myvars.zip</span>.</li>
<li>Click the button labeled <strong>Install</strong>.</li>
</ul>
</li>
<li>
<ul>
<li>Locate the MyVars Plugin file in <span style="text-decoration: underline;">ext_myvars/source/plugin/plugin.variables.php</span>.</li>
<li>Open the MyVars Plugin file in a text editor and copy the code.</li>
<li>Go to <strong>Admin &gt; Collections &gt; Plugins</strong></li>
<li>Click the button labeled <strong>Add</strong> in the upper-right corner of the admin page.</li>
<li>Paste the plugin code you copied into the textarea on the form.</li>
<li>Name the plugin <strong>plugin.variables.php</strong>.</li>
<li>Click the button labeled <strong>Save</strong>.</li>
</ul>
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/plugins/myvars-string-replacement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>scott</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[SkyBlueCanvas CMS]]></category>
<category>plugins</category><category>tutorials</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="" rel="nofollow" >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, 'pid', 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 . 'teaser.xml'
      );
    $snippet = $Core-&gt;SelectObj($snippets, $id);
    if (!$snippet) return null;
    $html  = "&lt;div id=\"snippet-$id\"&gt;\n";
    $html .= "&lt;h2&gt;{$snippet-&gt;name}&lt;/h2&gt;\n";
    $html .= "&lt;p&gt;" .
      base64_decode($snippet-&gt;intro) .
      "&lt;/p&gt;\n";
    $html .= "&lt;/div&gt;\n";
    return $html;
  }

  /**
  * Convert an argument to an array if it contains the
  * ',' delimiter. Otherwise return the argument untouched.
  */

  function plgSnippetConvertArg($arg)
  {
    if (strpos($arg, ',') == false) return $arg;
    $args = explode(',', $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 &#8211; 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])--&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>
		<slash:comments>0</slash:comments>
		</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>scott</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[SkyBlueCanvas CMS]]></category>
<category>plugins</category><category>tutorials</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><em>The SiteVars plugin is included in the SkyBlueCanvas core code. This article is still a good reference about how to use the plugin but you do not need to download or install any additional code.</em></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 class="syntax-table" border="0" cellspacing="0" cellpadding="0">
<tbody>
<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 &#8211; Settings &#8211; Default Info</td>
</tr>
<tr>
<td>site.url</td>
<td>Insert the URL of the site as set in Admin &#8211; Settings &#8211; 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 &#8211; Pages</td>
</tr>
<tr>
<td>site.contact_name</td>
<td>Insert the name of the default contact as set in Admin &#8211; Settings &#8211; Default Info</td>
</tr>
<tr>
<td>site.contact_title</td>
<td>Insert the title of the default contact as set in Admin &#8211; Settings &#8211; Default Info</td>
</tr>
<tr>
<td>site.contact_address</td>
<td>Insert the street address of the default contact as set in Admin &#8211; Settings &#8211; Default Info</td>
</tr>
<tr>
<td>site.contact_city</td>
<td>Insert the city of the default contact as set in Admin &#8211; Settings &#8211; Default Info</td>
</tr>
<tr>
<td>site.contact_state</td>
<td>Insert the state of the default contact as set in Admin &#8211; Settings &#8211; Default Info</td>
</tr>
<tr>
<td>site.contact_zip</td>
<td>Insert the postal code of the default contact as set in Admin &#8211; Settings &#8211; Default Info</td>
</tr>
<tr>
<td>site.contact_email</td>
<td>Insert the email address of the default contact as set in Admin &#8211; Settings &#8211; Default Info</td>
</tr>
<tr>
<td>site.contact_phone</td>
<td>Insert the phone number of the default contact as set in Admin &#8211; Settings &#8211; Default Info</td>
</tr>
<tr>
<td>site.contact_fax</td>
<td>Insert the fax number of the default contact as set in Admin &#8211; Settings &#8211; Default Info</td>
</tr>
</tbody>
</table>
<h3>Example Usage:</h3>
<pre class="html" lang="html">Welcome to [[site . name]]
</pre>
<p><!-- page.properties --></p>
<h2>Page Variables</h2>
<table class="syntax-table" border="0" cellspacing="0" cellpadding="0">
<tbody>
<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>
</tbody>
</table>
<h3>Example Usage:</h3>
<pre class="html" lang="html">Bread Crumbs: &lt;a href="index.php?pid=[[page . parent . id]]"&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 class="syntax-table" border="0" cellspacing="0" cellpadding="0">
<tbody>
<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 &#8211; 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 &#8211; 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 &#8211; 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 &#8211; Pages.</td>
</tr>
<tr>
<td>page.redirect(url)</td>
<td>Redirects the page to another URL.</td>
</tr>
</tbody>
</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>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Displaying Banner Ads</title>
		<link>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/displaying-banner-ads/</link>
		<comments>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/displaying-banner-ads/#comments</comments>
		<pubDate>Tue, 17 Jun 2008 01:01:53 +0000</pubDate>
		<dc:creator>scott</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[SkyBlueCanvas CMS]]></category>
<category>plugins</category><category>tutorials</category>
		<guid isPermaLink="false">http://blog.skybluecanvas.com/?p=30</guid>
		<description><![CDATA[SkyBlueCanvas Lightweight CMS comes with the ability to easily display banner ads on your site. This is achieved via the Plugin API and the ads plugin that comes with the SkyBlueCanvas source code. In this article I give you step-by-step instructions to help set up banner ads on your SkyBlueCanvas site.]]></description>
			<content:encoded><![CDATA[<p>SkyBlueCanvas Lightweight CMS comes with the ability to easily display banner ads on your site. This is achieved via the Plugin API and the ads plugin that comes with the SkyBlueCanvas source code.<br />
Defining Ad zones</p>
<p>Ad zones are defined using a special kind of commment in the HTML Skin of your site. Ad replacement tokens are a specially-formatted token that appears in your site Skin. An example from my own site is:</p>
<h3>Defining Banner Ad Zones</h3>
<pre class="html" lang="html">
&lt;!--#ads:main-top--&gt;
</pre>
<p>When the ads plugin loads, SkyBlueCanvas passes the page HTML to the plugin call which looks like this:</p>
<h3>The Ads Plugin</h3>
<pre class="php" lang="php">
plgLoadAds($html);
</pre>
<p>The ads plugin parses all comments that are formatted as above and determines the zone. In this case &#8216;main-top&#8217;. As the plugin encounters each token, it then looks in /skyblue/data/ads/ for any files whose names match the zone specified in the token. You can have an unlimited number of ads for each zone and the ads plugin will display them randomly.<br />
Saving Your Ads</p>
<p>NOTE: In order to upload ads to your site, you will need FTP access.</p>
<p>Ads are saved as text files in /skyblue/data/ads/. It doesn&#8217;t matter if your ad is a JavaScript? or HTML block. SkyBlueCanvas sends whatever is stored in the ad file to the browser and lets the browser determine how it should be displayed. Since the ads are saved as text, there is no code execution that takes place on the server, so you do not need to worry about malicious code &#8211; at least on the server side.<br />
Naming Your Ad Files</p>
<p>SkyBlueCanvas matches the file to the zone in which it is to be displayed based on the file name. You can name your zones anything you like, as long as your ad file names match the zone names you defined.</p>
<p>For example, if I have defined a zone &#8216;main-top&#8217;, then I would include the following token in my HTML skin:</p>
<pre class="html" lang="html">
&lt;!--#ads:main-top--&gt;
</pre>
<p>Then, I would save my add files with names like this:</p>
<ul>
<li>main-top.skypead.txt</li>
<li>main-top.yahoo.txt</li>
<li>main-top.googleads.txt</li>
</ul>
<h3>Styling Your Ad Blocks</h3>
<p>Each ad block is wrapped in a div with a unique ID to allow you to create CSS rules corresponding to each ad block.</p>
<p>Using the example above, the ad block wrapper would look like this:</p>
<pre class="html" lang="html">
&lt;div id="ads-main-top"&gt;
    &lt;!-- the ad code here --&gt;
&lt;/div&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/displaying-banner-ads/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SkyBlueCanvas Plugin Example</title>
		<link>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/skybluecanvas-example/</link>
		<comments>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/skybluecanvas-example/#comments</comments>
		<pubDate>Sun, 15 Jun 2008 01:50:43 +0000</pubDate>
		<dc:creator>scott</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[SkyBlueCanvas CMS]]></category>
<category>plugins</category><category>tutorials</category>
		<guid isPermaLink="false">http://blog.skybluecanvas.com/?p=16</guid>
		<description><![CDATA[Plugin Method No. 1
SkyBlueCanvas has a very flexible yet simple plugin API. Actually, it has 2 plugin APIs for greater flexibility. The first API is almost identical to the API used by Wordpress and Joomla &#8211; both of which use the Observer design pattern. 
Calling an Observer plugin in SkyBlueCanvas is simple. Create a file [...]]]></description>
			<content:encoded><![CDATA[<h2>Plugin Method No. 1</h2>
<p>SkyBlueCanvas has a very flexible yet simple plugin API. Actually, it has 2 plugin APIs for greater flexibility. The first API is almost identical to the API used by Wordpress and Joomla &#8211; both of which use the Observer design pattern. </p>
<p>Calling an Observer plugin in SkyBlueCanvas is simple. Create a file named &#8216;myplugin.php&#8217; and save it in /skyblue/data/plugins/myplugin.php. In the file, include the following code: </p>
<pre class="php">
global $Core;

$Core-&gt;RegisterEvent('OnBeforeShowPage', 'AllYourPlugins');

function AllYourPlugins($html) {
    $html .= "&lt;p&gt;All your plugins are belong to us&lt;/p&gt;n";
    return $html;
}
</pre>
<p>That&#8217;s it. Now when the $Core object gets to the &#8216;BeforeShowPage&#8217; marker, it will call the AllYourPlugins function, passing the $html variable containing the page data to the function. The function can perform any operation it need to on the page code, then must return it to the $Core object. </p>
<p>SkyBlueCanvas currently has 4 events to which plugin execution can be attached: </p>
<ul>
<li><strong>OnBeforeInitPage</strong>
<p>is triggered before the page is built. </p>
</li>
<li><strong>OnAfterLoadStory</strong>
<p>is triggered when the article for the current page is loaded.</p>
</li>
<li><strong>OnBeforeShowPage</strong>
<p>is triggered after the entire page is built but before it is sent to the browser.</p>
</li>
<li><strong>OnAfterCache</strong>
<p>is triggered after the page has been retrieved from and/or saved to cache.</p>
</li>
</ul>
<p>I am working on implementing more events but they will not be available until the next release. </p>
<h2>Plugin Method No. 2</h2>
<p>There are instances when you want to insert some code or execute some code at a certain point within the flow of a story. Well, SkyBlueCanvas allows you to do just that with the second Plugin API. </p>
<p>This API allows you to call specific functions, with arguments within the flow of the text using special tokens and function calls that look like this: </p>
<pre class="php">
{plugin:myfunction('Plugins')}
</pre>
<p>Before SkyBlueCanvas displays the page, it will parse all of the special plugin tokens, and call the function specified in the token. So, in this example, when the token is parsed, the SkyBlueCanvas PluginParser will call &#8216;myfunction&#8217; passing it the argument &#8216;Plugins&#8217;. </p>
<p>Now create a file in /skyblue/data/plugins/myplugin.php and create the myfunction function like so: </p>
<pre class="php">
function myfunction($args) {
    if (!count($args)) return false;
    $what = $args[0];
    echo "&lt;p&gt;All your $what are belong to us&lt;/p&gt;n";
}
</pre>
<p>Additionally, this method can be embedded in the HTML of your template as well like so: </p>
<pre class="php"><span class="com">
&lt;!--#plugin:myfunction(Plugins)--&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/skybluecanvas-example/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
