<?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>Nicolas Kuttler &#187; template</title>
	<atom:link href="http://www.nkuttler.de/tag/template/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nkuttler.de</link>
	<description>WordPress Services, IT Services</description>
	<lastBuildDate>Wed, 28 Jul 2010 23:49:18 +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>How to add support for navigation menus to your WordPress theme</title>
		<link>http://www.nkuttler.de/2010/06/08/wp_nav_menu-wordpress-3-0/</link>
		<comments>http://www.nkuttler.de/2010/06/08/wp_nav_menu-wordpress-3-0/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 15:00:50 +0000</pubDate>
		<dc:creator>nicolas</dc:creator>
				<category><![CDATA[Content Management]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[navigation]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[usability]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress theme]]></category>
		<category><![CDATA[wp_nav_menu]]></category>

		<guid isPermaLink="false">http://www.nkuttler.de/?p=1613</guid>
		<description><![CDATA[The new navigation menus system in WordPress 3.0 looks promising, but in my opinion it&#8217;s not very usable yet. Anyway, here&#8217;s one way to add navigation menus to your theme while maintaining backward compatibility: In your theme&#8217;s functions.php add something like the following code: 1 2 3 4 5 6 7 8 9 10 11 [...]]]></description>
			<content:encoded><![CDATA[<p>The new <a href="http://codex.wordpress.org/Appearance_Menus_SubPanel">navigation menus</a> system in WordPress 3.0 looks promising, but in my opinion it&#8217;s not very usable yet. Anyway, here&#8217;s one way to add navigation menus to your theme while maintaining backward compatibility:</p>
<p>In your theme&#8217;s <code>functions.php</code> add something like the following code:<span id="more-1613"></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> mytheme_addmenus<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	register_nav_menus<span style="color: #009900;">&#40;</span>
		<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'main_nav'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'The Main Menu'</span><span style="color: #339933;">,</span>
		<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'mytheme_addmenus'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> mytheme_nav<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wp_nav_menu'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
        wp_nav_menu<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'menu=main_nav&amp;container_class=pagemenu&amp;fallback_cb=mytheme_nav_fallback'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">else</span>
        mytheme_nav_fallback<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> mytheme_nav_fallback<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    wp_page_menu<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'show_home=Start&amp;menu_class=pagemenu'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>In line 1 we add support for the navigation menus. The <code>mytheme_nav()</code> function is what you will use in the theme to display the menu. Inside that function we check if <code>wp_nav_menu()</code> exists, that means if we&#8217;re running WordPress 3.0 (or later). If not we&#8217;ll use the fallback function <code>mytheme_nav_fallback()</code>.</p>
<p>Notice that the fallback also gets called if no navigation menus have been created in the admin area. That&#8217;s what the <code>fallback_cb</code> parameter on line 4 does.</p>
<p>To keep the HTM markup and the CSS consistent you&#8217;ll have to use the <code>container_class</code> parameter on <code>wp_nav_menu</code> but the <code>menu_class</code> parameter for <code>wp_page_menu</code>.</p>
<p>In your template use the following code to use your new custom function:</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> mytheme_nav<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></pre></div></div>

<h3>Resources</h3>
<ul>
<li><a href="http://codex.wordpress.org/Function_Reference/wp_nav_menu">wp_nav_menu() reference</a></li>
<li><a href="http://codex.wordpress.org/Template_Tags/wp_page_menu">wp_page_menu() reference</a></li>
<li><a href="http://justintadlock.com/archives/2010/06/01/goodbye-headaches-hello-menus">Informative article on nav menus by Justin Tadlock</a></li>
</ul>
<a name="wptoc_0_0_0"></a><h2>Ramblings</h2>
<p>What&#8217;s good about the new menu system:</p>
<ul>
<li>Total control over what appears in the menu</li>
<li>You can add posts, pages, categories and tags in the menu</li>
<li>Very nice drag and drop interface</li>
</ul>
<p>What&#8217;s bad:</p>
<ul>
<li>You will have to teach your users how to use the system properly.</li>
<li>If you create new pages they won&#8217;t be added to your existing menu (except for top level pages).</li>
<li>You can not control your page menus through the navigation menus interface. I think it is&#8230; very very odd that WordPress doesn&#8217;t have a simple drag-and-drop interface to arrange pages.</li>
<li>The previous point means that the new menu system is useless unless you update your theme.</li>
<li>The <code>wp_nav_menu()</code> call is inconsistent with the existing <code>wp_page_menu()</code> function.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.nkuttler.de/2010/06/08/wp_nav_menu-wordpress-3-0/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Nesting WordPress loops</title>
		<link>http://www.nkuttler.de/2010/05/30/wordpress-loop-inside-a-loop/</link>
		<comments>http://www.nkuttler.de/2010/05/30/wordpress-loop-inside-a-loop/#comments</comments>
		<pubDate>Sun, 30 May 2010 13:01:47 +0000</pubDate>
		<dc:creator>nicolas</dc:creator>
				<category><![CDATA[Content Management]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[shortcode]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress loop]]></category>
		<category><![CDATA[WordPress theme]]></category>

		<guid isPermaLink="false">http://www.nkuttler.de/?p=1559</guid>
		<description><![CDATA[Sometimes it&#8217;s useful to put a WordPress loop inside another loop. To do this you&#8217;ll have to create a new WP_Query object, as in this example: $my_query = new WP_Query&#40; &#34;cat=3&#34; &#41;; if &#40; $my_query-&#62;have_posts&#40;&#41; &#41; &#123; while &#40; $my_query-&#62;have_posts&#40;&#41; &#41; &#123; $my_query-&#62;the_post&#40;&#41;; the_content&#40;&#41;; &#125; &#125; $GLOBALS&#91;'post'&#93; = $GLOBALS&#91;'wp_query'&#93;-&#62;post; Restoring $post is necessary because $post->comment_status [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes it&#8217;s useful to put a WordPress loop inside another loop. To do this you&#8217;ll have to create a new <code>WP_Query</code> object, as in this example:<span id="more-1559"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">   <span style="color: #000088;">$my_query</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;">&quot;cat=3&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$my_query</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: #009900;">&#123;</span>
       <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$my_query</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: #009900;">&#123;</span>
           <span style="color: #000088;">$my_query</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>
           the_content<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
       <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
   <span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span>  <span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'wp_query'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post</span><span style="color: #339933;">;</span></pre></div></div>

<p>Restoring <code>$post</code> is necessary because <code>$post->comment_status</code> of the post in the outer loop can be wrong after running the inner loop. That was the only problem I found, by I prefer to restore <code>$post completely</code> just to be sure. WordPress 3.0 has a function <code>wp_reset_postdata()</code> that you can use to restore <code>$post</code>.</p>
<p>I use this technique to show an &#8220;excerpt cloud&#8221; in a post using a <a href="http://codex.wordpress.org/Shortcode_API">shortcode</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nkuttler.de/2010/05/30/wordpress-loop-inside-a-loop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a valid WordPress theme</title>
		<link>http://www.nkuttler.de/2009/09/12/creating-a-valid-wordpress-theme/</link>
		<comments>http://www.nkuttler.de/2009/09/12/creating-a-valid-wordpress-theme/#comments</comments>
		<pubDate>Sat, 12 Sep 2009 10:02:07 +0000</pubDate>
		<dc:creator>nicolas</dc:creator>
				<category><![CDATA[Content Management]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[Webdesign]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress theme]]></category>

		<guid isPermaLink="false">http://www.nkuttler.de//?p=484</guid>
		<description><![CDATA[Recently, I&#8217;ve been checking out some of the blogs that link back to me because they use one of my plugins. And it seems like a lot of them are using buggy, incorrect templates. It looks like many WordPress theme developers don&#8217;t read the theme development checklist. Another fine document that some developers seem to [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I&#8217;ve been checking out some of the blogs that <a href="http://siteexplorer.search.yahoo.com/">link back to me</a> because they use one of my plugins. And it seems like a lot of them are using buggy, incorrect templates. It looks like many WordPress theme developers don&#8217;t read the <a href="http://codex.wordpress.org/Theme_Development_Checklist">theme development checklist</a>.<span id="more-484"></span></p>
<p>Another fine document that some developers seem to ignore is the list of <a href="http://codex.wordpress.org/Theme_Development#Plugin_API_Hooks">plugin API hooks</a>. Please, read that section, and <strong>include these hooks</strong> in your template! Some plugins <b>need</b> that API hook to work at all. My surprisingly popular <a href="http://www.nkuttler.de/nksnow/">snowstorm plugin</a> for example certainly does.</p>
<p>While you&#8217;re at it, think about how you want to style, for example, the <tt>wp_footer()</tt> call. When I visit pages that give me a backlink through that call, sometimes the backlink is displayed in very odd places and with weird colors.</p>
<p>Finally, although it has already been said on the pages I linked to, <strong> get the <a href="http://codex.wordpress.org/Theme_Development_Checklist#.22Theme_Unit_Tests.22">theme unit tests</a></strong> and use them! It&#8217;s quite embarassing for a designer to release buggy WordPress templates.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nkuttler.de/2009/09/12/creating-a-valid-wordpress-theme/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Change Typo3 template depending on column content</title>
		<link>http://www.nkuttler.de/2009/09/05/change-typo3-template-depending-on-column-content/</link>
		<comments>http://www.nkuttler.de/2009/09/05/change-typo3-template-depending-on-column-content/#comments</comments>
		<pubDate>Sat, 05 Sep 2009 07:33:02 +0000</pubDate>
		<dc:creator>nicolas</dc:creator>
				<category><![CDATA[Content Management]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[Typo3]]></category>
		<category><![CDATA[typoscript]]></category>
		<category><![CDATA[usability]]></category>
		<category><![CDATA[Webdesign]]></category>

		<guid isPermaLink="false">http://www.nkuttler.de//?p=852</guid>
		<description><![CDATA[Let&#8217;s assume you don&#8217;t just want to inject some HTML if there is content in a column, but you want to use a completely different layout. This isn&#8217;t hard to accomplish, see the example: tmp.templateFile = COA tmp.templateFile &#123; 10 = COA 10 &#123; if.isFalse.numRows &#60; styles.content.getRight 10 = FILE 10 &#123; file = fileadmin/template/1col.html [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s assume you don&#8217;t just want to <a href="http://www.nkuttler.de//2009/05/24/change-template-if-content-exists-in-typo3/">inject some HTML</a> if there is content in a column, but you want to use a completely different layout. This isn&#8217;t hard to accomplish, see the example:<span id="more-852"></span></p>

<div class="wp_syntax"><div class="code"><pre class="typoscript" style="font-family:monospace;">tmp<span style="color: #339933; font-weight: bold;">.</span>templateFile <span style="color: #339933; font-weight: bold;">=</span> <span style="color: #990000; font-weight: bold;">COA</span>
tmp<span style="color: #339933; font-weight: bold;">.</span>templateFile <span style="color: #009900;">&#123;</span>
	<span style="color: #cc0000;">10</span> <span style="color: #339933; font-weight: bold;">=</span> <span style="color: #990000; font-weight: bold;">COA</span>
	<span style="color: #cc0000;">10</span> <span style="color: #009900;">&#123;</span>
		<span style="font-weight: bold;">if</span><span style="color: #339933; font-weight: bold;">.</span>isFalse<span style="color: #339933; font-weight: bold;">.</span><span style="font-weight: bold;">numRows</span> <span style="color: #339933; font-weight: bold;">&lt;</span> <span style="color: #000066; font-weight: bold;">styles</span><span style="color: #339933; font-weight: bold;">.</span>content<span style="color: #339933; font-weight: bold;">.</span>getRight
		<span style="color: #cc0000;">10</span> <span style="color: #339933; font-weight: bold;">=</span> <span style="color: #990000; font-weight: bold;">FILE</span>
		<span style="color: #cc0000;">10</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">file</span> <span style="color: #339933; font-weight: bold;">=</span> fileadmin<span style="color: #339933; font-weight: bold;">/</span>template<span style="color: #339933; font-weight: bold;">/</span>1col<span style="color: #339933; font-weight: bold;">.</span>html
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #cc0000;">20</span> <span style="color: #339933; font-weight: bold;">=</span> <span style="color: #990000; font-weight: bold;">COA</span>
	<span style="color: #cc0000;">20</span> <span style="color: #009900;">&#123;</span>
		<span style="font-weight: bold;">if</span><span style="color: #339933; font-weight: bold;">.</span>isTrue<span style="color: #339933; font-weight: bold;">.</span><span style="font-weight: bold;">numRows</span> <span style="color: #339933; font-weight: bold;">&lt;</span> <span style="color: #000066; font-weight: bold;">styles</span><span style="color: #339933; font-weight: bold;">.</span>content<span style="color: #339933; font-weight: bold;">.</span>getRight
		<span style="color: #cc0000;">10</span> <span style="color: #339933; font-weight: bold;">=</span> <span style="color: #990000; font-weight: bold;">FILE</span>
		<span style="color: #cc0000;">10</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">file</span> <span style="color: #339933; font-weight: bold;">=</span> fileadmin<span style="color: #339933; font-weight: bold;">/</span>template<span style="color: #339933; font-weight: bold;">/</span>2col<span style="color: #339933; font-weight: bold;">.</span>html
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The <tt>if</tt>s check if there is or isn&#8217;t content in the right column and the <tt>COA</tt> returns the correct cObject, FILE in this case.</p>
<p>And then in your main typoscript something like:</p>

<div class="wp_syntax"><div class="code"><pre class="typoscript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">page</span><span style="color: #339933; font-weight: bold;">.</span>10<span style="color: #339933; font-weight: bold;">.</span>template <span style="color: #339933; font-weight: bold;">&lt;</span> tmp<span style="color: #339933; font-weight: bold;">.</span>templateFile</pre></div></div>

<p>instead of the more usual</p>

<div class="wp_syntax"><div class="code"><pre class="typoscript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">page</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #cc0000;">10</span> <span style="color: #339933; font-weight: bold;">=</span> <span style="color: #990000; font-weight: bold;">TEMPLATE</span>
	<span style="color: #cc0000;">10</span> <span style="color: #009900;">&#123;</span>
		template <span style="color: #339933; font-weight: bold;">=</span> <span style="color: #990000; font-weight: bold;">FILE</span>
		template <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">file</span> <span style="color: #339933; font-weight: bold;">=</span> fileadmin<span style="color: #339933; font-weight: bold;">/</span>template<span style="color: #339933; font-weight: bold;">/</span>1col<span style="color: #339933; font-weight: bold;">.</span>html
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>That&#8217;s all.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nkuttler.de/2009/09/05/change-typo3-template-depending-on-column-content/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
