<?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>Matthew Simo &#187; php</title>
	<atom:link href="http://matt-simo.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://matt-simo.com</link>
	<description>Front-End Designer/Developer</description>
	<lastBuildDate>Mon, 01 Feb 2010 21:51:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Query Post by a Variable?</title>
		<link>http://matt-simo.com/query-post-by-a-variable/</link>
		<comments>http://matt-simo.com/query-post-by-a-variable/#comments</comments>
		<pubDate>Thu, 25 Jun 2009 17:59:07 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[Site Development]]></category>
		<category><![CDATA[personal]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[custom fields]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://matt-simo.com/?p=202</guid>
		<description><![CDATA[Howdy, I hope someone will see this and possibly know a solution to what I&#8217;m trying to do&#8230; So, I&#8217;m trying to pull a custom field and setting the result as $sortingTag I&#8217;m then trying to query_posts looking in a &#8230; <a href="http://matt-simo.com/query-post-by-a-variable/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Howdy, I hope someone will see this and possibly know a solution to what I&#8217;m trying to do&#8230;</p>
<p>So, I&#8217;m trying to pull a custom field and setting the result as $sortingTag I&#8217;m then trying to query_posts looking in a particular category and by a certain tag.</p>
<p>Here is the code I&#8217;m using:</p>
<pre>
<code>&lt;?php if ( (is_page('web')) or (is_page('print')) or (is_page('identity')) ) {

$sortingTag = get_post_meta($post-&gt;ID, 'sorting-tag', true);		

query_posts(array(
	'cat'=&gt;17,
	'showposts'=&gt;15,
	'tag'=&gt;"$sortingTag",
));
?&gt;</code>
</pre>
<p>Here is how I&#8217;m trying to implement it:</p>
<p>I&#8217;ve set up child pages &#8216;web&#8217;, &#8216;identity&#8217;, &#038; &#8216;print&#8217; under the parent &#8216;Portfolio&#8217;. On each page I&#8217;ve set a custom field with the key &#8216;sorting-tag&#8217; with it&#8217;s respective page name (i.e. web for web).</p>
<p>And I&#8217;m using posts to hold my portfolio pieces, depending on the project each could have one or more of the tags &#8216;web&#8217;, &#8216;identity&#8217;, or &#8216;print&#8217; (spelled the same, with same case). </p>
<p>Now my problem, I figure I&#8217;d be able to pass the custom field and search by that value for the post tags. But it isn&#8217;t populating the loop at all, I do get a populated loop when I change &#8216;tag&#8217; to &#8216;tag_slug&#8217; but it still isn&#8217;t changing the query results, it is as if they are still unfiltered..</p>
<p>Anyone have any help or run into this before? I&#8217;d love to sort this out&#8230; lol sort. Get it?!? Haha, sorry, couldn&#8217;t help myself&#8230; </p>
<p>But seriously, little help&#8230; and if you could pass this on to your wordpress guru&#8217;s that&#8217;d be sweet too.</p>
]]></content:encoded>
			<wfw:commentRss>http://matt-simo.com/query-post-by-a-variable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom Field Template Plugin: Very Handy!</title>
		<link>http://matt-simo.com/cft-plugin-very-handy/</link>
		<comments>http://matt-simo.com/cft-plugin-very-handy/#comments</comments>
		<pubDate>Sun, 31 May 2009 06:37:21 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[personal]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[CFT]]></category>
		<category><![CDATA[custom field template]]></category>
		<category><![CDATA[DFWWP]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://matt-simo.com/?p=130</guid>
		<description><![CDATA[Ok, I know that I said I wouldn&#8217;t really be posting so that I wouldn&#8217;t get distracted and so I could focus on my portfolio theme development. But, this is just too cool! I was at the DFW WordPress May &#8230; <a href="http://matt-simo.com/cft-plugin-very-handy/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Ok, I know that I said I wouldn&#8217;t really be posting so that I wouldn&#8217;t get distracted and so I could focus on my portfolio theme development. But, this is just too cool!</p>
<p>I was at the DFW WordPress May Meetup earlier today (at BJ&#8217;s) and met some really smart people that know a whole heck of a lot more than I do (and are much further along <em>&#8220;the road&#8221;</em> than I am). </p>
<p>One guy in particular, <a href="http://amesburyweb.com">Randy Hoyt</a>, was a great resource for what I&#8217;m attempting to do with wordpress. After talking with him for about 5 minutes, we got on the subject of Custom Field&#8217;s and he said <a href="http://wordpress.org/extend/plugins/custom-field-template/">Custom Field Template</a> was a great tool that would help me achieve my goals.</p>
<p>Needless to say, I left the DFWWP Meetup pretty pumped to get back to my computer to start playing around with all the ideas of what I could do bouncing around in my head! </p>
<p>After I got the CFT plugin installed I decided to take it for a test drive so to speak. (*As I&#8217;m new to a lot of this, the nomenclature I use may be off a little, as I continue I hope I do a good enough job describing the process I followed. Also, if there is a better/more effective/efficient process than what I&#8217;ve followed, please, enlighten me!) </p>
<p>I made a custom field template that I titled <em>&#8220;Portfolio&#8221;</em> with the plans of handling all of the &#8216;extra&#8217; data associated with a portfolio piece (i.e. Client Name, Client Quote, Portfolio Image, Skills used, etc&#8230;)</p>
<p>There is a <a href="http://www.gabrielserafini.com/tags/custom-field-template/">great post</a> by Gabriel Serafini (<a href="http://twitter.com/gserafini/">@gserafini</a>) in which he highlights and does pretty good walk through of setting up your own CFT template. I won&#8217;t go into it here, check out his post.</p>
<p>Here we go! I had my template all set up and rigged up some test posts to test out the functionality and work out any bugs. All of the &#8216;simple&#8217; fields worked beautifully (client_name, portfolio_image, etc&#8230;) but I had put in a custom field &#8216;skills_used&#8217; that utilized checkboxes. Since you can click on more than one box it passes an array to that custom field, which I haven&#8217;t had to deal with up to this point. I didn&#8217;t know if I could parse the array successfully and apply the html tags I wanted to it as well and place it in the wp template I needed it in.</p>
<p>I found some good posts on the net but nothing that really dealt specifically with this particular issue (granted, I&#8217;m sure it is out there, I looked for like 5 minutes max&#8230;) so I rolled up my sleeves and went to work.</p>
<p>Here is what I came up with, I&#8217;m sure it is pretty sloppy (I consider myself a php novice pretty much.) but it works like a beauty. I decided to wrap everything in an unordered list and wrap each skill used in it&#8217;s own list item.</p>
<pre>
<code>&lt;?php //get skills_used (custom field) ?&gt;
&lt;?php $skills = get_post_meta($post-&gt;ID, 'skills_used'); ?&gt;

&lt;?php if(empty($skills)) {
	//if $skills is empty DO NOTHING!!!
}
else {

	echo '&lt;ul class="skills-used"&gt;

		&lt;li class="skills-used-title"&gt;&lt;h4&gt;Skills Used:&lt;/h4&gt;&lt;/li&gt;';

	foreach ($skills as $skill) {
	    echo '&lt;li class="'."$skill".'"&gt;'."$skill&lt;/li&gt;";
	}

	echo "&lt;/ul&gt;";
}
?&gt;</code>
</pre>
<p>*this code was placed into the single template file for my portfolio category posts* (It can go in any wp template you need it to go into, sidebar.php, single.php, etc&#8230;)</p>
<p><strong>Description:</strong> I passed the custom field &#8216;skills_used&#8217; which was part for the template that I created in CFT ( Remember the checkboxes? Ya, those guys.) to a variable $skills. Then I tested this variable to see if it was empty, if it was empty I wanted it to do NOTHING, although, if it had the good stuff, I wanted it. But the question was, how to get <strong>all</strong> of it. Enter &#8220;foreach&#8221;, basically, the jist of what is happening here is that I&#8217;m splitting the array apart and labeling each part it pulls off as the variable $skill (not plural!) echo&#8217;s it after wrapping it in the li tag, then forgetting it and moving to the next one, until there is nothing left. Tack on the close ul tag and wrap up the php. </p>
<p>An astute student would notice two &#8216;$skill&#8217; varables being used each foreach. Very good padawan, I want css control over each one, so I&#8217;m listing the class of the list item as $skill. This way, if I use Photoshop CS4 for a particular project, I can place a sexy little blue square with &#8220;Ps&#8221; carved into it. </p>
<p>That, my friends, is what was <strong>so cool</strong> that it got me blogging at 1:30 am (pardon my spelling!). There is a whole lot of cool stuff you can do with custom fields and similar implementations to this, it just takes a little imagination and experimentation. Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://matt-simo.com/cft-plugin-very-handy/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Added &amp; Configured SimplePie for WP</title>
		<link>http://matt-simo.com/configured-simplepie-for-wp/</link>
		<comments>http://matt-simo.com/configured-simplepie-for-wp/#comments</comments>
		<pubDate>Tue, 19 May 2009 18:43:22 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[SimplePie]]></category>
		<category><![CDATA[WP]]></category>

		<guid isPermaLink="false">http://matt-simo.com/?p=68</guid>
		<description><![CDATA[I started thinking&#8230; &#8220;Man, having some lame post explaining that I&#8217;m off developing and hacking WP is almost as bad as having a big fat image saying that I&#8217;m &#8216;Under Construction&#8217; (see this).&#8221; As a result, I figured loading some &#8230; <a href="http://matt-simo.com/configured-simplepie-for-wp/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I started thinking&#8230; &#8220;Man, having some lame post explaining that I&#8217;m off developing and hacking WP is almost as bad as having a big fat image saying that I&#8217;m &#8216;Under Construction&#8217; (see <a href="http://images.google.com/images?q=under+construction&#038;oe=utf-8&#038;rls=org.mozilla:en-US:official&#038;client=firefox-a&#038;um=1&#038;ie=UTF-8&#038;ei=k_MSSq_RLYSs8QTPufT8Aw&#038;sa=X&#038;oi=image_result_group&#038;resnum=1&#038;ct=title">this</a>).&#8221;</p>
<p>As a result, I figured loading some dynamic content that tracks the latest 5 things I&#8217;m up to on the web would be far superior. </p>
<p>I was in luck. It just so happened that not too long ago I had played around with <a href="http://simplepie.org/">SimplePie</a>. The SimplePie website describes SimplePie as &#8220;a very fast and easy-to-use class, written in PHP, that puts the &#8216;simple&#8217; back into &#8216;really simple syndication&#8217;&#8221;. I used a great <a href="http://css-tricks.com/video-screencasts/55-adding-rss-content-with-simplepie/">css-tricks video tutorial</a> as a guide and decided to play around to make SimplePie track my web activity from the last week.</p>
<p>It went great. My initial exposure to working with SimplePie was quick, intuitive, and strait-forward. It took me a couple of hours to learn all I needed to know and code up what I wanted SimplePie to do for me. It should be stated that while I&#8217;m comfortable with php, I am by no means am a master or guru or even consider myself really all that experienced.</p>
<p>As a result, I was extremely pleased when I found the <a href="http://wordpress.org/extend/plugins/simplepie-plugin-for-wordpress/">SimplePie Plugin for WP</a>. I downloaded, installed and went to work. (Don&#8217;t forget to get the <a href="http://wordpress.org/extend/plugins/simplepie-core/">SimplePie Core Plugin</a>, you need it so the classes the WP plugin uses are understood!) Since I was familiar with the basic concept of how SimplePie worked it was a breeze, I coded what I needed (This time I only wanted to track the 5 most recent items.), integrated it into the theme I recently installed (Which, by the way, finding a theme that is intelligently and cleanly coded like <a href="http://jimbarraud.com/2009/03/19/manifest/">Manifest</a> is makes this go faster too. Kudos Jim!) and added some css classes to make it look pretty.</p>
<p>I put the very strait forward SimplePie code into the Header Template.</p>
<blockquote><p>
<code>  &lt;div id="simplepie"&gt;<br />
		&lt;?php<br />
		echo SimplePieWP(array(<br />
			    'http://digg.com/users/MaSimo/history.rss',<br />
    			'http://twitter.com/M_A_Simo',<br />
    			'http://feeds.pandora.com/feeds/people/simo5436/favorites.xml',<br />
    			'http://feeds.pandora.com/feeds/people/simo5436/favoriteartists.xml',<br />
    			'http://feeds.pandora.com/feeds/people/simo5436/nowplaying.xml',<br />
    			'http://delicious.com/M_A_Simo',<br />
		), array(<br />
			'items' =&gt; 5,<br />
			'cache_duration' =&gt; 1800,<br />
			'date_format' =&gt; 'M jS, g:i a'<br />
		));<br />
		?&gt;<br />
  &lt;/div&gt;</code>
</p></blockquote>
<p>I also took advantage of the template system that the WP Plugin uses and edited one of the .tmpl files that came with the plugin. After some tinkering and a little thought I came up with the following as my defined .tmpl&#8230;</p>
<blockquote>
<p><code>div id="simplepie"&gt;<br />
	{IF_ERROR_BEGIN}p class="error"&gt;{ERROR_MESSAGE}/p&gt;{IF_ERROR_END}</p>
<p>	ul&gt;<br />
	{ITEM_LOOP_BEGIN}<br />
	li&gt;<br />
		p class="title"&gt;strong&gt;&lt;img src="{ITEM_PARENT_FAVICON}" alt="{ITEM_PARENT_TITLE}" title="{ITEM_PARENT_TITLE}" /&gt; a href="{ITEM_PARENT_PERMALINK}"&gt;{ITEM_PARENT_TITLE}/a&gt;/strong&gt;/p&gt;<br />
		br /&gt;<br />
		p class="simplepie_content"&gt;a href="{ITEM_PERMALINK}"&gt;{ITEM_DESCRIPTION}/a&gt;/p&gt;<br />
		p class="date"&gt;{ITEM_DATE}/p&gt;<br />
	/li&gt;<br />
		br class="clear" /&gt;<br />
	{ITEM_LOOP_END}<br />
	/ul&gt;<br />
/div&gt;</code>
</p></blockquote>
<blockquote><p><strong>**See Note In Commets RE: Above Code**</strong></p></blockquote>
<p>Great, I got SimplePie to parse the feeds I wanted and embed it into WP where I wanted, but now I needed to make a few .css classes so it would match the look of my current theme. I whipped up the following, still a bit dirty and rough, I&#8217;ll be the first to admit.</p>
<blockquote><p>
<code>#simplepie{<br />
  margin-top: 10px;<br />
  margin-bottom: 70px;<br />
}<br />
#simplepie ul{<br />
  margin 0 auto;<br />
  background: #FBFBFB;<br />
  border-top: 1px solid #EAEAEA;<br />
  border-bottom: 1px solid #EAEAEA;<br />
}<br />
#simplepie li{<br />
  padding: 5px 5px 0px 5px;<br />
  display:block;<br />
  font-size:1.5em;<br />
  border-bottom: 1px solid #EAEAEA;<br />
}<br />
#simplepie p.simplepie_content{<br />
  text-align: left;<br />
  display: block;<br />
  padding: 0 10px 10px;<br />
}<br />
#simplepie p.date {<br />
  display: block;<br />
  font-size: .7em;<br />
  margin-bottom: 10px;<br />
}<br />
#simplepie li:last-child{<br />
  border-bottom: none;<br />
}<br />
br.clear {<br />
  clear:both;<br />
  display: block;<br />
  height: 0;<br />
}</code>
</p></blockquote>
<p>Almost there! Now I just edited a few already made classes that controlled the links how I liked and made them target the html that the .tmpl rendered as the SimplePie Plugin parsed my code.</p>
<blockquote><p>
<code>#mainNav, #simplepie a:link,<br />
#mainNav, #simplepie a:visited{<br />
  color: #999;<br />
}<br />
#mainNav, #simplepie a:hover,<br />
#mainNav, #simplepie a:active{<br />
  text-decoration: underline;<br />
  color: #2E301C;<br />
}</code>
</p></blockquote>
<p>Viola! The result??? Well, you should be seeing it, just above the post area. Simple, strait-forward, &#038; I hope it keeps you at least cursorily entertained while I&#8217;m working on my theme.  </p>
]]></content:encoded>
			<wfw:commentRss>http://matt-simo.com/configured-simplepie-for-wp/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

