<?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>Scattered &#187; Code</title>
	<atom:link href="http://dancameron.org/category/code/feed" rel="self" type="application/rss+xml" />
	<link>http://dancameron.org</link>
	<description>A lot of WordPress, some Technology and Gadgets; mostly just scattered stuff within my periphery.</description>
	<lastBuildDate>Wed, 17 Mar 2010 23:25:41 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Adding a Loop to a WordPress Page Template with WP_Query and Pagination</title>
		<link>http://dancameron.org/code/adding-a-loop-to-a-wordpress-page-template-with-wp_query-and-pagination</link>
		<comments>http://dancameron.org/code/adding-a-loop-to-a-wordpress-page-template-with-wp_query-and-pagination#comments</comments>
		<pubDate>Fri, 05 Mar 2010 01:44:19 +0000</pubDate>
		<dc:creator>dancameron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[page templates]]></category>
		<category><![CDATA[snippets]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://dancameron.org/?p=3874</guid>
		<description><![CDATA[Its pretty easy to add a loop to a page template but having pagination will provide some roadblocks if you&#8217;re trying to use the standard previous and next template tags. The solution I came up with this afternoon is pretty basic and if there&#8217;s a better alternative I&#8217;m open to hear them.
Place this after get_header() [...]]]></description>
			<content:encoded><![CDATA[<p>Its pretty easy to add a loop to a page template but having pagination will provide some roadblocks if you&#8217;re trying to use the standard <a href="http://codex.wordpress.org/Template_Tags/previous_post_link">previous and next template tags</a>. The solution I came up with this afternoon is pretty basic and if there&#8217;s a better alternative I&#8217;m open to hear them.</p>
<p>Place this after get_header() within your page template.</p>
<pre class="brush: php">
$paged = (get_query_var(&#039;paged&#039;)) ? (int) get_query_var(&#039;paged&#039;) : 1;
$page_link = get_permalink($id);
</pre>
<p>Not sure what type of loop you want to create but here&#8217;s what I recently used under the page content.</p>
<pre class="brush: php">
&lt;?php
	$events_query = new WP_Query(&#039;category_name=Custom&amp;amp;paged=&#039;.$paged);
	while ($events_query-&gt;have_posts()) : $events_query-&gt;the_post();
		// post markup would go here, e.g. the_excerpt();
	endwhile;
?&gt;
</pre>
<p>I also wrapped my page content so it only showed on the first page and not the paginated pages.</p>
<pre class="brush: php">
&lt;?php
	if($paged == 1){
		// all the page content markup, e.g. the_content();
	}
?&gt;
</pre>
<p>After those updates you&#8217;ll have a page template that returns a loop of posts under the &#8220;Custom&#8221; category.</p>
<p>The last step is adding the pagination links. Here&#8217;s the markup I used.</p>
<pre class="brush: php">
&lt;div class=&quot;pagination&quot;&gt;
			&lt;span class=&quot;previous&quot;&gt;
				&lt;a href=&quot;&lt;?php echo $link ?&gt;page/&lt;?php echo $paged + 1; ?&gt;&quot;&gt;&amp;amp;laquo; Previous&lt;/a&gt;
			&lt;/span&gt;
			&lt;?php if($paged != 1): ?&gt;
			&lt;span class=&quot;next&quot;&gt;
				&lt;a href=&quot;&lt;?php echo $link ?&gt;page/&lt;?php echo $paged - 1; ?&gt;&quot;&gt;Next &amp;amp;raquo;&lt;/a&gt;
			&lt;/span&gt;
			&lt;?php endif; ?&gt;
&lt;/div&gt;
</pre>
<p>So, is there a better way out there? I hope so, since the previous and next links show regardless if there&#8217;s posts or not, and I don&#8217;t feel like writing those queries for this tutorial :). </p>
]]></content:encoded>
			<wfw:commentRss>http://dancameron.org/code/adding-a-loop-to-a-wordpress-page-template-with-wp_query-and-pagination/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Apache Tomcat 6 on Snow Leopard ( OSX 10.6 )</title>
		<link>http://dancameron.org/code/installing-apache-tomcat-6-on-snow-leopard-osx-10-6</link>
		<comments>http://dancameron.org/code/installing-apache-tomcat-6-on-snow-leopard-osx-10-6#comments</comments>
		<pubDate>Tue, 02 Mar 2010 19:45:46 +0000</pubDate>
		<dc:creator>dancameron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[jsp programming]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tomcat]]></category>

		<guid isPermaLink="false">http://dancameron.org/?p=3859</guid>
		<description><![CDATA[It&#8217;s been a long time since I worked on a JSP project and I&#8217;m now tasked with the setup of a workspace in Eclipse, this time I&#8217;m solely using OS X to develop on. Here are the steps I took to setup my local workspace.
Download the Apache Tomcat
Found under Binary Distribution as a tar.gz under &#8216;Core&#8217;
Move [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a long time since I worked on a JSP project and I&#8217;m now tasked with the setup of a workspace in Eclipse, this time I&#8217;m solely using OS X to develop on. Here are the steps I took to setup my local workspace.</p>
<p><strong>Download the </strong><a href="http://tomcat.apache.org/download-60.cgi"><strong>Apache Tomcat</strong></a></p>
<p>Found under <a href="http://tomcat.apache.org/download-60.cgi">Binary Distribution</a> as a tar.gz under &#8216;Core&#8217;</p>
<p><strong>Move and untar</strong></p>
<ol></ol>
<pre class="brush: bash">
$ cd /usr/local
$ mv ~/Downloads/apache-tomcat-6.0.24.tar .
$ tar -xzvf apache-tomcat-6.0.24.tar
$ mv apache-tomcat-6.0.24 tomcat6
</pre>
<p><strong>Starting and Stopping Tomcat</strong></p>
<pre class="brush: bash">
$ mkdir bin
$ cd bin
</pre>
<p>Create a file under called start_tomcat ( e.g. ~/bin/start_tomcat  ) with the following contents:</p>
<pre class="brush: bash">
#!/bin/sh
export CATALINA_HOME=/usr/local/tomcat6
export JAVA_HOME=/usr
$CATALINA_HOME/bin/startup.sh
</pre>
<p>..and another for stopping tomcat ( e.g. stop_tomcat )</p>
<pre class="brush: bash">
#!/bin/sh
export CATALINA_HOME=/usr/local/tomcat6
export JAVA_HOME=/usr
$CATALINA_HOME/bin/shutdown.sh
</pre>
<p>Make the files executable:</p>
<pre class="brush: bash">
$ chmod ug+x start_tomcat stop_tomcat
</pre>
<p>Now you can start and stop tomcat with commands these commands:</p>
<pre class="brush: bash">
~/bin/start_tomcat
~/bin/stop_tomcat
</pre>
<p>Apple has some good <a href="http://tuvix.apple.com/internet/java/tomcat1.html">docs on tomcat</a>, even if they&#8217;re out of date.</p>
]]></content:encoded>
			<wfw:commentRss>http://dancameron.org/code/installing-apache-tomcat-6-on-snow-leopard-osx-10-6/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Display a loading image until the page completes loading</title>
		<link>http://dancameron.org/code/display-a-loading-image-until-the-page-completes-loading</link>
		<comments>http://dancameron.org/code/display-a-loading-image-until-the-page-completes-loading#comments</comments>
		<pubDate>Tue, 03 Nov 2009 22:13:55 +0000</pubDate>
		<dc:creator>dancameron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[tuts]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://dancameron.org/?p=3514</guid>
		<description><![CDATA[Similar to how GDGT.com has it&#8217;s loading.gif while the page completes this method will do something very similar.
Right after the body I include the image inside a div:

&#60;div id=&#34;loading-image&#34;&#62;
	&#60;img src=&#34;&#60;?php bloginfo(&#039;template_url&#039;); ?&#62;/images/ajax-loader.gif&#34; alt=&#34;Loading...&#34; /&#62;
&#60;/div&#62;

Of course I&#8217;m using wordpress so you might need to include a different path for your ajax-loader.gif.
Here&#8217;s the CSS I&#8217;m using on [...]]]></description>
			<content:encoded><![CDATA[<p>Similar to how GDGT.com has it&#8217;s loading.gif while the page completes this method will do something very similar.</p>
<p>Right after the body I include the image inside a div:</p>
<pre class="brush: php">
&lt;div id=&quot;loading-image&quot;&gt;
	&lt;img src=&quot;&lt;?php bloginfo(&#039;template_url&#039;); ?&gt;/images/ajax-loader.gif&quot; alt=&quot;Loading...&quot; /&gt;
&lt;/div&gt;
</pre>
<p>Of course I&#8217;m using wordpress so you might need to include a different path for your ajax-loader.gif.</p>
<p>Here&#8217;s the CSS I&#8217;m using on my current project:</p>
<pre class="brush: css">
#loading-image {
	background-color: #333;
	width: 55px;
	height: 55px;
	position: fixed;
	top: 20px;
	right: 20px;
	z-index: 1;
	-moz-border-radius: 10px;
	-webkit-border-radius: 10px;
	border-radius: 10px; /* future proofing */
	-khtml-border-radius: 10px;
}
</pre>
<p>Now the most important part. I&#8217;m using jQuery to hide that div after the page completes loading.</p>
<pre class="brush: javascript">
jQuery(window).load(function() {
	jQuery(&#039;#loading-image&#039;).hide();
});
</pre>
<p>I have some more jQuery &#8220;magic&#8221; working for form submissions but this should get you where you need to get.</p>
]]></content:encoded>
			<wfw:commentRss>http://dancameron.org/code/display-a-loading-image-until-the-page-completes-loading/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Splitting Content into Two Columns, e.g. Word Wrap with PHP or CSS + Javascript</title>
		<link>http://dancameron.org/code/splitting-content-into-two-columns-e-g-word-wrap-with-php-or-css-javascript</link>
		<comments>http://dancameron.org/code/splitting-content-into-two-columns-e-g-word-wrap-with-php-or-css-javascript#comments</comments>
		<pubDate>Wed, 21 Oct 2009 17:54:32 +0000</pubDate>
		<dc:creator>dancameron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tuts]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://dancameron.org/?p=3509</guid>
		<description><![CDATA[Over the last couple days I&#8217;ve had the dilemma of trying to figure out how to word-wrap WordPress post content into two columns. Here is an example of what I needed to produce.

As you can tell it shouldn&#8217;t be too difficult, but there&#8217;s a crux that I&#8217;ll bring up after the first solution.
The first solution [...]]]></description>
			<content:encoded><![CDATA[<p>Over the last couple days I&#8217;ve had the dilemma of trying to figure out how to word-wrap WordPress post content into two columns. Here is an example of what I needed to produce.</p>
<p><a href="http://dancameron.org/wp-content/uploads/2009/10/Double-columns.png" rel="shadowbox[post-3509];player=img;"><img class="aligncenter size-medium wp-image-3510" title="Double columns" src="http://dancameron.org/wp-content/uploads/2009/10/Double-columns-500x389.png" alt="Double columns" width="500" height="389" /></a></p>
<p>As you can tell it shouldn&#8217;t be too difficult, but there&#8217;s a crux that I&#8217;ll bring up after the first solution.</p>
<p>The first solution that will use CSS3 column-count;  and some js for that browser we all hate ( IE if you couldn&#8217;t tell ).</p>
<p>For Firefox and Webkit browsers ( chrome and safari ) it&#8217;s as easy as this:</p>
<pre class="brush: css">
#container {
text-align: justify;
width: 885px;
margin: 10px auto;
padding: 10px;
}
.columns {
-moz-column-count: 2;
-moz-column-gap: 1.5em;
-moz-column-rule: none;
-webkit-column-count: 2;
-webkit-column-gap: 1.5em;
-webkit-column-rule: none;
/* future proof */
column-count: 2;
column-gap: 1.5em;
column-rule: none;
}
</pre>
<p>Then for IE there&#8217;s a great script that will parse through your CSS and force IE to split the content up into two columns. <a href="http://www.cvwdesign.com/txp/multi-columns/multi-column-example4.html">Here&#8217;s a demo</a> of the script in action. You should be able to figure out how to implement it from there, it&#8217;s pretty easy.</p>
<p>[note: just make sure that you don't have your style sheets on a different domain, otherwise the script will not be able to parse it. I ran into this because of how I have my local wp dev setup]</p>
<p>Now this solution will solve just about 99% of anyones needs. However, if you wanted to print that same page you&#8217;re at a lose, the columns will break down.</p>
<p>Here comes my second solution, the one that I&#8217;m using on the current project.</p>
<p>The below function will essentially figure out where the middle of the content is, then insert your separation code in-between.</p>
<pre class="brush: php">
function content_split($text, $separator = &#039;&lt;hr/&gt;&#039;, $start = false ) {

if ( $start === false) {
$start = strlen($text) / 2;
}

$lastSpace = false;
$split = substr($text, 0, $start - 1);

// if the text is split at a good breaking point already.
if (in_array(substr($text, $start - 1, 1), array(&#039; &#039;, &#039;.&#039;, &#039;!&#039;, &#039;?&#039;))) {

$split .= substr($text, $start, 1);
// Calculate when we should start the split
$trueStart = strlen($split);

// find a good point to break the text.
} else {

$split = substr($split, 0, $start - strlen($separator));
$lastSpace = strrpos($split, &#039; &#039;);

if ($lastSpace !== false) {
$split = substr($split, 0, $lastSpace);
}

if (in_array(substr($split, -1, 1), array(&#039;,&#039;))) {
$split = substr($split, 0, -1);
}

// Calculate when we should start the split
$trueStart = strlen($split);
}
//now we know when to split the text
return substr_replace($text, $separator, $trueStart, 0);

}
</pre>
<p>[props to <a href="http://www.php.net/manual/en/function.substr-replace.php#39200">this function</a> which helped me through]</p>
<p>And to implement it into WordPress just place the above function in your functions.php file, then just use the function anywhere you&#8217;d like and pass the appropriate vars:</p>
<pre class="brush: php">
&lt;div class=&quot;first-column column&quot;&gt;
&lt;?php
$text = get_the_content();
$separator = &#039;&lt;/div&gt;&lt;div class=&quot;second-column column&quot;&gt;&#039;;
echo content_split($text,$separator);
?&gt;
&lt;/div&gt;
</pre>
<p>My CSS is basic after that:</p>
<pre class="brush: css">
.column {
float: left;
width: 430px;
clear: right;
}
.first-column {
margin-right: 20px;
}
</pre>
<p>Now I can print the page exactly how it looks on the web ( maybe with a little print.css love ).</p>
]]></content:encoded>
			<wfw:commentRss>http://dancameron.org/code/splitting-content-into-two-columns-e-g-word-wrap-with-php-or-css-javascript/feed</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Replace or Remove the Carrington Theme Admin Panel</title>
		<link>http://dancameron.org/code/replace-or-remove-the-carrington-theme-admin-panel</link>
		<comments>http://dancameron.org/code/replace-or-remove-the-carrington-theme-admin-panel#comments</comments>
		<pubDate>Wed, 26 Aug 2009 23:40:47 +0000</pubDate>
		<dc:creator>dancameron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[carrington]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress themes]]></category>

		<guid isPermaLink="false">http://dancameron.org/?p=3482</guid>
		<description><![CDATA[One of the very first things I had to do to start using the Carrington Theme Framework was replace the admin menu with my own. For some reason, already ranted here in the forums, the core includes the admin panel. Remember, you shouldn&#8217;t hack away at  carrington-core/admin.php or any other core file ( if you [...]]]></description>
			<content:encoded><![CDATA[<p>One of the very first things I had to do to start using the <a href="http://carringtontheme.com/themes/">Carrington Theme Framework</a> was replace the admin menu with my own. For some reason, <a href="http://crowdfavorite.com/forums/viewtopic.php?id=1932">already ranted here in the forums</a>, the core includes the admin panel. Remember, you shouldn&#8217;t hack away at  carrington-core/admin.php or any other core file ( if you do you&#8217;re missing the point of CFCT, or &#8220;you&#8217;re doing it wrong&#8221; ), instead use actions to remove or add what you need.</p>
<p>It&#8217;s really simple, so simple I almost didn&#8217;t post about it, just use the remove_action function like so:</p>
<pre class="brush: php">
remove_action(&#039;admin_menu&#039;, &#039;cfct_admin_menu&#039;);
</pre>
<p>Then just use an add_action for your admin panel ( if necessary ). I already had a logical admin panel &#8220;framework&#8221; built so it was an easy transition for me from my old theme framework ( custom ) to the carrington framework.</p>
<p>I&#8217;m guessing this post will be useful to most, especially WP theme developers whom are the real users of the CFCT, but I need to post some progress to the <a href="http://dancameron.org/general/phase-one-of-the-theme-experiment">theme experiment series</a> :).</p>
]]></content:encoded>
			<wfw:commentRss>http://dancameron.org/code/replace-or-remove-the-carrington-theme-admin-panel/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Short Post URLs</title>
		<link>http://dancameron.org/code/short-post-urls</link>
		<comments>http://dancameron.org/code/short-post-urls#comments</comments>
		<pubDate>Fri, 24 Jul 2009 15:02:02 +0000</pubDate>
		<dc:creator>dancameron</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://dancameron.org/?p=3423</guid>
		<description><![CDATA[I just noticed a trend recently ( maybe not too recent ) on how to make your WordPress Post URLs short for sharing, especially with Twitter&#8217;s character limit.
I stumbled across Derek&#8217;s post just the other day through a delicious share of Dean&#8217;s and since I&#8217;m working on a project with custom re-writes I thought it [...]]]></description>
			<content:encoded><![CDATA[<p>I just noticed a trend recently ( <a href="http://5thirtyone.com/archives/2075">maybe not too recent</a> ) on how to make your WordPress Post URLs short for sharing, especially with Twitter&#8217;s character limit.</p>
<p>I stumbled across <a href="http://5thirtyone.com/">Derek</a>&#8217;s post just the other day through a delicious share of <a href="http://delicious.com/deanjrobinson">Dean&#8217;s</a> and since I&#8217;m working on a project with custom re-writes I thought it would be simple to write a quick plugin and document how to shorten your urls within your theme&#8217;s function file.</p>
<p>Another reason I thought this was justified: <a href="http://wordpress.org/extend/plugins/search.php?q=shorten+post+urls">all the other plugins</a> are too complex and Derek&#8217;s solution seems to be the best because it&#8217;s simple&#8211;it just needed to use what WP offers for custom rewriting vs. hacking the .htaccess file.</p>
<p>Right now it comes in two flavors, a <a href="http://dancameron.org/wordpress/plugins/short-post-urls">plugin</a> or you can update your function.php file within your theme.</p>
<pre class="brush: php">
add_action( &#039;generate_rewrite_rules&#039;, &#039;custom_rewrite_rules&#039; );
function custom_rewrite_rules( $wp_rewrite )
{
$newRules = array();
// Defualt http://siteurl.com/s/1 ( &#039;1&#039; being the post id )
$newRules[ &#039;s/([0-9]+)$&#039; ] = &#039;index.php?p=&#039; . $wp_rewrite-&gt;preg_index( 1 );
// Another example below http://siteurl.com/1
// $newRules[ &#039;([0-9]+)$&#039; ] = &#039;index.php?p=&#039; . $wp_rewrite-&gt;preg_index( 1 );
$wp_rewrite-&gt;rules = $newRules + $wp_rewrite-&gt;rules;
return $wp_rewrite;
}
</pre>
<p>After you place this in your functions file, or after every update or new re-write, you will need to refresh your permalinks via http://yoursite.com/wp-admin/options-permalink.php ( just click save changes ).</p>
<p>Now you can just use Derek&#8217;s templating code to do something like this.</p>
<p><a class="share-via-twitter" title="Tweet this post" href="http://twitter.com/home?status=Reading: Short Post URLs http://dancameron.org/s/3423"><strong>Tweet This</strong></a></p>
]]></content:encoded>
			<wfw:commentRss>http://dancameron.org/code/short-post-urls/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Displaying a posts current category and parent category only</title>
		<link>http://dancameron.org/code/displaying-a-posts-current-category-and-parent-category-only</link>
		<comments>http://dancameron.org/code/displaying-a-posts-current-category-and-parent-category-only#comments</comments>
		<pubDate>Tue, 03 Feb 2009 21:05:14 +0000</pubDate>
		<dc:creator>dancameron</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://dancameron.org/?p=2993</guid>
		<description><![CDATA[Since WordPress doesn&#8217;t allow for limiting the category in &#8220;the_category&#8221; I had to write some custom code to achieve limiting the categories displayed for the current post to the current category and it&#8217;s parent.

&#60;?php //display the current and parent category (2 total)
$category = get_the_category();
$current_category = $category[0];
$parent_category = $current_category-&#62;category_parent;
if ( $parent_category != 0 ) {
echo &#039;&#60;a [...]]]></description>
			<content:encoded><![CDATA[<p>Since WordPress doesn&#8217;t allow for limiting the category in &#8220;the_category&#8221; I had to write some custom code to achieve limiting the categories displayed for the current post to the current category and it&#8217;s parent.</p>
<pre class="brush: php">
&lt;?php //display the current and parent category (2 total)
$category = get_the_category();
$current_category = $category[0];
$parent_category = $current_category-&gt;category_parent;
if ( $parent_category != 0 ) {
echo &#039;&lt;a href=&quot;&#039; . get_category_link($parent_category) . &#039;&quot;&gt;&#039; . get_cat_name($parent_category) . &#039;&lt;/a&gt;&#039;;
}
echo &#039;&lt;a href=&quot;&#039; . get_category_link($current_category) . &#039;&quot;&gt;&#039; . $current_category-&gt;cat_name . &#039;&lt;/a&gt;&#039;;
?&gt;
</pre>
<p>props: <a href="http://plugin-developer.com/blog/">Nick</a></p>
]]></content:encoded>
			<wfw:commentRss>http://dancameron.org/code/displaying-a-posts-current-category-and-parent-category-only/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Adding Content Between Posts &#8211; WordPress Loop</title>
		<link>http://dancameron.org/code/adding-content-between-posts-wordpress-loop</link>
		<comments>http://dancameron.org/code/adding-content-between-posts-wordpress-loop#comments</comments>
		<pubDate>Mon, 19 Jan 2009 06:09:47 +0000</pubDate>
		<dc:creator>dancameron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[theming]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress themes]]></category>

		<guid isPermaLink="false">http://dancameron.org/?p=2959</guid>
		<description><![CDATA[Here&#8217;s a simple trick I&#8217;ve been using to include an ad after the second post, however you could modify the location.

&#60;?php if ( $count == 1 ) : ?&#62;
  &#60;div class=&#34;special&#34;&#62;
   Content Here
  &#60;/div&#62;
&#60;?php endif // ( $count == 2 ) ?&#62;

&#60;?php $count++ ?&#62;
&#60;?php endwhile; ?&#62;

Notice the code is added just [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a simple trick I&#8217;ve been using to include an ad after the second post, however you could modify the location.</p>
<pre class="brush: php">
&lt;?php if ( $count == 1 ) : ?&gt;
  &lt;div class=&quot;special&quot;&gt;
   Content Here
  &lt;/div&gt;
&lt;?php endif // ( $count == 2 ) ?&gt;

&lt;?php $count++ ?&gt;
&lt;?php endwhile; ?&gt;
</pre>
<p>Notice the code is added just before the</p>
<pre class="brush: php">
&lt;?php endwhile; ?&gt;
</pre>
<p>in your loop.</p>
]]></content:encoded>
			<wfw:commentRss>http://dancameron.org/code/adding-content-between-posts-wordpress-loop/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Premium WordPress Themes and Plugins Inherit the GPL license</title>
		<link>http://dancameron.org/code/premium-wordpress-themes-and-plugins-inherit-the-gpl-license</link>
		<comments>http://dancameron.org/code/premium-wordpress-themes-and-plugins-inherit-the-gpl-license#comments</comments>
		<pubDate>Sat, 20 Dec 2008 00:00:11 +0000</pubDate>
		<dc:creator>dancameron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[gpl]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[revolution]]></category>
		<category><![CDATA[sproutventure]]></category>
		<category><![CDATA[themes]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://dancameron.org/?p=2834</guid>
		<description><![CDATA[The issue had come up again when over 200 themes were kicked out of the WP theme repository recently, most likely the plugins repo will see the same fait. In a recent meeting Matt&#8217;s perspective was clear: If a plugin or theme makes a call to any WP function then that plugin or theme technically falls [...]]]></description>
			<content:encoded><![CDATA[<p>The issue had come up again when over 200 themes were kicked out of the WP theme repository recently, most likely the plugins repo will see the same fait. In a <a href="http://recordings.talkshoe.com/TC-34224/TS-173505.mp3" rel="shadowbox[post-2834];player=flv;width=500;height=0;">recent meeting</a> Matt&#8217;s perspective was clear: If a plugin or theme makes a call to any WP function then that plugin or theme technically falls under GPL. Which pretty much means, any distributing theme or plugin inherits the the GPL regardless if it&#8217;s being sold or freely released.</p>
<p>Internal private use of that code, like the work I do for clients, is fine but if the theme or plugin is ever distributed in any way then full source code must be offered to everyone. </p>
<p>Looking back at this post, which I stopped following since it wasn&#8217;t going anywhere, I noticed <a href="http://themeshaper.com/blog/the-ethics-of-premium-wordpress-themes/#comment-5565">Samuel</a> sums up the entire issue.</p>
<blockquote><p>This is a really interesting discussion. As someone who has been involved with open source and the GPL for over a decade, it has never ceased to amaze me some of the common misconceptions about the GPL by some of its most ardent and vocal supporters.<br />
First of all to clarify the legal issues surrounding the GPL. It is perfectly legal to sell GPL software. The obligation that a distributor of GPL software has, whether for profit or not, is to provide the source code of the GPL work to the distributee. This is where the GPL doesn’t precisely fit source-only code models. However, I could sell an obfuscated php version of the theme, and I would still be obligated to provide the source to anyone I sold it to. That said, there’s nothing preventing someone I’ve sold it to from giving it away for free after the fact.<br />
The prevailing analysis about copyright is true: Work that is not directly tied to a GPL work (through API’s) is not required to be GPL, therefore images and CSS which can be used independently of the php templates can be released under any license of the creator’s choosing. They can be combined in the same distribution package. The GPL does not ‘infect’ proprietary code it is distributed with. To correctly follow the GPL, however, the php parts that use the API should retain the GPL notices.<br />
This mess could have been avoided by the theme API being under the LGPL which allows linking without license inheritance.<br />
Now as for Matt’s comments about vendors being ‘disrespectful’ to the community, I think that’s an unproductive way of viewing the situation. Premium distributors offer a value-add to the community in a different way than open contributors. Not everyone feels that their time spent coding should be released as a free for all back into the wild. It’s great for us that there are some that do. But open source software in general would not be in the strong position it is today without the aid of commercial support. There’s room for everyone at the table.</p></blockquote>
<p>Since I&#8217;ve moved to 90% WP development I&#8217;ve seen a lot of Premium theme shops pop up , I&#8217;ve even thought about creating a few but when I look at the long term business model I don&#8217;t see it flourishing. Flourishing: for the community and the business as a whole.</p>
<p>This is where I give <a href="http://www.revolutiontwo.com/">revolution themes</a> a lot of respect. I love what they&#8217;re doing, I&#8217;ve even used some of their themes as a base, and I&#8217;m sure they&#8217;re going to do much better for themselves than they would have just selling premium themes.</p>
]]></content:encoded>
			<wfw:commentRss>http://dancameron.org/code/premium-wordpress-themes-and-plugins-inherit-the-gpl-license/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
<enclosure url="http://recordings.talkshoe.com/TC-34224/TS-173505.mp3" length="55140570" type="audio/mpeg" />
		</item>
		<item>
		<title>Excluding categories in the_category</title>
		<link>http://dancameron.org/code/excluding-categories-in-the_category</link>
		<comments>http://dancameron.org/code/excluding-categories-in-the_category#comments</comments>
		<pubDate>Mon, 15 Dec 2008 19:30:01 +0000</pubDate>
		<dc:creator>dancameron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[codex]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://dancameron.org/?p=2822</guid>
		<description><![CDATA[This morning I needed to use the the_category tag but I needed to exclude a tag via a category name.

&#60;?php
	//exclude these from displaying
	$exclude = array(&#34;Hood Newz&#34;);

	//set up an empty categorystring
	$catagorystrings = array();

	//loop through the categories for this post
	foreach((get_the_category()) as $category)
	{
		//if not in the exclude array
		if (!in_array($category-&#62;cat_name, $exclude))
		{
			$catagorystrings[] = &#039;&#60;a href=&#34;&#039;.get_bloginfo(url).get_option(&#039;category_base&#039;).&#039;/&#039;.$category-&#62;slug.&#039;&#34;&#62;&#039;.$category-&#62;name.&#039;&#60;/a&#62;&#039;;
		}
	}
	echo join(&#039;, &#039;,$catagorystrings);
?&#62;

If you&#8217;re looking to [...]]]></description>
			<content:encoded><![CDATA[<p>This morning I needed to use the the_category tag but I needed to exclude a tag via a category name.</p>
<pre class="brush: php">
&lt;?php
	//exclude these from displaying
	$exclude = array(&quot;Hood Newz&quot;);

	//set up an empty categorystring
	$catagorystrings = array();

	//loop through the categories for this post
	foreach((get_the_category()) as $category)
	{
		//if not in the exclude array
		if (!in_array($category-&gt;cat_name, $exclude))
		{
			$catagorystrings[] = &#039;&lt;a href=&quot;&#039;.get_bloginfo(url).get_option(&#039;category_base&#039;).&#039;/&#039;.$category-&gt;slug.&#039;&quot;&gt;&#039;.$category-&gt;name.&#039;&lt;/a&gt;&#039;;
		}
	}
	echo join(&#039;, &#039;,$catagorystrings);
?&gt;
</pre>
<p>If you&#8217;re looking to exclude the category across the entire theme through a filter, you can add this to your funtion.php file.</p>
<pre class="brush: php">
function the_category_filter($thelist,$separator=&#039; &#039;) {
	if(!defined(&#039;WP_ADMIN&#039;)) {
		//list the category names to exclude
		$exclude = array(&#039;Something&#039;,&#039;Something Else&#039;,&#039;Blah&#039;,&#039;YAY&#039;);
		$cats = explode($separator,$thelist);
		$newlist = array();
		foreach($cats as $cat) {
			$catname = trim(strip_tags($cat));
			if(!in_array($catname,$exclude))
				$newlist[] = $cat;
		}
		return implode($separator,$newlist);
	} else
		return $thelist;
}
add_filter(&#039;the_category&#039;,&#039;the_category_filter&#039;,10,2);
</pre>
<p>Thanks to the <a href="http://wordpress.org/support/topic/140469">WordPress Forums</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://dancameron.org/code/excluding-categories-in-the_category/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Find out if ImageMagick is installed in Linux</title>
		<link>http://dancameron.org/code/find-out-if-imagemagick-is-installed-in-linux</link>
		<comments>http://dancameron.org/code/find-out-if-imagemagick-is-installed-in-linux#comments</comments>
		<pubDate>Tue, 09 Dec 2008 20:59:26 +0000</pubDate>
		<dc:creator>dancameron</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://dancameron.org/?p=2802</guid>
		<description><![CDATA[Just a simple command I found.
$convert -version
Normally I would use yum but I didn&#8217;t have the privileges.
]]></description>
			<content:encoded><![CDATA[<p>Just a simple command I found.</p>
<pre class="brush: bash">$convert -version</pre>
<p>Normally I would use yum but I didn&#8217;t have the privileges.</p>
]]></content:encoded>
			<wfw:commentRss>http://dancameron.org/code/find-out-if-imagemagick-is-installed-in-linux/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Displaying Category Description from a Slug (category_description)</title>
		<link>http://dancameron.org/code/displaying-category-description-from-a-slug-category_description</link>
		<comments>http://dancameron.org/code/displaying-category-description-from-a-slug-category_description#comments</comments>
		<pubDate>Tue, 02 Dec 2008 21:12:47 +0000</pubDate>
		<dc:creator>dancameron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[codex]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress development]]></category>

		<guid isPermaLink="false">http://dancameron.org/?p=2784</guid>
		<description><![CDATA[The WordPress Codex only covers circumstances when you need a category description from an ID or category_name. 
Here&#8217;s a method for getting a category description based off a slug

&#60;?php
echo category_description(get_category_by_slug(&#039;category-slug&#039;)-&#62;term_id);
?&#62;

]]></description>
			<content:encoded><![CDATA[<p>The WordPress Codex only covers circumstances when you need a category description from an ID or category_name. </p>
<p>Here&#8217;s a method for getting a category description based off a slug</p>
<pre class="brush: php">
&lt;?php
echo category_description(get_category_by_slug(&#039;category-slug&#039;)-&gt;term_id);
?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://dancameron.org/code/displaying-category-description-from-a-slug-category_description/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom Category Pages (in_category and get_cat_id)</title>
		<link>http://dancameron.org/code/custom-category-pages-in_category-and-get_cat_id</link>
		<comments>http://dancameron.org/code/custom-category-pages-in_category-and-get_cat_id#comments</comments>
		<pubDate>Tue, 11 Nov 2008 01:13:53 +0000</pubDate>
		<dc:creator>dancameron</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://dancameron.org/?p=2678</guid>
		<description><![CDATA[I&#8217;m currently working on a theme that I need to make custom category pages and single pages. I have a plugin almost ready for re-release but instead I went the template route.
One of the first issues I found, the in_category function doesn&#8217;t support the category name, 

&#60;?php
if (in_category(&#039;CATEGORY-NAME&#039;)) {
	load_template(TEMPLATEPATH . &#039;/category-special.php&#039;);
	}
else {
	get_header();
	load_template(TEMPLATEPATH . &#039;/category-default.php&#039;);
}  [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently working on a theme that I need to make custom category pages and single pages. I have a plugin almost ready for re-release but instead I went the template route.</p>
<p>One of the first issues I found, the in_category function doesn&#8217;t support the category name, </p>
<pre class="brush: php">
&lt;?php
if (in_category(&#039;CATEGORY-NAME&#039;)) {
	load_template(TEMPLATEPATH . &#039;/category-special.php&#039;);
	}
else {
	get_header();
	load_template(TEMPLATEPATH . &#039;/category-default.php&#039;);
}  ?&gt;
</pre>
<p>and since this client requires the category name (because of multiple development environments having different category ids) a simple get_cat_id retrieved the category ID for in_category. Example,</p>
<pre class="brush: php">
&lt;?php
if ( in_category(get_cat_id(&#039;CAT NAME&#039;)) ) {
	load_template(TEMPLATEPATH . &#039;/category-CATNAME-template.php&#039;);
	}
else {
	get_header();
	load_template(TEMPLATEPATH . &#039;/category-default.php&#039;);
}  ?&gt;
</pre>
<p>So, the above code will replace the category.php file but make sure to copy the existing code to a new template, in the example above use category-default.php. The rest should be self explanatory.</p>
]]></content:encoded>
			<wfw:commentRss>http://dancameron.org/code/custom-category-pages-in_category-and-get_cat_id/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Name your Widgets for WP Theme Development</title>
		<link>http://dancameron.org/code/name-your-widgets-for-wp-theme-development</link>
		<comments>http://dancameron.org/code/name-your-widgets-for-wp-theme-development#comments</comments>
		<pubDate>Mon, 03 Nov 2008 20:54:23 +0000</pubDate>
		<dc:creator>dancameron</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://dancameron.org/?p=2602</guid>
		<description><![CDATA[One of my current projects includes of 6 widgets areas for customization. I wont go into detail of why :). And if you&#8217;re either making a theme for yourself or for others it&#8217;s always a good idea to be very explicit, that way you don&#8217;t have to explain the what/where/why.
So, instead of running through the [...]]]></description>
			<content:encoded><![CDATA[<p>One of my current projects includes of 6 widgets areas for customization. I wont go into detail of why :). And if you&#8217;re either making a theme for yourself or for others it&#8217;s always a good idea to be very explicit, that way you don&#8217;t have to explain the what/where/why.</p>
<p>So, instead of running through the total amount of sidebars you want in the functions.php file, example below:</p>
<pre class="brush: php">
if ( function_exists(&#039;register_sidebars&#039;) )
    register_sidebars(3,array(
        &#039;before_widget&#039; =&gt; &#039;&lt;div class=&quot;side-box&quot;&gt;&#039;,
        &#039;after_widget&#039; =&gt; &#039;&lt;/div&gt;&#039;,
        &#039;before_title&#039; =&gt; &#039;&lt;h5&gt;&#039;,
        &#039;after_title&#039; =&gt; &#039;&lt;/h5&gt;&#039;,
    ));
</pre>
<p>create an array of widgets &#8211; naming each one, example below:</p>
<pre class="brush: php">
if ( function_exists(&#039;register_sidebars&#039;) )
register_sidebar(array(
   	&#039;name&#039; =&gt; &#039;Left Sidebar Top&#039;,
   	&#039;before_widget&#039; =&gt; &#039;&lt;div class=&quot;side-box&quot;&gt;&#039;,
   	&#039;after_widget&#039; =&gt; &#039;&lt;/div&gt;&#039;,
   	&#039;before_title&#039; =&gt; &#039;&lt;h5&gt;&#039;,
   	&#039;after_title&#039; =&gt; &#039;&lt;/h5&gt;&#039;,
));

register_sidebar(array(
   	&#039;name&#039; =&gt; &#039;Home Announcement&#039;,
   	&#039;before_widget&#039; =&gt; &#039;&lt;div class=&quot;side-box&quot;&gt;&#039;,
   	&#039;after_widget&#039; =&gt; &#039;&lt;/div&gt;&#039;,
   	&#039;before_title&#039; =&gt; &#039;&lt;h5&gt;&#039;,
   	&#039;after_title&#039; =&gt; &#039;&lt;/h5&gt;&#039;,
));

register_sidebar(array(
   	&#039;name&#039; =&gt; &#039;Right Sidebar Top&#039;,
   	&#039;before_widget&#039; =&gt; &#039;&lt;div class=&quot;side-box&quot;&gt;&#039;,
   	&#039;after_widget&#039; =&gt; &#039;&lt;/div&gt;&#039;,
   	&#039;before_title&#039; =&gt; &#039;&lt;h5&gt;&#039;,
   	&#039;after_title&#039; =&gt; &#039;&lt;/h5&gt;&#039;,
));
</pre>
]]></content:encoded>
			<wfw:commentRss>http://dancameron.org/code/name-your-widgets-for-wp-theme-development/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress Gallery [short codes] and custom fields</title>
		<link>http://dancameron.org/code/wordpress-gallery-short-codes-and-custom-fields</link>
		<comments>http://dancameron.org/code/wordpress-gallery-short-codes-and-custom-fields#comments</comments>
		<pubDate>Wed, 22 Oct 2008 06:15:43 +0000</pubDate>
		<dc:creator>dancameron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[web-development]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress development]]></category>
		<category><![CDATA[wordpress themes]]></category>

		<guid isPermaLink="false">http://dancameron.org/?p=2580</guid>
		<description><![CDATA[As a follow up to my recent post on custom fields I ran into another issue revolved around plugins or the built in WordPress gallery codes not working in custom fields.
Since those codes only work inside the post/page&#8217;s content a filter needs to be applied.
Nothing has changed the setup:

ID, &#039;slideshow&#039;, true); ?&#62;

and instead of,

&#60;? php echo [...]]]></description>
			<content:encoded><![CDATA[<p>As a follow up to my <a href="http://dancameron.org/general/creating-a-page-loop-with-a-custom-select-query">recent post on custom fields</a> I ran into another issue revolved around plugins or the built in WordPress gallery codes not working in custom fields.</p>
<p>Since those codes only work inside the post/page&#8217;s content a filter needs to be applied.</p>
<p>Nothing has changed the setup:</p>
<pre class="brush: php">
ID, &#039;slideshow&#039;, true); ?&gt;
</pre>
<p>and instead of,</p>
<pre class="brush: php">
&lt;? php echo $image; ?&gt;
[/sourcecode ]
we&#039;ll apply the filter,
[sourcecode language=&#039;php&#039;]
&lt;? php
$img = &#039;&#039;.$image.&#039;&#039;;
$img = apply_filters(&#039;the_content&#039;, $img );
echo $img;
?&gt;;
</pre>
<p>This could help in appending your custom fields too, for example you could setup the custom field for a code input only and wrap the value. Example,<br />
[sourcecode language='php']<br />
$id = &#8221;&#8221;;<br />
$id = apply_filters(&#8216;the_content&#8217;, $id );<br />
echo $id;<br />
[/sourcecode ]<br />
A value &#8220;3&#8243; would create &#8220;&#8220;.</p>
<p><a href="http://wordpress.org/support/topic/188887">props to the WP forums</a></p>
]]></content:encoded>
			<wfw:commentRss>http://dancameron.org/code/wordpress-gallery-short-codes-and-custom-fields/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Creating a Page Loop with a Custom Select Query</title>
		<link>http://dancameron.org/code/creating-a-page-loop-with-a-custom-select-query</link>
		<comments>http://dancameron.org/code/creating-a-page-loop-with-a-custom-select-query#comments</comments>
		<pubDate>Thu, 16 Oct 2008 05:11:59 +0000</pubDate>
		<dc:creator>dancameron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[sproutventure]]></category>
		<category><![CDATA[web-dev]]></category>
		<category><![CDATA[web-development]]></category>
		<category><![CDATA[wordpress development]]></category>

		<guid isPermaLink="false">http://dancameron.org/?p=2562</guid>
		<description><![CDATA[I hit a roadblock today in one of my projects, it requires a page template that would display a list of pages. Listing posts based on a category is basic with query_posts but I needed to do the same thing for pages. I ended up posting a tweet and Dean responded shortly after with a link [...]]]></description>
			<content:encoded><![CDATA[<p>I hit a roadblock today in one of my projects, it requires a page template that would display a list of pages. Listing posts based on a category is basic with query_posts but I needed to do the same thing for pages. I ended up posting a <a href="http://twitter.com/dancameron/statuses/961408077">tweet</a> and <a href="http://twitter.com/deanjrobinson/statuses/961429494">Dean</a> responded shortly after with a link to the WordPress codex explaining the custom select query (I love the -web-).</p>
<p>After reading though the <a href="http://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_Query">doc</a> I was able to create this:</p>
<pre class="brush: php">
&lt;?php
$querystr = ”
    SELECT wposts.*
    FROM $wpdb-&gt;posts wposts, $wpdb-&gt;postmeta wpostmeta
    WHERE wposts.ID = wpostmeta.post_id
    AND wpostmeta.meta_key = ‘repertory’
    AND wposts.post_type = ‘page’
    ORDER BY wpostmeta.meta_value DESC
 ”;
 $pageposts = $wpdb-&gt;get_results($querystr, OBJECT);
?&gt;
 &lt;?php if ($pageposts): ?&gt;
  &lt;?php foreach ($pageposts as $post): ?&gt;
    &lt;?php setup_postdata($post); ?&gt;
</pre>
<p>I&#8217;ll break it down just a little, you can read the doc if you&#8217;d like to learn more.</p>
<p>    
<pre class="brush: php">AND wpostmeta.meta_key = &#039;page-category&#039; </pre>
<p>&#8220;page-category&#8221; is the key that I&#8217;ve assigned to the page. This is creating a category for your pages. I don&#8217;t recommend creating these false categories if unnecessary, use tags, I&#8217;m using these because I need to sort the pages based on the value.</p>
<p>    
<pre class="brush: php">AND wposts.post_type = &#039;page&#039; </pre>
<p>Basically, only display pages.</p>
<p>    
<pre class="brush: php">ORDER BY wpostmeta.meta_value DESC</pre>
<p>Finally, sort the pages based on the key value.</p>
]]></content:encoded>
			<wfw:commentRss>http://dancameron.org/code/creating-a-page-loop-with-a-custom-select-query/feed</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>How to install and setup postgresql for Fedora/linux</title>
		<link>http://dancameron.org/code/how-to-install-and-setup-postgresql-for-fedoralinux-2</link>
		<comments>http://dancameron.org/code/how-to-install-and-setup-postgresql-for-fedoralinux-2#comments</comments>
		<pubDate>Wed, 07 Nov 2007 23:52:54 +0000</pubDate>
		<dc:creator>dancameron</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://dancameron.org/?p=2656</guid>
		<description><![CDATA[I needed to install postgresql for tiny tiny rss an online rss application I recently found. And I was having problems with the application not connecting to the db after following these instructions.
I scoured the Internet and pieced together what needed to be done.
Step 1. Install Postgresql
My server runs Fedora core 2 so I ran [...]]]></description>
			<content:encoded><![CDATA[<p>I needed to install <a href="http://www.postgresql.org/">postgresql</a> for <a href="http://bah.spb.su/~fox/tt-rss/">tiny tiny rss</a> an online rss application I recently found. And I was having problems with the application not connecting to the db after following <a href="http://www.flmnh.ufl.edu/linux/install_postgresql.htm">these</a> instructions.<br />
I scoured the Internet and pieced together what needed to be done.</p>
<p><strong>Step 1. Install Postgresql</strong><br />
My server runs Fedora core 2 so I ran this fro mt he command line:</p>
<p><code>yum -y install postgresql postgresql-server php-pgsql </code></p>
<p><strong>Step 2 .  Configure Postgresql</strong><br />
From the command line:</p>
<p><code>$ vi /var/lib/pgsql/data/postgresql.conf<br />
- change tcpip_socket = true<br />
$ vi /var/lib/pgsql/data/pg_hba.conf<br />
- add:local all all trust<br />
host all all 127.0.0.1 255.255.255.255 trust<br />
host all all 0.0.0.0 255.255.255.255 reject</code><br />
Or through a text editor just edit these files:<br />
open /var/lib/pgsql/data/postgresql.conf<br />
and change tcpip_socket = true (make sure to uncomment the line)<br />
open /var/lib/pgsql/data/pg_hba.conf<br />
and add these 3 lines to the bottom, no need to edit anything else.<br />
local all all trust<br />
host all all 127.0.0.1 255.255.255.255 trust<br />
host all all 0.0.0.0 255.255.255.255 reject</p>
<p><strong>Step 3. Restart Postgresql</strong><br />
I use</p>
<p>service postgresql restart<br />
you can replace restart with start.</p>
<p>Step 4. Create a DB<br />
from the command line:</p>
<p><code>su - postgres</code><br />
<code>createdb db_name </code></p>
<p><strong>Step 5. Create a postgresql username and password for the newly created DB</strong><br />
<code>createuser -P -U postgres db_username</code><br />
This command will initiate an user creation script.</p>
<p><code> Enter password for user "db_username":<br />
Enter it again:<br />
Shall the new user be allowed to create databases? (y/n) y<br />
Shall the new user be allowed to create more new users? (y/n) y<br />
CREATE USER</code></p>
<p>The CREATE USER statement indicates that the command was successful.</p>
<p><strong>Step 6. Restart Postgresql again</strong></p>
<p><strong>Step 7. Test your connection</strong><br />
from root:<br />
<code>psql -U web_user web_database</code></p>
<p><strong>Step 8. It&#8217;s all up to you. I installed <a href="http://phppgadmin.sourceforge.net/">phpPgAdmin</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://dancameron.org/code/how-to-install-and-setup-postgresql-for-fedoralinux-2/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to backup Plesk</title>
		<link>http://dancameron.org/code/how-to-backup-plesk</link>
		<comments>http://dancameron.org/code/how-to-backup-plesk#comments</comments>
		<pubDate>Tue, 07 Nov 2006 23:51:58 +0000</pubDate>
		<dc:creator>dancameron</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://dancameron.org/?p=2653</guid>
		<description><![CDATA[The following procedure makes a complete backup of Plesk. The backup includes the domain and account structures, domain names, email accounts.
1. 	You would need to log into the server through ssh.
2. 	Change into a directory were you would like the backup of Plesk to be saved. In this example I have made a directory called [...]]]></description>
			<content:encoded><![CDATA[<p>The following procedure makes a complete backup of Plesk. The backup includes the domain and account structures, domain names, email accounts.</p>
<blockquote><p>1. 	You would need to log into the server through ssh.</p>
<p>2. 	Change into a directory were you would like the backup of Plesk to be saved. In this example I have made a directory called backup and changed into this directory</p>
<p># mkdir home/backup</p>
<p># cd home/backup/</p>
<p>3. 	Type the following the command to start the Plesk backup procedure. This would make a complete backup (-F), to the directory location /home/backup (-f)</p>
<p># /usr/local/psa/bin/psadump -F -f /home/backup/</p>
<p>You will see the messages that the backup is in progress. After you will see the message</p>
<p>&#8220;Server backup is successfully completed&#8221;</p>
<p>4. 	After the backup is complete you can check the archive file which looks similar to;</p>
<p><code>1 root root 7568786 Oct 11 12:14 psa-7.1.4-p15160828.pureserver.info-20041011.12.archive<br />
</code><br />
You may now save this file to another server via FTP if you wish.</p>
<p>NOTE: A ftp backup of Plesk can also be done using the following format<br />
<code>: @</code> storing the backup file on remote ftp server.<br />
5. 	To restore the backup you would need to change back into the home/backup directory and run the following command</p>
<p><code>/usr/local/psa/bin/psarestore -f psa-7.1.4-p15160828.pureserver.info-20041011.12.archive -m map_ip -s shell_ma</code></p>
<p>NOTE:</p>
<p>The restore backup might fail on the 1st run. The reason for this is Plesk looks for the map_ip and shell_map files which may not be located, so on the first run it creates the files. If you run the restore command again the procedure would now start to restore Plesk on the system. If you do not get the following message then run the command again for the third time;</p>
<p>&#8220;Server restoration is completed&#8221;</p>
<p>You can also review the psadump and psarestore logs located at /var/log/ on the server.</p>
<p>Additional options that can be used for making the backup</p>
<p>Options:<br />
* 	-h &#8211; This help.<br />
* 	-F &#8211; Make (f)ull dump(it is default option, -C option is not supported now).<br />
* 	-z &#8211; Enable gzip compression for result dump file.<br />
* 	-f<br />
* 	/fullpath/filename &#8211; regular file,<br />
* 	/fullpath/ &#8211; dir for dumpfile with default name,<br />
* 	- &#8211; use stdout for output,<br />
* 	: @</p></blockquote>
<p>I prefer not to do it this way because the file is too large, making a daily backup very tedious. Most importantly, you cannot roll back your plesk server to an earlier version this way unless you keep the old backup as well. It is a matter of preference and the users ability.</p>
<p>I recomend tar&#8217;ing your backups separately.</p>
<p>Create Cron jobs that back up each of the following directory&#8217;s</p>
<blockquote><p>/boot:<strong> Files important for boot process</strong><br />
/etc: <strong>System configuration files</strong><br />
/home:<strong> Domains and home directories of users</strong><br />
/root: <strong>Homedirectory of root</strong><br />
/var/lib/mysql:<strong> MySQL-Databases</strong><br />
/var/logs: <strong>Log-files</strong><br />
/var/spool/mail: <strong>User-mailboxes</strong><br />
/var/spool/cron: <strong>Cron-Jobs</strong><br />
/usr/lib/python2.1/site-packages: <strong>PLESK Configuration </strong></p>
<p>Here is an example:<br />
<code>15	1	*	*	*	tar czvf /home/backup/sql.tar.gz /var/lib/mysql</code></p></blockquote>
<p>This will run at 1:15am everyday of every week and of every month and back up the /var/lib/mysql directory naming it sql.tar.gz and storing it in the /home/backup directory.</p>
<p>I store my backups in a newly created directory under my home directory because of space. *Please note*: if you do the same, you must not backup the whole /home directory because if you do you will create an infinite loop, backing up your backup, over and over.</p>
<p>I also recomend you backup domains individually so you are not stuck with a huge tar file. Restoration depends on how fast you can upload your data and set-up the server, that is why I choose the later because I can easily reconfigure plesk and individually upload the tars 10 times faster then uploading a 2 gig file that takes a long time to execute.</p>
]]></content:encoded>
			<wfw:commentRss>http://dancameron.org/code/how-to-backup-plesk/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
