<?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>Scott Rockers&#039; Blog &#187; php</title>
	<atom:link href="http://scottrockers.com/blog/tag/php/feed" rel="self" type="application/rss+xml" />
	<link>http://scottrockers.com/blog</link>
	<description>Website Designer and Developer, Flash, Wordpress, jQuery, and Other Scripts</description>
	<lastBuildDate>Mon, 22 Aug 2011 21:48:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>WordPress List Category Posts without Breaking Sidebar</title>
		<link>http://scottrockers.com/blog/resources/simple-code-tricks/wordpress-list-category-posts-without-breaking-sidebar</link>
		<comments>http://scottrockers.com/blog/resources/simple-code-tricks/wordpress-list-category-posts-without-breaking-sidebar#comments</comments>
		<pubDate>Wed, 20 Jul 2011 19:17:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Simple Code Tricks]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Fix]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[query_posts]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://scottrockers.com/blog/?p=1240</guid>
		<description><![CDATA[As I was creating a page template for wordpress, I wanted to list posts from a specific category on a page when I ran into a interesting problem, the query_posts function I was using was causing breaks in the execution of conditional tags like is_page(&#8217;25&#8242;) in the sidebar template.  I looked around on the web [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://scottrockers.com/blog/wp-content/uploads/2011/07/query_post-image.jpg" alt="query_post codex" title="query_post codex" width="590" height="300" class="aligncenter size-full wp-image-1244" /><br />
As I was creating a page template for wordpress, I wanted to list posts from a specific category on a page when I ran into a interesting problem, the query_posts function I was using was causing breaks in the execution of conditional tags like is_page(&#8217;25&#8242;) in the sidebar template.  I looked around on the web for a while before finally finding the solution that worked for me. So I am rewriting the solution here for reference and so anyone else may find it easier.</p>
<p>Here is how you list posts from a particular category in a wordpress page template, right before the &#8220;while (have_posts()) : the_post(); &#8221; call add:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> query_posts<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'category_name=name&amp;showposts=100'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #666666; font-style: italic;">/*  change name to the name of the category posts you want to display   */</span>  <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>The reason the wordpress function query_posts() breaks the sidebar template is because its not a simple database query collecting posts from a specific category, but its resetting the query object as a whole to reflect a normal category query. </p>
<p>So to fix the sidebar template you have to go with creating a new query object through WP_Query() in your page template. So here is the before and after of the loop in a page template.</p>
<p><strong>Page Template Loop BEFORE:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> query_posts<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'category_name=name&amp;showposts=100'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> the_post<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
       &lt;!-- do stuff ... --&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><strong>Page Template Loop AFTER:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$cat_posts</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WP_Query<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'category_name=name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cat_posts</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">have_posts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
         <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cat_posts</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">have_posts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$cat_posts</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">the_post</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
                 &lt;!-- do stuff ... --&gt;
         <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

</pre>
<p>Hope that helps someone, cya.</p>
]]></content:encoded>
			<wfw:commentRss>http://scottrockers.com/blog/resources/simple-code-tricks/wordpress-list-category-posts-without-breaking-sidebar/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Envato Marketplace API</title>
		<link>http://scottrockers.com/blog/resources/simple-code-tricks/new-envato-marketplace-api</link>
		<comments>http://scottrockers.com/blog/resources/simple-code-tricks/new-envato-marketplace-api#comments</comments>
		<pubDate>Wed, 22 Apr 2009 14:45:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Simple Code Tricks]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://scottrockers.com/blog/?p=516</guid>
		<description><![CDATA[The Envato Marketplace, which includes sites like FlashDen and ThemeForest, has just come out with their own API. This API is an  interface which will allow developers to build applications and software that can easily utilize Envato user and item data. This allows me to get information in either XML 0r JSON.  So like my [...]]]></description>
			<content:encoded><![CDATA[<p>The Envato Marketplace, which includes sites like FlashDen and ThemeForest, has just come out with their own API. This API is an  interface which will allow developers to build applications and software that can easily utilize Envato user and item data. This allows me to get information in either XML 0r JSON.  So like my integration with WordPress and Flash, I could make a flash application that displays my sellable items from Envato Marketplace onto my Blog.  Its pretty cool.  Here is an example:</p>
<p>With this <a href="http://marketplace.envato.com/api/edge/new-files-from-user:scottrockers,graphicriver.xml" target="_blank">link</a>,  it shows the xml created from the API of the newest files I have uploaded to GraphicRiver.net up to 10 (I only have one up so its only showing that one).</p>
<p>Here is the <a title="Envato Marketplace API Documentation" href="http://marketplace.envato.com/api/documentation" target="_blank">Envato Marketplace API Documentation</a>.</p>
<p>Here is an <a href="http://www.scottrockers.com/blog" target="_blank">API example</a>. After clicking the link, look toward the bottom of the side navigation, I have some of my sellable items from the marketplace listed using the API.</p>
<p>Here is the code I inserted into the sidebar.php file in my wordpress files. I added it right after the last &#8216;&lt;?php endif; ?&gt;&#8217;. Don&#8217;t forget for it to work you have to download the <a href="http://wordpress.org/extend/plugins/envato-recent-items/" target="_blank">Envato Recent Files Plugin</a>, upload that to your plugins folder, and activate it.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;h2&gt;Latest Sellable Items&lt;/h2&gt;
	&lt;li&gt;&lt;?php echo envato_recent_items('your_marketplace_username', 'envato_sitename', 1, true, $ref='your_marketplace_username'); ?&gt;&lt;/li&gt;
	&lt;li&gt;&lt;?php echo envato_recent_items('scottrockers', 'graphicriver', 1, true, $ref='scottrockers'); ?&gt;&lt;/li&gt;</pre></div></div>

<p>Cya</p>
]]></content:encoded>
			<wfw:commentRss>http://scottrockers.com/blog/resources/simple-code-tricks/new-envato-marketplace-api/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash and PHP Newsletter Sign Up Form</title>
		<link>http://scottrockers.com/blog/portfolio/experimental/flash-newsletter-sign-up-form</link>
		<comments>http://scottrockers.com/blog/portfolio/experimental/flash-newsletter-sign-up-form#comments</comments>
		<pubDate>Fri, 06 Feb 2009 22:13:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Experimental]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.rockerssoft.org/scott/blog/?p=326</guid>
		<description><![CDATA[So I had a little extra time this weekend to work on some flash stuff so I createD a newsletter sign up form.  Which brings me to this point,  one of the things that attracts me to Flash so much is that I can easily customize the look and feel of anything I work on [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a rel="shadowbox;width=200;height=100;" href="http://www.scottrockers.com/blog/wp-content/uploads/2009/02/newslettersignup.swf"><img class="aligncenter size-full wp-image-327" title="newslettersignup" src="http://www.scottrockers.com/blog/wp-content/uploads/2009/02/newslettersignup.jpg" alt="newslettersignup" width="200" height="100" /></a></p>
<p>So I had a little extra time this weekend to work on some flash stuff so I createD a newsletter sign up form.  Which brings me to this point,  one of the things that attracts me to Flash so much is that I can easily customize the look and feel of anything I work on really easily. You have to love the Flash IDE, thats all I am saying.  Some of the features that I programmed into this sign up form that I would like to point out are:</p>
<ol>
<li>Use of the &#8220;Enter&#8221; key with the keylistener function to make it more user friendly</li>
<li>Tab indexing functionality also to make it more user friendly</li>
<li>Error detection on the input field for those users who are retarded (basically it won&#8217;t take any input that is not a valid email address)</li>
</ol>
<p>I am all about user friendliness, and  I will get more into that at some point.  There is a really simple PHP script that goes along with this, and for right now it just sends the email address the user inputs to a certain email address (right now it just sends it to my email). At some point, I would like for the input to be put directly into a database but thats for later.</p>
<p>Cya</p>
]]></content:encoded>
			<wfw:commentRss>http://scottrockers.com/blog/portfolio/experimental/flash-newsletter-sign-up-form/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

