<?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>Raymond Kolbe &#187; savant3</title>
	<atom:link href="http://www.raymondkolbe.com/tag/savant3/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.raymondkolbe.com</link>
	<description>Code, cars, and beer...</description>
	<lastBuildDate>Sun, 07 Feb 2010 17:14:18 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Savant3 URI Plugin</title>
		<link>http://www.raymondkolbe.com/2009/06/14/savant3-uri-plugin/</link>
		<comments>http://www.raymondkolbe.com/2009/06/14/savant3-uri-plugin/#comments</comments>
		<pubDate>Sun, 14 Jun 2009 16:24:35 +0000</pubDate>
		<dc:creator>Ray</dc:creator>
				<category><![CDATA[PHP/MySQL]]></category>
		<category><![CDATA[Solar]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[savant3]]></category>
		<guid isPermaLink="false">http://white-box.us/?p=274</guid>
		<description><![CDATA[I started working on a small project last weekend for a [H]ard&#124;Forum member that would allow viewing maillog log info from a web site.  I wanted to make an app that would have a small footprint and would be easy to manage (code base wise as well as UI).  My first instinct was [...]]]></description>
			<content:encoded><![CDATA[<p>I started working on a small project last weekend for a <a href="http://hardforum.com">[H]ard|Forum</a> member that would allow viewing maillog log info from a web site.  I wanted to make an app that would have a small footprint and would be easy to manage (code base wise as well as UI).  My first instinct was to use a MVC framework like <a href="http://solarphp.com">Solar</a> or <a href="http://framework.zend.com">Zend</a> but those two have more features than what I needed for this project.  Remember, I wanted a small footprint.</p>
<p>I decided to give <a href="http://phpsavant.com/">Savant3</a> a shot.  This at least allows me to separate my controller logic from my view logic.  I only had one controller and one template so code overhead wasn&#8217;t an issue.</p>
<p>One of the things missing from this system was a way to easily handle URIs/URLs.  Since Savant3 is a template engine, I wouldn&#8217;t necessarily expect a URI handler.  However, I felt that having a plugin that handles URIs was worth the effort, even with a project of this size.</p>
<p>Since the plugin code is still a bit messy (missing inline docs, needs a little bit of refactoring, etc) I can only show you usage examples for now.  I plan on cleaning up the code and releasing the plugin on this site shortly.</p>
<p>Here is how one might use this URI plugin in a Savant3 template:</p>
<pre class="brush: php;">
// builds the URI based off of the current URL
$uri = $this-&gt;uri()-&gt;fromCurrentUrl();
// allows setting query info
$uri-&gt;query = 'order=name_asc';
// this adds to the query, it does not overwrite it
$uri-&gt;query = 'page=2';
// returns only the query portion: '?order=name&amp;page=2'
$uri-&gt;get();
// this will update page to 'page=3'
$uri-&gt;query = 'page=3';
// again we only return the query portion: '?order=name&amp;page=3'
$uri-&gt;get();
// we can also set a full query as well and we can provide keys without values
$uri-&gt;query = 'order=name_desc&amp;page=3&amp;submitted'
// currently there is not a way to remove a single piece of the query
// we have to reset the whole query and rebuild it
unset($uri-&gt;query);
// passing 'true' to get() gives us the whole URI
// for example: http://white-box.us/somedir/index.php
$uri-&gt;get(true);
</pre>
<p>The rest of the functionality works much like <a href="http://solarphp.com/class/Solar_Uri">Solar_Uri</a> (currently w/the exception of path and query behavior), being able to set each piece of the URI before returning a newly built URI.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.raymondkolbe.com/2009/06/14/savant3-uri-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
