<?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>Josh Highland &#187; php</title>
	<atom:link href="http://joshhighland.com/blog/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://joshhighland.com/blog</link>
	<description>the living internet</description>
	<lastBuildDate>Tue, 24 Aug 2010 16:02:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>timthumb.php returns a 404 Error in WordPress</title>
		<link>http://joshhighland.com/blog/2010/05/20/timthumb-php-returns-a-404-error-in-wordpress/</link>
		<comments>http://joshhighland.com/blog/2010/05/20/timthumb-php-returns-a-404-error-in-wordpress/#comments</comments>
		<pubDate>Fri, 21 May 2010 06:00:56 +0000</pubDate>
		<dc:creator>Josh Highland</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[chmod]]></category>
		<category><![CDATA[linux. php]]></category>
		<category><![CDATA[permissions]]></category>
		<category><![CDATA[timthumb]]></category>

		<guid isPermaLink="false">http://joshhighland.com/blog/?p=1199</guid>
		<description><![CDATA[timthumb is a great little php script that helps create thumbnail images (http://code.google.com/p/timthumb). I&#8217;ve used it before, but recently I purchased a wordpress theme that used it, and it wasn&#8217;t working. I would get a 404 error when I tired to access the directly via a url like this: theDomain.com/wp-content/themes/theTheme/scripts/timthumb.php?src=/wp-content/uploads/2010/05/moose1.jpg&#38;h=207&#38;w=237&#38;zc=1&#38;q=80 After some digging around in [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://joshhighland.com/blog/wp-content/uploads/2010/05/create-wordpress-thumbnails-300x300.jpg"><img class="alignleft size-thumbnail wp-image-1200" title="timthumb 404 error in wordpress" src="http://joshhighland.com/blog/wp-content/uploads/2010/05/create-wordpress-thumbnails-300x300-150x150.jpg" alt="" width="150" height="150" /></a>timthumb is a great little php script that helps create thumbnail images (<a href="http://code.google.com/p/timthumb">http://code.google.com/p/timthumb</a>). I&#8217;ve used it before, but recently I purchased a wordpress theme that used it, and it wasn&#8217;t working.</p>
<p>I would get a 404 error when I tired to access the directly via a url like this:<br />
theDomain.com/wp-content/themes/theTheme/scripts/timthumb.php?src=/wp-content/uploads/2010/05/moose1.jpg&amp;h=207&amp;w=237&amp;zc=1&amp;q=80</p>
<p>After some digging around in log files on my server I realized the error</p>
<blockquote><p>SoftException in Application.cpp:610: Directory  “/home/usernamehere/public_html/wp-content” is writable by others</p></blockquote>
<p>My problem had to so with the directory permissions! &#8220;writable by others&#8221; means that the permission on the directory were set to &#8220;777&#8243;. I changed the permissions of the directory using chmod to 755, and everything started to work.</p>
<p>Lesson learned, if timthumb.php is not working at giving you 404 errors, check the permission of the directory that contains the php file.</p>
]]></content:encoded>
			<wfw:commentRss>http://joshhighland.com/blog/2010/05/20/timthumb-php-returns-a-404-error-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Removing trailing comas with PHP</title>
		<link>http://joshhighland.com/blog/2009/11/02/removing-trailing-comas-with-php/</link>
		<comments>http://joshhighland.com/blog/2009/11/02/removing-trailing-comas-with-php/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 22:30:56 +0000</pubDate>
		<dc:creator>Josh Highland</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[regexp]]></category>
		<category><![CDATA[regular expression]]></category>

		<guid isPermaLink="false">http://joshhighland.com/blog/?p=940</guid>
		<description><![CDATA[Dealing with trailing comas in lists is common problem for developers. I found the best way to handle this situation in PHP is with the following regular expression. $string = eregi_replace&#40;',$', '', $string&#41;; Before: string = &#8220;2, 6, 9,&#8221; After: string = &#8220;2, 6, 9&#8243; Only the trailing coma will be stripped. If no coma [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-939" title="php_logo_medium" src="http://joshhighland.com/blog/wp-content/uploads/2009/11/php_logo_medium.jpg" alt="php_logo_medium" width="200" height="108" />Dealing with trailing comas in lists is common problem for developers. I found the best way to handle this situation in PHP is with the following regular expression.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #990000;">eregi_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">',$'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>Before:</strong> string = &#8220;2, 6, 9,&#8221;<strong><br />
After:</strong> string = &#8220;2, 6, 9&#8243;</p>
<p>Only the trailing coma will be stripped. If no coma is found, the string simply passes through. It&#8217;s a simple and effective solution.</p>
]]></content:encoded>
			<wfw:commentRss>http://joshhighland.com/blog/2009/11/02/removing-trailing-comas-with-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Create WordPress Thumbnails Automatically</title>
		<link>http://joshhighland.com/blog/2009/09/29/create-wordpress-thumbnails-automatically/</link>
		<comments>http://joshhighland.com/blog/2009/09/29/create-wordpress-thumbnails-automatically/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 00:19:29 +0000</pubDate>
		<dc:creator>Josh Highland</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[automatically]]></category>
		<category><![CDATA[custom fields]]></category>
		<category><![CDATA[premium theme]]></category>
		<category><![CDATA[thumbnail]]></category>
		<category><![CDATA[timthumb]]></category>

		<guid isPermaLink="false">http://joshhighland.com/blog/?p=887</guid>
		<description><![CDATA[WordPress has the ability to allow post authors to assign custom fields to a post. This arbitrary extra information is known as meta-data. This meta-data can be used by theme authors to do some pretty cool things. The theme I am currently using allows for a custom field named &#8220;thumb&#8221;. If you create the &#8220;thumb&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-medium wp-image-890" title="create wordpress thumbnails automatically" src="http://joshhighland.com/blog/wp-content/uploads/2009/09/create-wordpress-thumbnails-300x300.jpg" alt="create wordpress thumbnails automatically" width="300" height="300" />WordPress has the ability to allow post authors to assign custom fields to a post. This arbitrary extra information is known as meta-data. This meta-data can be used by theme authors to do some pretty cool things.</p>
<p>The <a href="http://www.studiopress.com/themes/church">theme</a> I am currently using allows for a custom field named &#8220;thumb&#8221;. If you create the &#8220;thumb&#8221; custom field in a post and pass in the path to an image, for example &#8220;wp-content/uploads/2008/12/wordpress_logo.png&#8221;, a thumb nail version of the image will appear next the posts title on the home page of my blog. Awesome stuff.</p>
<p>When I discovered this theme and the &#8220;thumb&#8221; custom field, I already had 225 posts in my blog. I didn&#8217;t want to go back and manually create all the custom fields for the existing posts, so I wrote a PHP script to do it for me.</p>
<p>The PHP script cycles through your existing posts and looks for the first image in the post, and creates the thumb field based on it&#8217;s location. The script is configurable, your theme may want a different custom field name, like &#8220;thumbnail&#8221; or &#8220;image&#8221;.</p>
<p>This code is provided as is. If you aren&#8217;t a developer, you should be messing with stuff like this. Be sure to <a href="http://wordpress.org/extend/plugins/wp-db-backup/">back up your wordpress database</a> before running this.</p>
<p><strong>Instruction:<br />
</strong></p>
<ul>
<li>download this code</li>
<li>configure the database connection info and custom field name</li>
<li>upload this code onto your server</li>
<li>point your browser to the file</li>
<li>watch the script do it&#8217;s magic</li>
<li>remove the file from your server</li>
<li><a href="https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&amp;content_ID=marketing_us/send_money" target="_blank">donate $2 to my paypal account</a> (joshhighland@gmail.com)</li>
</ul>
<p><strong>Note:</strong> This is a one time deal, when you create new posts you will need to add the &#8220;thumb&#8221; field and image path manually</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//your database configuration information</span>
<span style="color: #000088;">$username</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;YOUR_USER_NAME&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$password</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;YOUR_PASSWORD&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$database</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;DATABASE&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$databaseLocation</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;localhost&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//name of the Custom Field to use</span>
<span style="color: #000088;">$customFieldName</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;thumb&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/******************* END CONFIGURATION *****************************/</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//get the wordpress posts to work with</span>
<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT * FROM wp_posts&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$mysqli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$query</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">//loop over all the posts</span>
	<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$result</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetch_object</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//get all the info from the post that we need to work with</span>
		<span style="color: #000088;">$cur_post_id</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$cur_post_content</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_content</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//the pattern to find the html image tag</span>
		<span style="color: #000088;">$pattern</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/]+src[\\s=\'&quot;]'</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$pattern</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'+([^&quot;\'&gt;\\s]+)/is'</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//try to match the pattern against the post content</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pattern</span><span style="color: #339933;">,</span><span style="color: #000088;">$cur_post_content</span><span style="color: #339933;">,</span><span style="color: #000088;">$match</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">//break up the image path</span>
			<span style="color: #000088;">$pieces</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;wp-content/&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$match</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #666666; font-style: italic;">//make sure the file name isnt empty</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pieces</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #666666; font-style: italic;">//build the file path</span>
				<span style="color: #000088;">$imagePath</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;wp-content/&quot;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$pieces[1]</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #666666; font-style: italic;">//insert the custom field for the post</span>
				<span style="color: #000088;">$insertQuery</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;INSERT INTO wp_postmeta (post_id, meta_key, meta_value) VALUES (<span style="color: #006699; font-weight: bold;">$cur_post_id</span>, '<span style="color: #006699; font-weight: bold;">$customFieldName</span>', '<span style="color: #006699; font-weight: bold;">$imagePath</span>')&quot;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #000088;">$mysqli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$insertQuery</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #666666; font-style: italic;">//debugging stuff</span>
&nbsp;
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$mysqli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">errno</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #990000;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;failed: <span style="color: #009933; font-weight: bold;">%s</span> <span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$mysqli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">error</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #b1b100;">else</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;..... inserting <span style="color: #006699; font-weight: bold;">$imagePath</span> <span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #990000;">flush</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;---completed---&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://joshhighland.com/blog/2009/09/29/create-wordpress-thumbnails-automatically/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>phpBB admin password manual reset</title>
		<link>http://joshhighland.com/blog/2009/03/31/phpbb-admin-password-manual-reset/</link>
		<comments>http://joshhighland.com/blog/2009/03/31/phpbb-admin-password-manual-reset/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 07:51:36 +0000</pubDate>
		<dc:creator>Josh Highland</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[semi-legal]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://joshhighland.com/blog/?p=607</guid>
		<description><![CDATA[Today I ran into a situation where I had forgotten the password to my development instance of phpBB 3. I was stuck in a situation were I needed to reset the password. I had full admin access to the database, so changing it there wouldn&#8217;t be the problem. The real problem is that phpBB uses [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-606" title="phpbb_logo" src="http://joshhighland.com/blog/wp-content/uploads/2009/03/phpbb_logo.jpg" alt="phpbb_logo" width="206" height="158" /></p>
<p>Today I ran into a situation where I had forgotten the password to my development instance of <a href="http://www.phpbb.com">phpBB</a> 3. I was stuck in a situation were I needed to reset the password. I had full admin access to the database, so changing it there wouldn&#8217;t be the problem. The real problem is that phpBB uses its own password hashing, not MD5.</p>
<p>In a work around, I created a new user and used the password &#8220;123456&#8243; looking at the database , in the users table of the phpBB install. I saw the &#8220;user_password&#8221; field was &#8220;e10adc3949ba59abbe56e057f20f883e&#8221;.</p>
<p>I then changed my admin accounts user to the same string, &#8220;e10adc3949ba59abbe56e057f20f883e&#8221;.</p>
<p><a href="http://joshhighland.com/blog/wp-content/uploads/2009/03/phpbbpasswordreset.gif"><img class="alignnone size-full wp-image-608" title="phpbbpasswordreset" src="http://joshhighland.com/blog/wp-content/uploads/2009/03/phpbbpasswordreset.gif" alt="phpbbpasswordreset" width="536" height="66" /></a></p>
<p>I went to the phpBB login screen, fillled out my username, and entered the password &#8220;123456&#8243;&#8230; BINGO! it worked.</p>
<p>So to save you the work. You can follow what I did or just use these hashes to reset your own password:</p>
<p><strong>Hash:</strong> e10adc3949ba59abbe56e057f20f883e<br />
<strong>Password:</strong> 123456</p>
<p><strong>Hash:</strong> $H$9Ae3Uk.ECdWW5ya13M4ErWhr4c.761/<br />
<strong>Password:</strong> password</p>
<p>I hope this helps someone else out there.</p>
]]></content:encoded>
			<wfw:commentRss>http://joshhighland.com/blog/2009/03/31/phpbb-admin-password-manual-reset/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Modifying MimboPro to Add Paged Navigation To Category Pages</title>
		<link>http://joshhighland.com/blog/2008/12/08/modifying-mimbopro-to-add-paged-navigation-to-category-pages/</link>
		<comments>http://joshhighland.com/blog/2008/12/08/modifying-mimbopro-to-add-paged-navigation-to-category-pages/#comments</comments>
		<pubDate>Tue, 09 Dec 2008 02:39:55 +0000</pubDate>
		<dc:creator>Josh Highland</dc:creator>
				<category><![CDATA[hacks]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[web 2.0]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[MimboPro]]></category>

		<guid isPermaLink="false">http://joshhighland.com/blog/?p=453</guid>
		<description><![CDATA[Recently I have been doing a lot of work with WordPress. I love WordPress. one of the things I like most about WordPress is the plugins and themes. I recently bought a copy of the MimboPro theme. Mimbo is clean and very professional. More of a CMS theme then a blogging theme, prefect for what [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-462" title="mimbologo" src="http://joshhighland.com/blog/wp-content/uploads/2008/12/mimbologo.jpg" alt="" width="240" height="100" /></p>
<p>Recently I have been doing a lot of work with WordPress. I love WordPress. one of the things I like most about WordPress is the plugins and themes.</p>
<p>I recently bought a copy of the <a href="http://prothemedesign.com/themes/mimbo-pro/">MimboPro theme</a>. Mimbo is clean and very professional. More of a CMS theme then a blogging theme, prefect for what I want to use it for.</p>
<p>As I dug into MimboPro and WordPress, I realized something strange, the MimboPro theme doesn&#8217;t support paging in a category view. What this means is EVERY SINGLE post you make is shown on one page. If you have a very active site, like the one I&#8217;m working on, this quickly gets out of hand. Look at this image and you will see what I mean (click for full version).</p>
<p><a href="http://joshhighland.com/blog/wp-content/uploads/2008/12/prehack.gif"><img class="alignnone size-medium wp-image-454" title="prehack" src="http://joshhighland.com/blog/wp-content/uploads/2008/12/prehack-111x300.gif" alt="" width="111" height="300" /></a></p>
<p>One of the reasons I like MimboPro was the support that the authors of the theme offer. I headed over to their message forums and found other people like me asking for the <a href="http://forum.prothemedesign.com/topic/adding-paged-navigation-to-category-page">Additon of Paged Navigation To Category Pages</a>. The original post was 8 months ago, and no one had resolved anything. I made a post to the MimboPro authors only to be told that there is going to be a new theme that will handle this and it will be available at a deep discount to MimboPro owner. This upset me a bit, so taking matters into my own hand, I fixed what Mimbo wont, and I am handing out my own patch to solve this issue. Below are the instructions to hack your own files, or you can just download my zip file with the pre-hacked files.</p>
<p><strong>Pre-Hacked Files:</strong><br />
Download with pre-hacked files: <a href="http://joshhighland.com/blog/wp-content/uploads/2008/12/joshhighlands_mimbopro_categorypaginghack.zip">JoshHighlands_MimboPro_CategoryPagingHack.zip</a></p>
<p><strong>DIY INSTRUCTIONS</strong> (click images for full sizes):</p>
<ol>
<li>Save a copy of your current categories.php and styles.css files inside of the MimboPro theme directory to a safe location</li>
<li>Open up categories.php inside of the MimboPro theme directory, and find line 17<br />
<a href="http://joshhighland.com/blog/wp-content/uploads/2008/12/mimbohack1.gif"><img class="alignnone size-full wp-image-455" title="mimbohack1" src="http://joshhighland.com/blog/wp-content/uploads/2008/12/mimbohack1.gif" alt="" width="500" height="133" /></a></li>
<li>Comment line 17 with a double back slash (//)<br />
<a href="http://joshhighland.com/blog/wp-content/uploads/2008/12/mimbohack2.gif"><img class="alignnone size-full wp-image-456" title="mimbohack2" src="http://joshhighland.com/blog/wp-content/uploads/2008/12/mimbohack2.gif" alt="" width="500" height="183" /></a></li>
<li>Go to line 87 of category.php and add the following code<br />
<a href="http://joshhighland.com/blog/wp-content/uploads/2008/12/mimbohack3.gif"><img class="alignnone size-medium wp-image-457" title="mimbohack3" src="http://joshhighland.com/blog/wp-content/uploads/2008/12/mimbohack3-300x68.gif" alt="" width="300" height="68" /></a></li>
<li>Save and close category.php</li>
<li>Open up style.css inside of the MimboPro theme directory</li>
<li>Add the following CSS code to the bottom of the file (should be close to line 852)<br />
<a href="http://joshhighland.com/blog/wp-content/uploads/2008/12/minbohack4.gif"><img class="alignnone size-full wp-image-458" title="minbohack4" src="http://joshhighland.com/blog/wp-content/uploads/2008/12/minbohack4.gif" alt="" width="351" height="192" /></a></li>
<li>Save styles.css</li>
<li>Upload categories.php and styles.css to the MimboPro theme directory on your server</li>
<li>Everything should be working. Here is what my wordpress running MimboPro looks like<br />
<a href="http://joshhighland.com/blog/wp-content/uploads/2008/12/posthack.gif"><img class="alignnone size-medium wp-image-459" title="posthack" src="http://joshhighland.com/blog/wp-content/uploads/2008/12/posthack-220x300.gif" alt="" width="220" height="300" /></a></li>
</ol>
<p>That&#8217;s it! MimboPro will now have paging in all of the categories. The next and previous links will only show up when you have enough posts. The WordPress default is 10 posts. You can edit the number of posts by going to change the number of posts to show on a category page, go into to the admin and under &#8220;setting&#8221; &gt; &#8220;reading&#8221; you will find the option, as highlighted here.<br />
<a href="http://joshhighland.com/blog/wp-content/uploads/2008/12/admin.gif"><img class="alignnone size-medium wp-image-461" title="admin" src="http://joshhighland.com/blog/wp-content/uploads/2008/12/admin-252x300.gif" alt="" width="252" height="300" /></a></p>
<p>If you had any problem reading the code in the image files, download the zip files with the pre-hacked files in them.</p>
<p>Download with pre-hacked files: <a href="http://joshhighland.com/blog/wp-content/uploads/2008/12/joshhighlands_mimbopro_categorypaginghack.zip">JoshHighlands_MimboPro_CategoryPagingHack.zip</a></p>
<p>If you have any further questions, please post them in the comment.<br />
<a href="http://joshhighland.com/blog/wp-content/uploads/2008/12/joshhighlands_mimbopro_categorypaginghack.zip"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://joshhighland.com/blog/2008/12/08/modifying-mimbopro-to-add-paged-navigation-to-category-pages/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>WordPress 2.7 is almost here!</title>
		<link>http://joshhighland.com/blog/2008/12/03/wordpress-27-is-almost-here/</link>
		<comments>http://joshhighland.com/blog/2008/12/03/wordpress-27-is-almost-here/#comments</comments>
		<pubDate>Thu, 04 Dec 2008 05:09:56 +0000</pubDate>
		<dc:creator>Josh Highland</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[web 2.0]]></category>

		<guid isPermaLink="false">http://joshhighland.com/blog/?p=450</guid>
		<description><![CDATA[OMG OMG OMG! WordPress 2.7 is almost here. Here is a long list of the changes that are going to be in the latest release. I have been a huge wordpress fan for some years now. Its always treated me well. Its treated me so well that I have decided to move my main website, [...]]]></description>
			<content:encoded><![CDATA[<p><img class="size-medium wp-image-449 alignnone" title="wordpress_logo" src="http://joshhighland.com/blog/wp-content/uploads/2008/12/wordpress_logo.png" alt="" width="280" height="280" />OMG OMG OMG! WordPress 2.7 is almost here. <a href="http://en.blog.wordpress.com/2008/12/03/27-gets-here-in-two-days/">Here is a long list of the changes</a> that are going to be in the latest release. I have been a huge wordpress fan for some years now. Its always treated me well. Its treated me so well that I have decided to move my main website, <a href="http://notpopular.com">notPopular.com</a>, to the wordpress platform for content management. I&#8217;m really nervous though, I have done a lot of custom work on the notpop install of wordpress, and it isnt released yet. I hope that my plugins and custom code doesnt break to badly. I will have a full review of wordpress 2.7 once it is released later this week.</p>
]]></content:encoded>
			<wfw:commentRss>http://joshhighland.com/blog/2008/12/03/wordpress-27-is-almost-here/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How I do layouts and views in CodeIgniter</title>
		<link>http://joshhighland.com/blog/2008/11/09/how-i-do-layouts-and-views-in-codeigniter/</link>
		<comments>http://joshhighland.com/blog/2008/11/09/how-i-do-layouts-and-views-in-codeigniter/#comments</comments>
		<pubDate>Mon, 10 Nov 2008 03:07:53 +0000</pubDate>
		<dc:creator>Josh Highland</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://joshhighland.com/blog/?p=445</guid>
		<description><![CDATA[I have been a loyal fan of the kick-ass php framework, codeIgniter, for some time now. A while back I made a post on how to improve the view handling of codeIgniter. I would like to retract that post. Through the comments on that post I found out about an undocumented parameter (as of version [...]]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-443 alignleft" title="codeigniter_logo" src="http://joshhighland.com/blog/wp-content/uploads/2008/11/codeigniter_logo.jpg" alt="" width="91" height="101" />I have been a loyal fan of the kick-ass php framework, codeIgniter, for some time now. A while back I made a post on <a href="http://joshhighland.com/blog/2008/04/29/improving-codeigniters-view-handling/">how to improve the view handling of codeIgniter</a>. I would like to retract that post. Through the comments on that post I found out about an undocumented parameter (as of version 1.7, it has been <a href="http://codeigniter.com/user_guide/general/views.html">documented</a>) that allows view to be rendered into a variable. This changes everything, and totally negates any of the complaint I had about how CI handles layouts and views.</p>
<p>Below is an example of live code I have running at <a href="http://loudson.gs">loudson.gs</a>. It shows how I have been able to take advantage of of this powerful third parameter that stops CI from rendering a view to the screen when loading it.</p>
<p><strong>&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;<br />
</strong><strong>Inside of my controller</strong></p>
<p>function index()<br />
{<br />
$base_url = base_url();</p>
<p>//what the nav needs<br />
$navigation_data['navTab'] = &#8220;home&#8221;;</p>
<p>//basic info for the header<br />
$layout_data['pageTitle'] = &#8220;LoudSon.gs&#8221;;<br />
$layout_data['meta_description'] = &#8220;Under Ground Lyrics, hardcore, metal, emo, rock&#8221;;<br />
$layout_data['meta_keywords'] = &#8220;lyrics,song,songs,words,hardore,metal,emo,rock&#8221;;<br />
$layout_data['meta_url'] = &#8220;$base_url&#8221;;<br />
$layout_data['meta_classification'] = &#8220;home&#8221;;<br />
$layout_data['searchInput'] = &#8220;&#8221;;<br />
$layout_data['searchOptions'] = &#8220;&#8221;;</p>
<p>$this-&gt;load-&gt;model(&#8216;search&#8217;);<br />
$lastest_albums = $this-&gt;search-&gt;last_n_albumsAdded(10);<br />
$popular_songs = $this-&gt;search-&gt;popular_n_songs(10);</p>
<p>//get the featured Albums<br />
$featuredAlbums = $this-&gt;search-&gt;getFeaturedAlbums();</p>
<p>$body_data['featured'] = $featuredAlbums;<br />
$body_data['newest'] = $lastest_albums;<br />
$body_data['popular'] = $popular_songs;</p>
<p>//load the content variables<br />
$layout_data['content_navigation'] = $this-&gt;load-&gt;view(&#8216;navigation&#8217;, $navigation_data, true);<br />
$layout_data['content_body'] = $this-&gt;load-&gt;view(&#8216;home/homePage&#8217;, $body_data, true);</p>
<p>$this-&gt;load-&gt;view(&#8216;layouts/main&#8217;, $layout_data);<br />
}</p>
<p><strong>&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;</strong><br />
<strong>/views/navigation.php</strong></p>
<p>&lt;div id=&#8221;header&#8221;&gt;<br />
&lt;h1 title=&#8221;Loud Songs Logo&#8221;&gt;LoudSongs search &#8211; hard to find obscure lyrics&lt;/h1&gt;</p>
<p>&lt;ul title=&#8221;navigation&#8221;&gt;<br />
&lt;li &lt;? if($navTab == &#8220;about&#8221;){echo &#8221; id=\&#8221;active\&#8221;";}?&gt;&gt;&lt;a href=&#8221;&lt;?= base_url(); ?&gt;about&#8221; title=&#8221;About Page&#8221;&gt;About&lt;/a&gt;&lt;/li&gt;<br />
&lt;li &lt;? if($navTab == &#8220;add&#8221;){echo &#8221; id=\&#8221;active\&#8221;";}?&gt;&gt;&lt;a href=&#8221;&lt;?= base_url(); ?&gt;add&#8221; title=&#8221;Add Lyrics&#8221;&gt;Add Lyrics&lt;/a&gt;&lt;/li&gt;<br />
&lt;li &lt;? if($navTab == &#8220;home&#8221;){echo &#8221; id=\&#8221;active\&#8221;";}?&gt;&gt;&lt;a href=&#8221;&lt;?= base_url(); ?&gt;&#8221; title=&#8221;Home Page&#8221;&gt;Home&lt;/a&gt;&lt;/li&gt;<br />
&lt;/ul&gt;<br />
&lt;/div&gt;</p>
<p><strong>&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;</strong><br />
<strong>/views/home/homePage.php</strong></p>
<p>&lt;div&gt;<br />
Thanks for visiting LoudSongs<br />
&lt;br/&gt;<br />
We are trying to build a maintain a collection of punk rock, hardcore, emo, metal and other lyrics.<br />
This website is free and open to all.<br />
Please help us by &lt;a href=&#8221;http://www.LoudSon.gs/add&#8221;&gt;contributing to the collection&lt;/a&gt;.<br />
&lt;/div&gt;</p>
<p>&lt;div&gt;<br />
&lt;? $this-&gt;load-&gt;view(&#8216;home/featuredAlbums&#8217;); ?&gt;<br />
&lt;/div&gt;</p>
<p>&lt;div class=&#8221;middle_col_split&#8221;&gt;<br />
&lt;? $this-&gt;load-&gt;view(&#8216;home/recentlyAdded&#8217;); ?&gt;<br />
&lt;/div&gt;</p>
<p>&lt;div class=&#8221;middle_col_split&#8221;&gt;<br />
&lt;? $this-&gt;load-&gt;view(&#8216;home/mostPopularSongs&#8217;); ?&gt;<br />
&lt;/div&gt;</p>
<p><strong>&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;</strong><br />
<strong>/views/layouts/main.php</strong></p>
<p>&lt;!DOCTYPE html PUBLIC &#8220;-//W3C//DTD XHTML 1.0 Strict//EN&#8221; &#8220;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&#8221;&gt;<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;meta http-equiv=&#8221;Content-Type&#8221; content=&#8221;text/html;charset=us-ascii&#8221;&gt;<br />
&lt;meta name=&#8221;description&#8221; content=&#8221;&lt;?= $meta_description ?&gt;&#8221;&gt;<br />
&lt;meta name=&#8221;keywords&#8221; content=&#8221;&lt;?= $meta_keywords ?&gt;&#8221;&gt;<br />
&lt;meta http-equiv=&#8221;expires&#8221; content=&#8221;0&#8243; /&gt;<br />
&lt;meta name=&#8221;classification&#8221; content=&#8221;&lt;?= $meta_classification ?&gt;&#8221; /&gt;<br />
&lt;meta name=&#8221;Robots&#8221; content=&#8221;index,follow&#8221;&gt;<br />
&lt;meta name=&#8221;revisit-after&#8221; content=&#8221;2 Days&#8221;&gt;<br />
&lt;meta name=&#8221;language&#8221; content=&#8221;en-us&#8221;&gt;</p>
<p>&lt;link href=&#8221;&lt;?= base_url() ?&gt;includes/styles/lyrics.css&#8221; rel=&#8221;stylesheet&#8221; type=&#8221;text/css&#8221; media=&#8221;screen&#8221; title=&#8221;default&#8221;&gt;</p>
<p>&lt;script language=&#8221;javascript&#8221; type=&#8221;text/javascript&#8221; src=&#8221;&lt;?= base_url() ?&gt;includes/scripts/jquery-1.2.6.min.js&#8221;&gt;&lt;/script&gt;</p>
<p>&lt;title&gt;&lt;?= $pageTitle ?&gt;&lt;/title&gt;<br />
&lt;/head&gt;</p>
<p>&lt;body id=&#8221;home&#8221;&gt;<br />
&lt;div id=&#8221;nav&#8221;&gt;<br />
&lt;?= $content_navigation; ?&gt;<br />
&lt;/div&gt;</p>
<p>&lt;div id=&#8221;middle_column&#8221;&gt;</p>
<p>&lt;?= $content_body ?&gt;</p>
<p>&lt;/div&gt;<br />
&lt;/body&gt;</p>
<p>&lt;/html&gt;</p>
<p><strong>&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;</strong></p>
<p>wow, ok, so that might be a lot to digest. The bottom line is this, CI doesnt have &#8220;layouts&#8221; like other frameworks, so you have to become creative and use a view AS a layout by using the mythical 3rd parameter when loading a view. We load data into the navigation view and store all of that into the $layout_data array, then we load a view named homePage and pass data into it, and stor it into the $layout_data array. When we are done loading all of the views into the array, we pass that array into another view. This view acts as our layout. easy as that! check it out below:</p>
<p>//load the content variables<br />
$layout_data['content_navigation'] = $this-&gt;load-&gt;view(&#8216;navigation&#8217;, $navigation_data, true);<br />
$layout_data['content_body'] = $this-&gt;load-&gt;view(&#8216;home/homePage&#8217;, $body_data, true);</p>
<p>$this-&gt;load-&gt;view(&#8216;layouts/main&#8217;, $layout_data);</p>
<p>I hope this helps someone understand how codeigniter does have layout and view functionality, you just have to structure it that way in your code.</p>
<p>post some comments if you need more clarification.</p>
]]></content:encoded>
			<wfw:commentRss>http://joshhighland.com/blog/2008/11/09/how-i-do-layouts-and-views-in-codeigniter/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>php sprintf + sql like</title>
		<link>http://joshhighland.com/blog/2008/07/06/php-sprintf-sql-like/</link>
		<comments>http://joshhighland.com/blog/2008/07/06/php-sprintf-sql-like/#comments</comments>
		<pubDate>Sun, 06 Jul 2008 19:13:08 +0000</pubDate>
		<dc:creator>Josh Highland</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://joshhighland.com/blog/?p=297</guid>
		<description><![CDATA[Sometimes I do my best programming when I&#8217;m tired. Don&#8217;t ask me why, I just do. It&#8217;s a skill I picked up in college. Being tired and producing good code wasn&#8217;t the case last night. I was trying to use the sprintf PHP function with a SQL &#8220;Like&#8221; statement. I made some dumb mistakes that [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://joshhighland.com/blog/wp-content/uploads/2008/07/php_mysql_logo.jpg"><img class="alignnone size-medium wp-image-296" title="php and mysql" src="http://joshhighland.com/blog/wp-content/uploads/2008/07/php_mysql_logo.jpg" alt="" width="300" height="161" /></a></p>
<p>Sometimes I do my best programming when I&#8217;m tired. Don&#8217;t ask me why, I just do. It&#8217;s a skill I picked up in college.</p>
<p>Being tired and producing good code wasn&#8217;t the case last night. I was trying to use the sprintf PHP function with a SQL &#8220;Like&#8221; statement. I made some dumb mistakes that tripped me up for a while. Hopefully someone out there will find this post and help them not make the problems I made, sleepy or not!</p>
<p>Normally the LIKE is used in mysql like this:<strong><br />
<code>SELECT name FROM users WHERE name LIKE 'J%';</code></strong></p>
<p>That would get all names including: Josh, Jason, Jimi, etc.<br />
In a SQL Like statement the % is a wild card, so the command is to match everything starting with &#8220;J&#8221;</p>
<p>Now when you use the sprintf() function it looks kind like this:<br />
<strong><code>$query = sprintf("SELECT name FROM users WHERE name='%s'", $searchString);</code></strong><br />
The %s will be replaced with the value of $searchString</p>
<p>Trying to combined them is where I had some problems&#8230;.</p>
<p>At first I tried to do something like this:<br />
<code><strong>$query = sprintf("SELECT name FROM users WHERE name LIKE'%s'", $searchString);</strong><br />
</code>didnt return what I was looking for at all, it had no wild cards in it!</p>
<p>Then I tried this:<br />
<strong><code>$query = sprintf("SELECT name FROM users WHERE name LIKE'%s%'", $searchString);</code></strong><br />
didnt work either, this time it threw errors</p>
<p>But this worked great<strong><code><br />
$query =</code></strong><strong><code>sprintf("SELECT name FROM users WHERE name LIKE '%s'", $searchString . "%")</code>;</strong></p>
<p>So the moral of the story is, if you want to use a SQL Like statement, appent the wildcard for the Like statement to the string to be inserted by the sprintf funtion.</p>
]]></content:encoded>
			<wfw:commentRss>http://joshhighland.com/blog/2008/07/06/php-sprintf-sql-like/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Improving CodeIgniters View Handling</title>
		<link>http://joshhighland.com/blog/2008/04/29/improving-codeigniters-view-handling/</link>
		<comments>http://joshhighland.com/blog/2008/04/29/improving-codeigniters-view-handling/#comments</comments>
		<pubDate>Wed, 30 Apr 2008 00:43:11 +0000</pubDate>
		<dc:creator>Josh Highland</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://joshhighland.com/blog/?p=279</guid>
		<description><![CDATA[If you have ever worked with an MVC framework for web developent, you know that the &#8220;V&#8221; stands for &#8220;view&#8221;. At work, I program in coldfusion, and use the coldbox framework, and I love it. At home, I write PHP code, with the codeigniter framework. I love codeigniter, but I think that its biggest weakness [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-278" title="codeigniter_logo" src="http://joshhighland.com/blog/wp-content/uploads/2008/04/codeigniter_logo.jpg" alt="codeigniter logo" width="91" height="101" /></p>
<p>If you have ever worked with an MVC framework for web developent, you know that the &#8220;V&#8221; stands for &#8220;view&#8221;.</p>
<p>At work, I program in coldfusion, and use the <a href="http://coldboxframework.com/">coldbox framework</a>, and I love it. At home, I write PHP code, with the <a href="http://codeigniter.com">codeigniter framework</a>.</p>
<p>I love codeigniter, but I think that its biggest weakness is the <a href="http://codeigniter.com/user_guide/general/views.html">view handeling</a>, all thought codeigniter had taken strides to improve it. At the time of writing this, codeigniter is at version 1.6.1, and allows multiple views to be loaded at one time.</p>
<p>example:</p>
<p><code><br />
&lt;?php</code></p>
<p>class Page extends Controller {</p>
<p>function index()<br />
{<br />
$data['page_title'] = &#8216;Your title&#8217;;<br />
$this-&gt;load-&gt;view(&#8216;header&#8217;);<br />
$this-&gt;load-&gt;view(&#8216;menu&#8217;);<br />
$this-&gt;load-&gt;view(&#8216;content&#8217;, $data);<br />
$this-&gt;load-&gt;view(&#8216;footer&#8217;);<br />
}</p>
<p>}<br />
?&gt;</p>
<p>This is great with one exception, codeigniter simple builds a stack of the view results, appending them to each other.</p>
<p>This means that in header.php, loaded at the start of the view sequence, we would have to opening tags, such as &lt;body&gt;, and then in the last view, footer, we have to close the tags we opened in header.php, in this case, &lt;/body&gt;</p>
<p>I don&#8217;t know about you, but opening tags in open file, and depending on another file to close them is not a good practice. Using a MVC setup and then doing something like this is very counter intuitive.</p>
<p>To fix this, codeigniter needs to support layouts, as well as views.</p>
<p>A layout is a file that contains the framework for a page, and the views are included and rendered inside the layout. basically filling out the content of the page. This also leaves your code the ability to be more flexible. Your views are pluggable components that don&#8217;t care about the layout at all.</p>
<p>One of the reasons I love open source software is the fact that the community will fix weaknesses is the software. Looking at the <a href="http://www.codeigniter.com/wiki">codeigniter wiki</a>, I came across the <a href="http://codeigniter.com/wiki/View_Object/">&#8220;view object&#8221; (http://codeigniter.com/wiki/View_Object/)</a></p>
<p>The view object is a great solution for adding layouts to the codeigniter framework.<br />
Here is a code sample of how to use the view object in a controller:<br />
<code><br />
$this-&gt;load-&gt;library('view');         // or autoload</code></p>
<p>$this-&gt;view-&gt;layout = &#8216;admin/layout&#8217;;</p>
<p>$this-&gt;view-&gt;data(array(              // set the view data<br />
&#8216;privileges&#8217; =&gt; $privileges,<br />
&#8216;catcode&#8217;    =&gt; -1,<br />
&#8216;page&#8217;       =&gt; $page,<br />
));</p>
<p>$this-&gt;view-&gt;load(array(             // load the page partials<br />
&#8216;header&#8217;     =&gt; &#8216;header&#8217;,<br />
&#8216;menu&#8217;       =&gt; &#8216;menu&#8217;,<br />
&#8216;content&#8217;    =&gt; &#8216;admin/&#8217;.$page,<br />
&#8216;footer&#8217;     =&gt; &#8216;footer&#8217;,<br />
));</p>
<p>$this-&gt;view-&gt;render();               // create the view or</p>
<p>inside the layout file (admin/layout.php)</p>
<p><code><br />
&lt;? $header-&gt;render(); ?&gt;</code></p>
<p>&lt;body&gt;<br />
&lt;? $menu-&gt;render(); ?&gt;<br />
&lt;div id=&#8221;mainContent&#8221;&gt;<br />
&lt;? $content-&gt;render(); ?&gt;<br />
&lt;/div&gt;<br />
&lt;/body&gt;</p>
<p>&lt;? $footer-&gt;render(); ?&gt;</p>
<p>You can see that the layout file contains the framework of the page, freeing up the views to be individual pluggable items that can be used across your codeigniter application.</p>
<p>I hope that the codeigniter team takes note of the view object and adds it to the core for codeignier 1.7 or maybe even sooner!</p>
]]></content:encoded>
			<wfw:commentRss>http://joshhighland.com/blog/2008/04/29/improving-codeigniters-view-handling/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>LifeStreaming Is Simple As Pie</title>
		<link>http://joshhighland.com/blog/2008/04/19/lifestreaming-is-simple-as-pie/</link>
		<comments>http://joshhighland.com/blog/2008/04/19/lifestreaming-is-simple-as-pie/#comments</comments>
		<pubDate>Sat, 19 Apr 2008 19:04:46 +0000</pubDate>
		<dc:creator>Josh Highland</dc:creator>
				<category><![CDATA[Josh's Rambling]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[web 2.0]]></category>

		<guid isPermaLink="false">http://joshhighland.com/blog/?p=277</guid>
		<description><![CDATA[Its not secret, I love social networking, I cant get enough of it. I also love programming and anything internet related. I&#8217;m not sure how I came across it, but a PHP based, Object Oriented RSS caching tool named SimplePie caught my attention. Previously I had been using a tool called Last RSS, but I [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-276" title="my lifestream" src="http://joshhighland.com/blog/wp-content/uploads/2008/04/lifestream.gif" alt="" width="486" height="327" /></p>
<p>Its not secret, I love social networking, I cant get enough of it. I also love programming and anything internet related.</p>
<p>I&#8217;m not sure how I came across it, but a PHP based, Object Oriented RSS caching tool named <a href="http://simplepie.org">SimplePie</a> caught my attention.</p>
<p>Previously I had been using a tool called <a href="http://lastrss.oslab.net">Last RSS</a>, but I found that <a href="http://lastrss.oslab.net">Last RSS</a> could not handle ATOM feeds.</p>
<p>Digging into how <a href="http://simplepie.org">SimplePie</a> works, I found that I could merge several feeds together, sorted by post time, my first thought was to use this to aggregate and cache all the different music related news feeds that and going to add content to <a href="http://www.notpopular.com">notpopular.com</a> v2.5 (when ever I finish it). I started thinking about it a bit more and thought it would be cool to use <a href="http://simplepie.org">SimplePie</a> to mash together all of the different RSS feeds from the different social networks I am on.</p>
<p>It wasn&#8217;t that hard to use SimplePie and the various social networks to make something really cool.</p>
<p><code><br />
//establish the feeds<br />
$pownce = new SimplePie("$pownceRSS_url");<br />
$flickr = new SimplePie("$flickrRSS_url");<br />
$twitter = new SimplePie("$twitterRSS_url");<br />
$digg = new SimplePie("$diggRSS_url");<br />
$youtube = new SimplePie("$youtubeRSS_url");<br />
</code><br />
<code><br />
//merge them all together!<br />
$merged = SimplePie::merge_items(array($pownce, $flickr, $twitter, $digg, $youtube));<br />
</code></p>
<p>Then all you have to do is look over each item in $merged, and output the appropriate info you want.</p>
<p>You can see what I built over at <a href="http://www.JoshHighland.com">www.JoshHighland.com</a></p>
<p>One thing I really found great was the <a href="http://simplepie.org/wiki/reference/start">API that was on the SimplePie site</a>.</p>
<p>After I put this all together, I found out that there is a term for what I had just built. People are calling them &#8220;<a href="http://lifestreamblog.com">LifeStreams</a>&#8220;, which is a very appropriate term. I thought I had invented something, but guess <a href="http://lifestreamblog.com/showcase" class="broken_link">LifeStreaming</a> is like fire or a spear, given enough time people all over the place will discover it on their own.</p>
<p>I encourage you do set up a LifeStream for yourself and post the URL in the comments below. It&#8217;s fun!</p>
<p>My LifeStream: <a href="http://www.JoshHighland.com">www.JoshHighland.com</a></p>
<p><strong>UPDATE (10/29/08) :</strong><br />
I was having trouble with my feed from twitter dying after a while. It would only fetch it once, then nothing.I found the answer to my problem on the simplePie blog, <a href="http://simplepie.org/blog/2008/08/16/twitter-bug/">http://simplepie.org/blog/2008/08/16/twitter-bug/</a>. I followed the instructions and commented out the If statement on lines 1583-1586, and the twitter feed started to work again. I hope that twitter updates their RSS service so hacks like this aren&#8217;t needed.</p>
]]></content:encoded>
			<wfw:commentRss>http://joshhighland.com/blog/2008/04/19/lifestreaming-is-simple-as-pie/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
