<?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>Marius Gundersen &#187; php</title>
	<atom:link href="http://www.mariusgundersen.net/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mariusgundersen.net</link>
	<description>MariusGundersen.net</description>
	<lastBuildDate>Fri, 06 Aug 2010 00:34:38 +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>Very simple CMS: project category</title>
		<link>http://www.mariusgundersen.net/2009/11/24/very-simple-cms-project-category/</link>
		<comments>http://www.mariusgundersen.net/2009/11/24/very-simple-cms-project-category/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 14:38:27 +0000</pubDate>
		<dc:creator>Marius</dc:creator>
				<category><![CDATA[CMS]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.mariusgundersen.net/?p=89</guid>
		<description><![CDATA[I made this blog to have a place to post the applications and programs I have made, and for that I needed a Content Management System (CMS). I looked at some CMS plugins for WordPress, but most of them are overkill for what I need. Instead I decided to use the built inn Categories of [...]]]></description>
			<content:encoded><![CDATA[<p>I made this blog to have a place to post the applications and programs I have made, and for that I needed a Content Management System (CMS). I looked at some CMS plugins for WordPress, but most of them are overkill for what I need. Instead I decided to use the built inn Categories of WordPress. I created a category called Project, and for each project (a program, website or anything else I made) I would add a sub-category with that projects name. With this simple method I could create several posts describing the progress of a project. Now all I needed was a page with all the projects listed, and maybe the latest posts for each one.</p>
<p>I solved this by making a page Template (not to be confused with Theme, which is something completely different). The template lists all the subcategories of a category, specified in the page metadata, along with the category description and the last 5 posts for each category. This way you can list all the projects on one page and link to the most recent information for each one. Because the category name is specified in the page metadata, you can have multiple CMS pages, for example, ideas, projects or experiments.<br />
<span id="more-89"></span><br />
Add the template file to /wp-content/themes/&lt;active theme&gt;. To use this template, make a new page, then select the template called &#8216;CMS&#8217; from the list of templates. The content will be shown at the top of the page. Next you need to add a metadata (also called custom field) to the page, with name &#8216;category&#8217; and value equal to the category you want the page to show. You might need to edit the template slightly for it to display properly with your theme.</p>
<pre class="brush: php; html-script: true;">
&lt;?php

/*

Template Name: CMS

*/

?&gt;

&lt;?php get_header(); ?&gt;

&lt;?php if (have_posts()) : the_post(); update_post_caches($posts); ?&gt;

  &lt;div class=&quot;post&quot; id=&quot;post-&lt;?php the_ID(); ?&gt;&quot;&gt;

    &lt;h1&gt;&lt;?php the_title(); ?&gt;&lt;/h1&gt;

    &lt;div class=&quot;content&quot;&gt;

      &lt;?php the_content(); ?&gt;

      &lt;?php if(count(get_post_custom_values('category')) &gt; 0 ): ?&gt;

        &lt;?php $category_slug = get_post_custom_values('category'); $category_slug = $category_slug[0];?&gt;

        &lt;?php if(($category = get_category_by_slug($category_slug)) != null): ?&gt;

          &lt;?php $categories = get_categories(array('child_of' =&gt; $category-&gt;term_id, 'orderby' =&gt; 'name', 'order' =&gt; 'asc')); ?&gt;

          &lt;?php foreach($categories as $category): ?&gt;

            &lt;div class=&quot;post&quot;&gt;

              &lt;h2&gt;&lt;a class=&quot;title&quot; href=&quot;/category/&lt;?php echo $category_slug.&quot;/&quot;.$category-&gt;category_nicename; ?&gt;&quot;&gt;&lt;?php echo $category-&gt;name; ?&gt;&lt;/a&gt;&lt;/h2&gt;

              &lt;div class=&quot;content&quot;&gt;

                &lt;p&gt;&lt;?php echo $category-&gt;description; ?&gt;&lt;/p&gt;

                &lt;!--Latest post --&gt;

                &lt;?php $posts = get_posts(&quot;cat=$category-&gt;term_id&amp;numberposts=5&amp;order=DESC&amp;orderby=date&quot;); ?&gt;

                &lt;h5&gt;Latest posts&lt;/h5&gt;

                &lt;?php foreach($posts as $post): ?&gt;

                  &lt;?php setup_postdata($post); ?&gt;

                  &lt;div class=&quot;content&quot;&gt;

                    &lt;a class=&quot;title&quot; href=&quot;&lt;?php the_permalink(); ?&gt;&quot;&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;

                    &lt;span style=&quot;float:right&quot; class=&quot;date&quot;&gt;&lt;?php the_time(__('F jS, Y', 'inove')); ?&gt;&lt;/span&gt;

                  &lt;/div&gt;

                &lt;?php endforeach; ?&gt;

              &lt;/div&gt;

            &lt;/div&gt;

          &lt;?php endforeach; ?&gt;

        &lt;?php else: ?&gt;

          &lt;div class=&quot;errorbox&quot;&gt;

            &lt;?php echo(&quot;Category '$category_slug' was not found!&quot;); ?&gt;

          &lt;/div&gt;

        &lt;?php endif; ?&gt;

      &lt;?php else: ?&gt;

        &lt;div class=&quot;errorbox&quot;&gt;

          &lt;?php echo(&quot;Add a custom field with name 'category' and value equal to the name of a category&quot;); ?&gt;

        &lt;/div&gt;

      &lt;?php endif; ?&gt;

    &lt;/div&gt;

  &lt;/div&gt;

&lt;?php else : ?&gt;

  &lt;div class=&quot;errorbox&quot;&gt;

    &lt;?php echo('Sorry, no posts matched your criteria.'); ?&gt;

  &lt;/div&gt;

&lt;?php endif; ?&gt;

&lt;?php get_footer(); ?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.mariusgundersen.net/2009/11/24/very-simple-cms-project-category/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
