<?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>Mike Funk</title>
	<atom:link href="http://mikefunk.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://mikefunk.com</link>
	<description>Web Developer</description>
	<lastBuildDate>Thu, 11 Oct 2012 16:26:35 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Remote Config Files In CodeIgniter</title>
		<link>http://mikefunk.com/remote-config-files-in-codeigniter/</link>
		<comments>http://mikefunk.com/remote-config-files-in-codeigniter/#comments</comments>
		<pubDate>Mon, 07 May 2012 20:22:11 +0000</pubDate>
		<dc:creator>mikedfunk</dc:creator>
				<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://mikefunk.com/?p=58</guid>
		<description><![CDATA[I ran into a situation recently where I had multiple CodeIgniter apps which depended on the same config values. No problem, right? Just use a common third_party folder. That would work, except they were on different servers! My solution was &#8230; <a href="http://mikefunk.com/remote-config-files-in-codeigniter/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I ran into a situation recently where I had multiple CodeIgniter apps which depended on the same config values. No problem, right? Just use a common third_party folder. That would work, except they were on different servers! My solution was to echo the config as JSON in one place, grab the JSON in other apps and load them as config values. Now you can do the same!</p>

<h2>Setup</h2>
<ol>
<li>Install sparks at <a href="http://getsparks.org">GetSparks.org</a></li>
<li>Install the <a href="http://getsparks.org/packages/curl_load/show">curl_load spark</a></li>
</ol>

<h2>Usage</h2>

<p>First, do this in your config file:</p>

<pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #808080; font-style: italic;">// DON'T put the usual !defined(BASEPATH) part up here</span>
&nbsp;
<span style="color: #0000ff;">$config</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'this_key'</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">'value'</span>;
<span style="color: #0000ff;">$config</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'that_key'</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">'value'</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// if it's not loaded by CodeIgniter, echo it as JSON so</span>
<span style="color: #808080; font-style: italic;">// we can grab the keys/values remotely</span>
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>!<a href="http://www.php.net/defined"><span style="color: #000066;">defined</span></a><span style="color: #66cc66;">&#40;</span>BASEPATH<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> json_encode<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$config</span><span style="color: #66cc66;">&#41;</span>;</pre>

<p>Now in your controller, use the curl_load spark to load the config file:</p>

<pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> ! <a href="http://www.php.net/defined"><span style="color: #000066;">defined</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'BASEPATH'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <a href="http://www.php.net/exit"><span style="color: #000066;">exit</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'No direct script access allowed'</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> test_controller <span style="color: #000000; font-weight: bold;">extends</span> CI_Controller
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> index<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#123;</span>
        <span style="color: #808080; font-style: italic;">// replace x.x.x with version number</span>
        <span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">load</span>-&gt;<span style="color: #006600;">spark</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'curl_load/x.x.x'</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
        <span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">curl_load</span>-&gt;<span style="color: #006600;">load_config</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'http://example.com/path/to/config.php'</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre>

<p>If you need to secure the values of the config file, you can add optional http authentication credentials:</p>

<pre class="php"><span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">curl_load</span>-&gt;<span style="color: #006600;">load_config</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'http://example.com/path/to/config.php'</span>, <span style="color: #ff0000;">'http_auth_username'</span>, <span style="color: #ff0000;">'http_auth_password'</span><span style="color: #66cc66;">&#41;</span>;</pre>

<p>Or you could load an array of config files:</p>

<pre class="php"><span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">curl_load</span>-&gt;<span style="color: #006600;">load_config</span><span style="color: #66cc66;">&#40;</span>
    <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span>
        <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span>
            <span style="color: #ff0000;">'url'</span> =&gt; <span style="color: #ff0000;">'http://url1.com/config.php'</span>
        <span style="color: #66cc66;">&#41;</span>,
        <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span>
            <span style="color: #ff0000;">'url'</span> =&gt; <span style="color: #ff0000;">'http://url2.com/config.php'</span>,
            <span style="color: #ff0000;">'username'</span> =&gt; <span style="color: #ff0000;">'optional_http_auth_username'</span>,
            <span style="color: #ff0000;">'password'</span> =&gt; <span style="color: #ff0000;">'optional_http_auth_password'</span>
        <span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span>;</pre>

<p>Last but not least: You can set it to autoload config files in <pre class="php">config/curl_load.php</pre>. Just add your config files in the same array format as above:</p>

<pre class="php"><span style="color: #0000ff;">$config</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'curl_autoload'</span><span style="color: #66cc66;">&#93;</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span>
    <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span>
        <span style="color: #ff0000;">'url'</span> =&gt; <span style="color: #ff0000;">'http://url1.com/config.php'</span>
    <span style="color: #66cc66;">&#41;</span>,
    <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span>
        <span style="color: #ff0000;">'url'</span> =&gt; <span style="color: #ff0000;">'http://url2.com/config.php'</span>,
        <span style="color: #ff0000;">'username'</span> =&gt; <span style="color: #ff0000;">'optional_http_auth_username'</span>,
        <span style="color: #ff0000;">'password'</span> =&gt; <span style="color: #ff0000;">'optional_http_auth_password'</span>
    <span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span>;</pre>

<p>This is really cool, especially when you autoload the spark as well. Then your config values will automatically be loaded without you having to do anything!</p>

<pre class="php"><span style="color: #0000ff;">$autoload</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'sparks'</span><span style="color: #66cc66;">&#93;</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'curl_load/x.x.x'</span><span style="color: #66cc66;">&#41;</span>;</pre>

<p>If this helps you, leave me a comment. Have fun!</p><div id="social-essentials" class="se_left"><div class="se_button se_button_small" style="width:85px;margin:0px 0px 0px 0px"><a href="https://twitter.com/share" class="twitter-share-button" data-url="http://mikefunk.com/remote-config-files-in-codeigniter/" data-text="Remote Config Files In CodeIgniter" data-via="mikedfunk" data-counturl="http://mikefunk.com/remote-config-files-in-codeigniter/" data-count="horizontal" data-lang="en">Tweet</a></div><div class="se_button se_button_small" style="width:72px;margin:0px 0px 0px 0px"><iframe src="//www.facebook.com/plugins/like.php?locale=en_US&href=http%3A%2F%2Fmikefunk.com%2Fremote-config-files-in-codeigniter%2F&amp;send=false&amp;layout=button_count&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font" scrolling="no" frameborder="0" allowTransparency="true"></iframe></div><div class="se_button se_button_small" style="width:60px;margin:0px 0px 0px 0px"><g:plusone size="medium" href="http://mikefunk.com/remote-config-files-in-codeigniter/" count="true"></g:plusone></div></div><div class="clear"></div><style type="text/css">#call_to_action h4{padding:0px 5px;}</style>]]></content:encoded>
			<wfw:commentRss>http://mikefunk.com/remote-config-files-in-codeigniter/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Barcamp Orlando Presentation</title>
		<link>http://mikefunk.com/barcamp-orlando-presentation/</link>
		<comments>http://mikefunk.com/barcamp-orlando-presentation/#comments</comments>
		<pubDate>Sat, 14 Apr 2012 15:58:43 +0000</pubDate>
		<dc:creator>mikedfunk</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mikefunk.com/?p=48</guid>
		<description><![CDATA[Today I'll be presenting an overview of Twitter Bootstrap. The slides are available here. It will cover an overview on the CSS, JS, HTML template, Less CSS concerns. Enjoy! Tweet]]></description>
				<content:encoded><![CDATA[<p>Today I'll be presenting an overview of Twitter Bootstrap.<br />
<a href="https://docs.google.com/presentation/d/174UdBXHRl4PvOO0T-ICiskgc2pcRVh_TSYKKMwJjuM0/edit">The slides are available here</a>. It will cover an overview on the CSS, JS, HTML template, Less CSS concerns. Enjoy!</p>
<div id="social-essentials" class="se_left"><div class="se_button se_button_small" style="width:85px;margin:0px 0px 0px 0px"><a href="https://twitter.com/share" class="twitter-share-button" data-url="http://mikefunk.com/barcamp-orlando-presentation/" data-text="Barcamp Orlando Presentation" data-via="mikedfunk" data-counturl="http://mikefunk.com/barcamp-orlando-presentation/" data-count="horizontal" data-lang="en">Tweet</a></div><div class="se_button se_button_small" style="width:72px;margin:0px 0px 0px 0px"><iframe src="//www.facebook.com/plugins/like.php?locale=en_US&href=http%3A%2F%2Fmikefunk.com%2Fbarcamp-orlando-presentation%2F&amp;send=false&amp;layout=button_count&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font" scrolling="no" frameborder="0" allowTransparency="true"></iframe></div><div class="se_button se_button_small" style="width:60px;margin:0px 0px 0px 0px"><g:plusone size="medium" href="http://mikefunk.com/barcamp-orlando-presentation/" count="true"></g:plusone></div></div><div class="clear"></div><style type="text/css">#call_to_action h4{padding:0px 5px;}</style>]]></content:encoded>
			<wfw:commentRss>http://mikefunk.com/barcamp-orlando-presentation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IE Multiple Submit Buttons Bug</title>
		<link>http://mikefunk.com/ie-multiple-submit-buttons-bug/</link>
		<comments>http://mikefunk.com/ie-multiple-submit-buttons-bug/#comments</comments>
		<pubDate>Mon, 09 Apr 2012 17:12:58 +0000</pubDate>
		<dc:creator>mikedfunk</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mikefunk.com/?p=45</guid>
		<description><![CDATA[I ran into a nasty bug recently that was totally unexpected. I had a form that needed to be submitted to multiple possible locations such as submit item and save draft. I am trying to chill on JQuery overuse lately &#8230; <a href="http://mikefunk.com/ie-multiple-submit-buttons-bug/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I ran into a nasty bug recently that was totally unexpected. I had a form that needed to be submitted to multiple possible locations such as <em>submit item</em> and <em>save draft</em>. I am trying to chill on JQuery overuse lately so I Googled a solution for this. Turns out I'm in luck! You can have multiple submit buttons with the same name but different values. Whichever one you click will be submitted, while the other won't. Yay!</p>

<p>So I thought.</p>

<p>Unfortunately, if you Google "multiple submit buttons" and open an article, most of them don't mention a nasty IE 6-7 bug where this simple process fails silently. It's not a CSS bug. It's not a javascript bug. It's a bug in the way IE handles submit events, and it sucks.</p>

<p>Here's an example form. It just submits to itself and displays the value of the "action" button submitted. Check the source:</p>

<script src="https://gist.github.com/2344500.js?file=gistfile1.phtml"></script>

<p><a href="http://mikefunk.com/examples/ie_submit_test.php">Give it a try yourself and see what happens</a>. Try it in IE6, IE7, then in a modern browser. Go ahead, I'll wait. In case you don't have these installed, here's IE6:</p>

<p><img src="http://mikefunk.com/assets/images/ie6_submit_test.png" alt="IE6" title="" /></p>

<p>and here's IE7:</p>

<p><img src="http://mikefunk.com/assets/images/ie7_submit_test.png" alt="IE6" title="" /></p>

<p>In both IE6 and IE7, It treats buttons strangely. It submits <em>the text between the button tags</em> rather than the <em>value</em> of the button. WTF? On top of that, IE6 just submits the value as the last submit button in the source order with that name, no matter which button you click. WTF! At least it seems to work as expected in IE8 and IE9.</p>

<p>So how do we fix it? With some JQuery duct tape.</p>

<p>First we strip the <code>name</code> and <code>value</code> attributes of the buttons. Retard IE can't figure them out. We'll replace them with some <a href="twitter.github.com/bootstrap/">twitter bootstrap</a> style metadata:</p>

<pre>&lt;button data-value=&quot;value one&quot; class=&quot;btn&quot; type=&quot;submit&quot;&gt;Submit One&lt;/button&gt;
&lt;button data-value=&quot;value two&quot; class=&quot;btn&quot; type=&quot;submit&quot;&gt;Submit Two&lt;/button&gt;</pre>

<p>Then we add a hidden input for the <code>action</code>. We set a default value so the enter key will still work:</p>

<pre>&lt;input type=&quot;hidden&quot; name=&quot;action&quot; value=&quot;one&quot; /&gt;</pre>

<p>Then we add some simple jquery to the top:</p>

<pre class="javascript">&lt;script type=<span style="color: #3366CC;">&quot;text/javascript&quot;</span>&gt;
    $<span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#123;</span>
        <span style="color: #009900; font-style: italic;">// on clicking one of the submit buttons</span>
        $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'button'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">click</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#123;</span>
            <span style="color: #009900; font-style: italic;">// get the data-value and assign it to the hidden action field</span>
            <span style="color: #003366; font-weight: bold;">var</span> submit_val = $<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">attr</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'data-value'</span><span style="color: #66cc66;">&#41;</span>;
            $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'[name=&quot;action&quot;]'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">val</span><span style="color: #66cc66;">&#40;</span>submit_val<span style="color: #66cc66;">&#41;</span>;
        <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
        <span style="color: #009900; font-style: italic;">// form submit, just to allow js to set the value before submitting</span>
	    $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'form'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">submit</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>e<span style="color: #66cc66;">&#41;</span>
	    <span style="color: #66cc66;">&#123;</span>
	    	e.<span style="color: #006600;">preventDefault</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	    	$<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">unbind</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'submit'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">submit</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	    <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;​
&lt;/script&gt;</pre>

<p>Now we're all set! The <code>click</code> event always fires before the <code>submit</code> event, even in IE6. It sets the value of the hidden input and submits the form. Here's our working file:</p>

<script src="https://gist.github.com/2344684.js"></script>

<a href="http://mikefunk.com/examples/ie_submit_test_working.php">Check it out</a>, it's working!<div id="social-essentials" class="se_left"><div class="se_button se_button_small" style="width:85px;margin:0px 0px 0px 0px"><a href="https://twitter.com/share" class="twitter-share-button" data-url="http://mikefunk.com/ie-multiple-submit-buttons-bug/" data-text="IE Multiple Submit Buttons Bug" data-via="mikedfunk" data-counturl="http://mikefunk.com/ie-multiple-submit-buttons-bug/" data-count="horizontal" data-lang="en">Tweet</a></div><div class="se_button se_button_small" style="width:72px;margin:0px 0px 0px 0px"><iframe src="//www.facebook.com/plugins/like.php?locale=en_US&href=http%3A%2F%2Fmikefunk.com%2Fie-multiple-submit-buttons-bug%2F&amp;send=false&amp;layout=button_count&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font" scrolling="no" frameborder="0" allowTransparency="true"></iframe></div><div class="se_button se_button_small" style="width:60px;margin:0px 0px 0px 0px"><g:plusone size="medium" href="http://mikefunk.com/ie-multiple-submit-buttons-bug/" count="true"></g:plusone></div></div><div class="clear"></div><style type="text/css">#call_to_action h4{padding:0px 5px;}</style>]]></content:encoded>
			<wfw:commentRss>http://mikefunk.com/ie-multiple-submit-buttons-bug/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Query Strings in CodeIgniter</title>
		<link>http://mikefunk.com/query-strings-in-codeigniter/</link>
		<comments>http://mikefunk.com/query-strings-in-codeigniter/#comments</comments>
		<pubDate>Sat, 31 Mar 2012 17:09:50 +0000</pubDate>
		<dc:creator>mikedfunk</dc:creator>
				<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://mikefunk.com/?p=3</guid>
		<description><![CDATA[CodeIgniter really does not like query strings. It's just downright mean. $this-&#62;uri-&#62;uri_string() removes the query string. Why? current_url() from the url helper removes the query string. Why? You can use query strings instead of segment-based urls such as http://example.com?c=controller_name&#38;m=method_name instead &#8230; <a href="http://mikefunk.com/query-strings-in-codeigniter/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>CodeIgniter really does not like query strings. It's just downright mean.</p>
<ol>
<li><code>$this-&gt;uri-&gt;uri_string()</code> removes the query string. Why?</li>
<li><code>current_url()</code> from the url helper removes the query string. Why?</li>
<li>You can use query strings instead of segment-based urls such as <code>http://example.com?c=controller_name&amp;m=method_name</code> instead of <code>http://example.com/controller_name/method_name</code>but they have a nasty warning:</li>
</ol>
<blockquote><p>If you are using query strings you will have to build your own URLs, rather than utilizing the URL helpers (and other helpers that generate URLs, like some of the form helpers) as these are designed to work with segment based URLs.</p></blockquote>
<p>Not a good deal! Plus there are no built-in helpers or libraries to grab the query string and do stuff with it.</p>
<p>But why use query strings at all? I thought segments were better?</p>
<ol>
<li>Unlike URI segments, query string segments are all optional. If you have 5 key/value pairs, you can include just items 1 and 5 if you want.</li>
<li>Unlike URI segments, query string segments can be put in any order. If you have the same 5 items you can order them like 4,5,3,1,2 if you want.</li>
</ol>
<p>These are big deals, because they are a giant pain in the ass with segments. For instance, let's say you have 5 segments and you just want to change segment 5 from the default. You have to send the default values for segments 1-4 first! So your url ends up looking something like this:</p>
<pre><code>http://example.com/1/true/false/0/fifth_segment </code></pre>
<p>Looking at that url it makes no sense. You don't know what 1, true, false, or 0 refer to. But you are forced to type them all. What happens if one of these default values change? Or if the order changes? Or if you have to add or remove a segment? You have to change all your URLs! What a pain in the ass!!</p>
<p>Now segment-based urls are fine for hierarchical websites such as <code>/products/outdoor/chainsaws/12</code>. But for web applications, they totally suck. The way I see it there are two possible ways to fix this in CodeIgniter. You can either extend the URI and URL classes or write a new helper/library. I chose not to mess with URLs and just create a helper so I could use it in a view by just calling a function without <code>$this-&gt;helper_name-&gt;</code> in front. So here's my query_string_helper:</p>
<p><strong>Query String Helper</strong><br />
<strong><a href="http://getsparks.org/packages/query_string_helper/versions/HEAD/show">Download</a></strong></p>
<p>It has just two functions:</p>
<ol>
<li><code>query_string($add, $remove, $include_current)</code>This just echoes the query string with no params.
<ol>
<li>Param 1 allows you to add an array of items to the query string.</li>
<li>Param 2 you can either send a string of a key you want to remove or send an array of keys you want to remove.</li>
<li>Param 3 lets you ditch the current query string if you want and just make a new one.</li>
</ol>
</li>
<li><code>uri_query_string( same params as above )</code> This includes the full current uri with the query string on the end. It allows you to manipulate the query string in the same ways as above.</li>
</ol>
<p>Now you can just replace all your <code>$this-&gt;uri-&gt;uri_string()</code> or <code>current_url()</code> calls with <code>uri_query_string()</code> and you're good to go!</p>
<div id="social-essentials" class="se_left"><div class="se_button se_button_small" style="width:85px;margin:0px 0px 0px 0px"><a href="https://twitter.com/share" class="twitter-share-button" data-url="http://mikefunk.com/query-strings-in-codeigniter/" data-text="Query Strings in CodeIgniter" data-via="mikedfunk" data-counturl="http://mikefunk.com/query-strings-in-codeigniter/" data-count="horizontal" data-lang="en">Tweet</a></div><div class="se_button se_button_small" style="width:72px;margin:0px 0px 0px 0px"><iframe src="//www.facebook.com/plugins/like.php?locale=en_US&href=http%3A%2F%2Fmikefunk.com%2Fquery-strings-in-codeigniter%2F&amp;send=false&amp;layout=button_count&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font" scrolling="no" frameborder="0" allowTransparency="true"></iframe></div><div class="se_button se_button_small" style="width:60px;margin:0px 0px 0px 0px"><g:plusone size="medium" href="http://mikefunk.com/query-strings-in-codeigniter/" count="true"></g:plusone></div></div><div class="clear"></div><style type="text/css">#call_to_action h4{padding:0px 5px;}</style>]]></content:encoded>
			<wfw:commentRss>http://mikefunk.com/query-strings-in-codeigniter/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>My CodeIgniter libraries are now sparks!</title>
		<link>http://mikefunk.com/my-codeigniter-libraries-are-now-sparks/</link>
		<comments>http://mikefunk.com/my-codeigniter-libraries-are-now-sparks/#comments</comments>
		<pubDate>Sat, 03 Mar 2012 22:49:04 +0000</pubDate>
		<dc:creator>mikedfunk</dc:creator>
				<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://mikefunk.com/?p=34</guid>
		<description><![CDATA[I've migrated all my open-source libraries to sparks on GetSparks.org. You can check them all out on my profile page. Now they're much easier to install, use and keep up-to-date! I've also updated my Base CodeIgniter App and Bookymark to use Sparks &#8230; <a href="http://mikefunk.com/my-codeigniter-libraries-are-now-sparks/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I've migrated all my open-source libraries to sparks on <a href="http://getsparks.org">GetSparks.org</a>. You can check them all out on <a href="http://getsparks.org/contributors/profile/mikedfunk">my profile page</a>. Now they're much easier to install, use and keep up-to-date!</p>
<p>I've also updated my <a href="https://github.com/mikedfunk/Base-CodeIgniter-App">Base CodeIgniter App</a> and <a href="http://bookymark.com">Bookymark</a> to use Sparks as well. Woot!</p>
<div id="social-essentials" class="se_left"><div class="se_button se_button_small" style="width:85px;margin:0px 0px 0px 0px"><a href="https://twitter.com/share" class="twitter-share-button" data-url="http://mikefunk.com/my-codeigniter-libraries-are-now-sparks/" data-text="My CodeIgniter libraries are now sparks!" data-via="mikedfunk" data-counturl="http://mikefunk.com/my-codeigniter-libraries-are-now-sparks/" data-count="horizontal" data-lang="en">Tweet</a></div><div class="se_button se_button_small" style="width:72px;margin:0px 0px 0px 0px"><iframe src="//www.facebook.com/plugins/like.php?locale=en_US&href=http%3A%2F%2Fmikefunk.com%2Fmy-codeigniter-libraries-are-now-sparks%2F&amp;send=false&amp;layout=button_count&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font" scrolling="no" frameborder="0" allowTransparency="true"></iframe></div><div class="se_button se_button_small" style="width:60px;margin:0px 0px 0px 0px"><g:plusone size="medium" href="http://mikefunk.com/my-codeigniter-libraries-are-now-sparks/" count="true"></g:plusone></div></div><div class="clear"></div><style type="text/css">#call_to_action h4{padding:0px 5px;}</style>]]></content:encoded>
			<wfw:commentRss>http://mikefunk.com/my-codeigniter-libraries-are-now-sparks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting CIUnit to work with Sparks</title>
		<link>http://mikefunk.com/getting-ciunit-to-work-with-sparks/</link>
		<comments>http://mikefunk.com/getting-ciunit-to-work-with-sparks/#comments</comments>
		<pubDate>Fri, 02 Mar 2012 21:11:53 +0000</pubDate>
		<dc:creator>mikedfunk</dc:creator>
				<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://mikefunk.com/?p=27</guid>
		<description><![CDATA[I recently got bit by the Sparks bug again. If you don't know, Sparks is like CodeIgniter's version of Ruby Gems. It's a command-line-based package manager that lets you install stuff for CodeIgniter quickly and keep it up-to-date. It's a &#8230; <a href="http://mikefunk.com/getting-ciunit-to-work-with-sparks/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I recently got bit by the Sparks bug again. If you don't know, <a href="http://getsparks.org">Sparks</a> is like CodeIgniter's version of Ruby Gems. It's a command-line-based package manager that lets you install stuff for CodeIgniter quickly and keep it up-to-date. It's a great idea and I want to port my libraries over to this system.</p>

<p>So I thought I'd try to get <a href="https://bitbucket.org/kenjis/my-ciunit">Kenji's CIUnit</a> working with Sparks. His <a href="https://bitbucket.org/kenjis/my-ciunit/wiki/Home">wiki</a> says to just change one line in <strong>MY_Loader.php</strong> (which is created by Sparks) and you're good to go. I found this to not be the case, so I did a little digging. Here's what you need to do to get them to play nice together:</p>

<p>If you haven't already, start by <a href="http://getsparks.org">installing Sparks</a>.</p>

<p>In <strong>application/core/MY_Loader.php</strong> change this:</p>
<pre class="php"><a href="http://www.php.net/define"><span style="color: #000066;">define</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'SPARKPATH'</span>, <span style="color: #ff0000;">'sparks/'</span><span style="color: #66cc66;">&#41;</span>;</pre>
<p>to this:</p>
<pre class="php"><a href="http://www.php.net/define"><span style="color: #000066;">define</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'SPARKPATH'</span>, APPPATH . <span style="color: #ff0000;">'../sparks/'</span><span style="color: #66cc66;">&#41;</span>;</pre>
<p>Then in <strong>application/third_party/CIUnit/core/CIU_Loader.php</strong> change this:</p>
<pre class="php"><span style="color: #000000; font-weight: bold;">class</span> CIU_Loader <span style="color: #000000; font-weight: bold;">extends</span> CI_Loader <span style="color: #66cc66;">&#123;</span></pre>
<p>to this:</p>
<pre class="php"><span style="color: #000000; font-weight: bold;">class</span> CIU_Loader <span style="color: #000000; font-weight: bold;">extends</span> MY_Loader <span style="color: #66cc66;">&#123;</span></pre>
<p>Then you should be good to go. CD back to your root/tests in the terminal and hit phpunit. If you've loaded sparks, they should now work without erroring out. Huzzah!</p><div id="social-essentials" class="se_left"><div class="se_button se_button_small" style="width:85px;margin:0px 0px 0px 0px"><a href="https://twitter.com/share" class="twitter-share-button" data-url="http://mikefunk.com/getting-ciunit-to-work-with-sparks/" data-text="Getting CIUnit to work with Sparks" data-via="mikedfunk" data-counturl="http://mikefunk.com/getting-ciunit-to-work-with-sparks/" data-count="horizontal" data-lang="en">Tweet</a></div><div class="se_button se_button_small" style="width:72px;margin:0px 0px 0px 0px"><iframe src="//www.facebook.com/plugins/like.php?locale=en_US&href=http%3A%2F%2Fmikefunk.com%2Fgetting-ciunit-to-work-with-sparks%2F&amp;send=false&amp;layout=button_count&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font" scrolling="no" frameborder="0" allowTransparency="true"></iframe></div><div class="se_button se_button_small" style="width:60px;margin:0px 0px 0px 0px"><g:plusone size="medium" href="http://mikefunk.com/getting-ciunit-to-work-with-sparks/" count="true"></g:plusone></div></div><div class="clear"></div><style type="text/css">#call_to_action h4{padding:0px 5px;}</style>]]></content:encoded>
			<wfw:commentRss>http://mikefunk.com/getting-ciunit-to-work-with-sparks/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>console.log() and Internet Explorer</title>
		<link>http://mikefunk.com/console-log-and-internet-explorer/</link>
		<comments>http://mikefunk.com/console-log-and-internet-explorer/#comments</comments>
		<pubDate>Fri, 02 Mar 2012 15:11:42 +0000</pubDate>
		<dc:creator>mikedfunk</dc:creator>
				<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://mikefunk.com/?p=15</guid>
		<description><![CDATA[The Problem I use console.log() in javascript all the time for debugging. It's a great way to display errors without printing them on the screen. Sometimes I forget to delete them all before deploying live code. Come to find out &#8230; <a href="http://mikefunk.com/console-log-and-internet-explorer/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<h2>The Problem</h2>
<p>I use console.log() in javascript all the time for debugging. It's a great way to display errors without printing them on the screen. Sometimes I forget to delete them all before deploying live code. Come to find out that if even one console.log exists in your javascript, IE will stop dead when they see it and throw a small javascript error. They do not understand console.log unless the F12 developer tools are open.</p>

<p>One thing to keep in mind is that console.log will actually work if you have the IE developer tools window open, even if it's minimized to the bottom of the IE window. It will even work if you open the developer tools and completely close them. So everything will seem fine, but when a customer visits the site in IE7, they will run into errors. (IE7 does not include developer tools but they can be installed as an add-on) This is a huge problem!</p>
<h2>The Solution</h2>
<p>Fortunately solutions exist for this, courtesy of <a title="Arlo Carreon" href="http://www.arlocarreon.com/blog/javascript/how-to-debug-javascript/">Arlo Carreon</a>. You could of course remove all console.log method calls for production code, which you should do. But what if you forget one? That's where this solution comes in. Declare this function at the top of your JS:</p>
<pre class="javascript"><span style="color: #003366; font-weight: bold;">var</span> console = console || <span style="color: #66cc66;">&#123;</span>
    log:<span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span>,
    warn:<span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span>,
    error:<span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>;</pre>
<p>This will replace the console object in IE with empty methods for the usual console commands. No more javascript errors! <strong>I highly recommend you put this at the top of <em>ALL</em> of your custom javascript code.</strong> Now if only Microsoft would patch IE to allow for console.log() to fail silently if developer tools are not open!</p><div id="social-essentials" class="se_left"><div class="se_button se_button_small" style="width:85px;margin:0px 0px 0px 0px"><a href="https://twitter.com/share" class="twitter-share-button" data-url="http://mikefunk.com/console-log-and-internet-explorer/" data-text="console.log() and Internet Explorer" data-via="mikedfunk" data-counturl="http://mikefunk.com/console-log-and-internet-explorer/" data-count="horizontal" data-lang="en">Tweet</a></div><div class="se_button se_button_small" style="width:72px;margin:0px 0px 0px 0px"><iframe src="//www.facebook.com/plugins/like.php?locale=en_US&href=http%3A%2F%2Fmikefunk.com%2Fconsole-log-and-internet-explorer%2F&amp;send=false&amp;layout=button_count&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font" scrolling="no" frameborder="0" allowTransparency="true"></iframe></div><div class="se_button se_button_small" style="width:60px;margin:0px 0px 0px 0px"><g:plusone size="medium" href="http://mikefunk.com/console-log-and-internet-explorer/" count="true"></g:plusone></div></div><div class="clear"></div><style type="text/css">#call_to_action h4{padding:0px 5px;}</style>]]></content:encoded>
			<wfw:commentRss>http://mikefunk.com/console-log-and-internet-explorer/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>New open source CodeIgniter projects</title>
		<link>http://mikefunk.com/new-open-source-codeigniter-projects/</link>
		<comments>http://mikefunk.com/new-open-source-codeigniter-projects/#comments</comments>
		<pubDate>Mon, 27 Feb 2012 00:04:12 +0000</pubDate>
		<dc:creator>mikedfunk</dc:creator>
				<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://mikefunk.com/?p=12</guid>
		<description><![CDATA[I've made some open source projects available on GitHub: CI Alerts - A CodeIgniter package to save and display different types of alerts. It wraps alerts with html based on the type of alert. CI Authentication - A CodeIgniter authentication &#8230; <a href="http://mikefunk.com/new-open-source-codeigniter-projects/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I've made some open source projects available on GitHub:</p>
<p><a href="https://github.com/mikedfunk/CI-Alerts">CI Alerts</a> - A CodeIgniter package to save and display different types of alerts. It wraps alerts with html based on the type of alert.</p>
<p><a href="https://github.com/mikedfunk/CI-Authentication">CI Authentication</a> - A CodeIgniter authentication package for complete authentication management.</p>
<p><a href="https://github.com/mikedfunk/carabiner">Carabiner</a> - a fork of Tony Dewan's Carabiner library. This version also accepts and compiles .less files.</p>
<p><a href="https://github.com/mikedfunk/Base-CodeIgniter-App">Base CodeIgniter App</a> - a preconfigured codeigniter app with some useful submodules such as carabiner, authentication, twitter bootstrap, and PHPUnit.</p>
<p><a href="https://github.com/mikedfunk/bookymark">Bookymark</a> - a sample CodeIgniter app using all of the above libraries, general CodeIgniter best practices, and fully unit tested. Example app is live on <a href="http://bookymark.com">bookymark.com</a>.</p>
<p>I hope this will help you develop CodeIgniter apps more easily!</p>
<div id="social-essentials" class="se_left"><div class="se_button se_button_small" style="width:85px;margin:0px 0px 0px 0px"><a href="https://twitter.com/share" class="twitter-share-button" data-url="http://mikefunk.com/new-open-source-codeigniter-projects/" data-text="New open source CodeIgniter projects" data-via="mikedfunk" data-counturl="http://mikefunk.com/new-open-source-codeigniter-projects/" data-count="horizontal" data-lang="en">Tweet</a></div><div class="se_button se_button_small" style="width:72px;margin:0px 0px 0px 0px"><iframe src="//www.facebook.com/plugins/like.php?locale=en_US&href=http%3A%2F%2Fmikefunk.com%2Fnew-open-source-codeigniter-projects%2F&amp;send=false&amp;layout=button_count&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font" scrolling="no" frameborder="0" allowTransparency="true"></iframe></div><div class="se_button se_button_small" style="width:60px;margin:0px 0px 0px 0px"><g:plusone size="medium" href="http://mikefunk.com/new-open-source-codeigniter-projects/" count="true"></g:plusone></div></div><div class="clear"></div><style type="text/css">#call_to_action h4{padding:0px 5px;}</style>]]></content:encoded>
			<wfw:commentRss>http://mikefunk.com/new-open-source-codeigniter-projects/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Hello world!</title>
		<link>http://mikefunk.com/hello-world/</link>
		<comments>http://mikefunk.com/hello-world/#comments</comments>
		<pubDate>Sat, 25 Feb 2012 18:08:29 +0000</pubDate>
		<dc:creator>mikedfunk</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mikefunk.com/?p=1</guid>
		<description><![CDATA[I've finally taken steps to ditch my 10 year old website and start a development blog. I'll be updating this with useful stuff I find about web development and other cool stuff. Tweet]]></description>
				<content:encoded><![CDATA[<p>I've finally taken steps to ditch my 10 year old website and start a development blog. I'll be updating this with useful stuff I find about web development and other cool stuff.</p>
<div id="social-essentials" class="se_left"><div class="se_button se_button_small" style="width:85px;margin:0px 0px 0px 0px"><a href="https://twitter.com/share" class="twitter-share-button" data-url="http://mikefunk.com/hello-world/" data-text="Hello world!" data-via="mikedfunk" data-counturl="http://mikefunk.com/hello-world/" data-count="horizontal" data-lang="en">Tweet</a></div><div class="se_button se_button_small" style="width:72px;margin:0px 0px 0px 0px"><iframe src="//www.facebook.com/plugins/like.php?locale=en_US&href=http%3A%2F%2Fmikefunk.com%2Fhello-world%2F&amp;send=false&amp;layout=button_count&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font" scrolling="no" frameborder="0" allowTransparency="true"></iframe></div><div class="se_button se_button_small" style="width:60px;margin:0px 0px 0px 0px"><g:plusone size="medium" href="http://mikefunk.com/hello-world/" count="true"></g:plusone></div></div><div class="clear"></div><style type="text/css">#call_to_action h4{padding:0px 5px;}</style>]]></content:encoded>
			<wfw:commentRss>http://mikefunk.com/hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
