<?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>Distracted by Squirrels</title>
	<atom:link href="http://www.distractedbysquirrels.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.distractedbysquirrels.com</link>
	<description>My virtual playground</description>
	<lastBuildDate>Sun, 02 Dec 2012 15:45:11 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Making your Footer stay put when having a fixed Header</title>
		<link>http://www.distractedbysquirrels.com/blog/making-your-footer-stay-put-with-css-when-having-a-fixed-header/</link>
		<comments>http://www.distractedbysquirrels.com/blog/making-your-footer-stay-put-with-css-when-having-a-fixed-header/#comments</comments>
		<pubDate>Tue, 17 Jan 2012 13:22:21 +0000</pubDate>
		<dc:creator>Sebastian</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[bottom]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[fixed]]></category>
		<category><![CDATA[footer]]></category>
		<category><![CDATA[header]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[layout]]></category>

		<guid isPermaLink="false">http://www.distractedbysquirrels.com/?p=1407</guid>
		<description><![CDATA[I am currently developing a small web application for the department I am working at. Everything was looking good until I ran into a problem with the layout last week. It bugged me that the footer was placed directly after the content. It just looked wrong. So I googeled to find a way to have a non-fixed footer that stays at the bottom of the window as long as there is enough space. If the windows is to small the footer should be bedhin the content (so you have to scroll down in order to reach the footer). Usually an easy task. Set the body width to 100%, add an negative margin, which is the same height as the footer should be and you&#8217;re done. In my case there was a little detail that smashed my approach: The layout has an fixed header navigation plus a top padding of the body so that the beginning of the content is not hidden beneath the navigation. Read on to find a (hopefully good) solution to fix that. Making your Footer stay put with CSS (w/o fixed header) There are a lot of tutorials, who explain how to accomplish that. After my little<p><a class="more-link" href="http://www.distractedbysquirrels.com/blog/making-your-footer-stay-put-with-css-when-having-a-fixed-header/">read more</a></p>]]></description>
				<content:encoded><![CDATA[<p>I am currently developing a small web application for the <a href="http://www.imtek.de/cpi/">department</a> I am working at. Everything was looking good until I ran into a problem with the layout last week. It bugged me that the footer was placed directly after the content. It just looked wrong. So I googeled to find a way to have a non-fixed footer that stays at the bottom of the window as long as there is enough space. If the windows is to small the footer should be bedhin the content (so you have to scroll down in order to reach the footer).</p>
<p>Usually an easy task. Set the body width to 100%, add an negative margin, which is the same height as the footer should be and you&#8217;re done. In my case there was a little detail that smashed my approach: The layout has an fixed header navigation plus a top padding of the body so that the beginning of the content is not hidden beneath the navigation.</p>
<p>Read on to find a (hopefully good) solution to fix that.<br />
<span id="more-1407"></span></p>
<h3>Making your Footer stay put with CSS (w/o fixed header)</h3>
<p>There are a lot of tutorials, who explain how to accomplish that. After my little research I would say that <a href="http://fortysevenmedia.com/blog/archives/making_your_footer_stay_put_with_css/">this one</a> from <a href="http://fortysevenmedia.com/">Forty Sevenmedia</a> is the best one. Basically, you set your footer to a specific height and add a negative margin with the same value as the footer height to the content. The last child of for content has to be a <em>clear:both</em>. Also with the same height as the footer. Here is a little visualization what it does:</p>
<a class="zoomimg" title="Making your Footer stay put with CSS" href="http://www.distractedbysquirrels.com/wp-content/uploads/2012/01/footer-bottom.png"><img alt="Making your Footer stay put with CSS" src="http://www.distractedbysquirrels.com/wp-content/uploads/2012/01/footer-bottom.png" /></a>
<h3>Footer at bottom with a fixed header</h3>
<p>If you have an fixed header in your layout the above method does work as long as you don&#8217;t add an padding to the <em>body</em>-element. But you kinda have to, otherwise some content will be hidden under your header.</p>
<p>You could use JavaScript to align the footer the way you want it. But I am not a big fan of using JavaScript for something like this. Especially if the solution could easily be achieved using only CSS. But sticking with the body padding does not work. At least I couldn&#8217;t find a solution if you want to keep the padding. The good news is: You don&#8217;t have to. But sometimes it is impossible to see the forest for the trees.</p>
<p>Instead of using the padding to align the content use an additional element with the height set to your former padding value. I chose not to support IE7/8 because the deparment&#8217;s IT support (which is actually me) forces you to use Chrome or Firefox. This way I was able to use peusdo element. The following example will also use them, but if you have to <a href="http://css-tricks.com/browser-support-pseudo-elements/">support bad browsers</a> use <em>div</em>-element instead. Personally, I feel that using <em>:before</em> and <em>:after</em> is just cleaner (HTML-wise).</p>
<h3>The HTML</h3>
<pre class="brush: xml; title: ; notranslate">
&lt;header class=&quot;navbar navbar-fixed&quot;&gt;
    This is the Header
&lt;/header&gt;
&lt;div class=&quot;content&quot;&gt;
    &lt;div class=&quot;container&quot;&gt;
        &lt;p&gt;Some content.&lt;/p&gt;
    &lt;/div&gt;
&lt;/div&gt;
&lt;footer&gt;
    This is the footer, which will stay at the bottom!
&lt;/footer&gt;
</pre>
<h3>The CSS</h3>
<pre class="brush: css; title: ; notranslate">
html, body {
    height: 100%;
}

header, footer { display:block; text-align: center; }

header { height:30px; background-color:#f5f5f5 }

.navbar-fixed {
  left: 0;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 1030;
}

.content {
    position: relative;
    min-height: 100%;
    height: auto !important;
    margin-bottom: -50px; /* the bottom margin is the negative value of the footer's height */
}

.content:before {
    display: table;
    content: &quot;&quot;;
    height: 40px;  /* the value of the header's height */
    zoom: 1;
}

.container:after {
    display: table;
    content: &quot;&quot;;    
    clear: both;
    height: 50px;
}

footer {
    height: 50px;
    position: relative;
    background-color:#dddddd;
}


footer:before {
    content: &quot;.&quot;;
    visibility: hidden;
    display: table;
    height: 0;
    clear: both;
}
</pre>
<h3>Conclusion</h3>
<p>Sometimes you rack your brain and in the end the solution is just so simple. If you want to see it in action take a loot at the jsFiddle demo:</p>
<div class="action-buttons"><a class="goto-demo" href="http://jsfiddle.net/distractedBySquirrels/3hYUr/">Demo</a></div>
<p>Here is a example what it could look like (the mentioned application <em>wip</em>):</p>
<img title="Making your Footer stay put with CSS when having a fixed Header" alt"Making your Footer stay put with CSS when having a fixed Header" src="http://www.distractedbysquirrels.com/wp-content/uploads/2012/01/fixed-header-bottom-footer.png" />
]]></content:encoded>
			<wfw:commentRss>http://www.distractedbysquirrels.com/blog/making-your-footer-stay-put-with-css-when-having-a-fixed-header/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WordPress: Rearrange category order</title>
		<link>http://www.distractedbysquirrels.com/blog/wordpress-rearange-category-order/</link>
		<comments>http://www.distractedbysquirrels.com/blog/wordpress-rearange-category-order/#comments</comments>
		<pubDate>Fri, 21 Oct 2011 07:52:29 +0000</pubDate>
		<dc:creator>Sebastian</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[category]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.distractedbysquirrels.com/?p=1380</guid>
		<description><![CDATA[Just recently I ran into a problem with the category order. The oldest category was &#8220;New Publications&#8221;. So dividing the items based on their category and then looping over them would always put items from the &#8220;New Publications&#8221;-category at the end of the page, which is rather unpleasant. WordPress sadly has no option to rearrange the order of categories (at least I couldn&#8217;t find it). Snippet Here is the snippet that solves the problem: What it does After querying for the categories (line 1) it loops through all categories until it (hopefully) finds the desired category. If the category was found it is saved into a new variable and removed from the category array (line 2-8). Line 11 inserts the category again at the beginning of the array. Now you can iterate through the categories and display your items and the new publications will always be the first displayed category.]]></description>
				<content:encoded><![CDATA[<p>Just recently I ran into a problem with the category order. The oldest category was &#8220;New Publications&#8221;. So dividing the items based on their category and then looping over them would always put items from the &#8220;New Publications&#8221;-category at the end of the page, which is rather unpleasant. WordPress sadly has no option to rearrange the order of categories (at least I couldn&#8217;t find it).<br />
<span id="more-1380"></span></p>
<h3>Snippet</h3>
<p>Here is the snippet that solves the problem:</p>
<pre class="brush: php; title: ; notranslate">
$categories = get_terms('books_category');
      
for( $i=0; $i&lt;sizeof($categories); $i++ ){
  if ( $categories[$i]-&gt;name == 'New Publications' ) :
    $latest = array($categories[$i]);
    unset($categories[$i]);
  endif;
}

if( isset($latest) )
  array_splice( $categories, 0, 0, $latest );
</pre>
<h3>What it does</h3>
<p>After querying for the categories (line 1) it loops through all categories until it (hopefully) finds the desired category. If the category was found it is saved into a new variable and removed from the category array (line 2-8). Line 11 inserts the category again at the beginning of the array. Now you can iterate through the categories and display your items and the new publications will always be the first displayed category.</p>
Greetings,<br/><img class="sig" src="http://www.distractedbysquirrels.com/wp-content/themes/DistractedBySquirrels/img/sig.png" alt="Sebastian"/>
]]></content:encoded>
			<wfw:commentRss>http://www.distractedbysquirrels.com/blog/wordpress-rearange-category-order/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Fancy fixed Navigation powered by jQuery</title>
		<link>http://www.distractedbysquirrels.com/blog/one-page-layout-with-fixed-navigation-and-jquery/</link>
		<comments>http://www.distractedbysquirrels.com/blog/one-page-layout-with-fixed-navigation-and-jquery/#comments</comments>
		<pubDate>Wed, 20 Apr 2011 10:00:22 +0000</pubDate>
		<dc:creator>Sebastian</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[animate]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[layout]]></category>
		<category><![CDATA[one page]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[portfolio]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://www.distractedbysquirrels.com/?p=1337</guid>
		<description><![CDATA[Last week I redid my work page. It was hard to navigate through the page without a second navigation. So I used the chance to tinker around with jQuery. The goal was to provide an alternative to scrolling through the content. Also, it should be much easier to navigate through the page. In this post I explain how to create a simple page layout with fixed navigation. jQuery is used to enhance usability of the the navigation even more.This includes animated scrolling, aligning the navigation to sections and a fancy fading effect. Step 1: Basic HTML First of all we have to create some basic HTML layout to work with. Nothing fancy, just a sidebar and a content area like this: Step 2: Adding the CSS Now that we have the basic layout we position the element. Float the content div to the right and fix the position of the navigation list. Don&#8217;t forget to set a width for the list and the content. Otherwise the content will float over your navigation. The added width should be equal to the parent width. Don&#8217;t forget that padding is also added to the total width. Step 3: Aligning the navigation The navigation<p><a class="more-link" href="http://www.distractedbysquirrels.com/blog/one-page-layout-with-fixed-navigation-and-jquery/">read more</a></p>]]></description>
				<content:encoded><![CDATA[<img title="One Page Layout" alt"One Page Layout" src="http://www.distractedbysquirrels.com/wp-content/uploads/2011/04/one_page_fixed_nav.png" />
<p>Last week I redid my work page. It was hard to navigate through the page without a second navigation. So I used the chance to tinker around with jQuery. The goal was to provide an alternative to scrolling through the content. Also, it should be much easier to navigate through the page.</p>
<p>In this post I explain how to create a simple page layout with fixed navigation. jQuery is used to enhance usability of the the navigation even more.This includes animated scrolling, aligning the navigation to sections and a fancy fading effect.<br />
<span id="more-1337"></span><br />
<div class="action-buttons"><a class="goto-demo" href="http://demo.distractedbysquirrels.com/one_page_fixed_nav/">Demo</a><a class="download-src" href="http://www.distractedbysquirrels.com/wp-content/uploads/2011/04/one_page_fixed_nav.zip">Download</a></div></p>
<h3>Step 1: Basic HTML</h3>
<p>First of all we have to create some basic HTML layout to work with. Nothing fancy, just a sidebar and a content area like this:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;div id=&quot;wrapper&quot;&gt;
	&lt;div id=&quot;sidebar&quot;&gt;
		&lt;ul id=&quot;navigation&quot;&gt;
			&lt;li&gt;&lt;a id=&quot;navfirst&quot; class=&quot;current&quot; href=&quot;#&quot;&gt;First Section&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a id=&quot;navsecond&quot; href=&quot;#&quot;&gt;Second Section&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a id=&quot;navthird&quot; href=&quot;#&quot;&gt;Third Section&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a  id=&quot;navtop&quot;href=&quot;#&quot;&gt;Back to top&lt;/a&gt;&lt;/li&gt;
		&lt;/ul&gt;
	&lt;/div&gt;
	&lt;div id=&quot;content&quot;&gt;
		&lt;div class=&quot;section&quot; id=&quot;first&quot;&gt;
			&lt;!--  content goes here --&gt;	
		&lt;/div&gt;
		&lt;div class=&quot;section&quot; id=&quot;second&quot;&gt;
			&lt;!--  content goes here --&gt;
		&lt;/div&gt;
		&lt;div class=&quot;section&quot; id=&quot;third&quot;&gt;
			&lt;!--  content goes here --&gt;
		&lt;/div&gt;
	&lt;/div&gt; 
&lt;/div&gt;
</pre>
<h3>Step 2: Adding the CSS</h3>
<p>Now that we have the basic layout we position the element. Float the content div to the right and fix the position of the navigation list. Don&#8217;t forget to set a width for the list and the content. Otherwise the content will float over your navigation. The added width should be equal to the parent width. Don&#8217;t forget that padding is also added to the total width.</p>
<pre class="brush: css; title: ; notranslate">
#wrapper {
    width: 850px;
    margin: 50px auto;
    overflow: hidden;
}

#sidebar ul {
position: fixed;
	width: 180px;
}

#content {
float: right;
width: 630px;
padding: 0 20px 20px;
}
</pre>
<h3>Step 3: Aligning the navigation</h3>
<p>The navigation is sticky already but the distance to the top will never change. This doesn&#8217;t look good and it could possibly cause some problems. E.g. the navigation can overlap with subsequent content. To prevent this from happening we&#8217;ll use some jQuery.</p>
<pre class="brush: jscript; title: ; notranslate">
// distance to the window
var navOffset 	= 15;
// navigation is aligned to #content
var minTop = $('#content').offset().top,
	maxTop = $('#content').height()+minTop-$('#navigation').height();		
// place navigation
var currentScroll = $(window).scrollTop();
$('#navigation').css({'top' : minTop});
// align navigation after loading
if( currentScroll &amp;gt; minTop &amp;amp;&amp;amp; currentScroll &amp;lt; maxTop ) {
	// while scrolling though the content
	$('#navigation').css({'top' : navOffset+'px'});		
}
if( currentScroll &amp;lt;= minTop ) {
	// adjust navigation top to content top
	$('#navigation').css({'top' : minTop-currentScroll});
}
if( currentScroll &amp;gt;= maxTop ) {
	// end of content
	$('#navigation').css({'top' : maxTop-currentScroll});
}	
</pre>
<p>This code will align the navigation to top edge of the content div and when you start scrolling it will fit the navigation to top edge as long as it is in the browser&#8217;s viewport (line 14-17). While scrolling though the site the navigation will have a certain distance to the viewport (predetermined by <em>navOffset</em>; line 10-13) and when the end of the content div is reached the navigation will align with the bottom of the content (line 18-21). We have to call the code after the page has loaded and when the scroll event is triggered.</p>
<h3>Step 4: Jump to a section</h3>
<p>Instead of a simple jump via an HTML anchor we&#8217;ll use the power of jQuery and scroll smoothly to the anchor.</p>
<pre class="brush: jscript; title: ; notranslate">
//navigation click actions	
$('#navfirst').click(function(event) {
	event.preventDefault();
	scrollToID('#first', 500);
});	
$('#navsecond').click(function(event) {
	event.preventDefault();
	scrollToID('#second', 500);
});
$('#navthird').click(function(event) {
	event.preventDefault();
	scrollToID('#third', 500);
});
$('#navtop').click(function(event) {
	event.preventDefault();
	$('html, body').animate({scrollTop:0}, 'slow'); 		
});
</pre>
<p>Here is the helper function for the scrolling:</p>
<pre class="brush: jscript; title: ; notranslate">
function scrollToID(id, speed){
	var offSet = 15;
	var targetOffset = $(id).offset().top-offSet;
	$('html,body').animate({scrollTop:targetOffset}, speed);
}
</pre>
<h3>Step 4: Display current position</h3>
<p>The last thing we have to do is displaying the current position. To do this we fade out every section except the one we are currently in and color the section name in the navigation.</p>
<pre class="brush: jscript; title: ; notranslate">
var fadeSpeed = 300;
// indicator for current position in the document
if(	(winScroll + navOffset) &amp;lt; secondTop ) {
	// current section = first
	$('#navfirst').css({'color' : '#CC0000'});
	$('#navsecond').css({'color' : '#FFFFFF'});
	$('#navthird').css({'color' : '#FFFFFF'});
	// animate
	$('#navfirst').stop().stop().animate({ opacity: 1.0 }, fadeSpeed);
	$('#navsecond').stop().animate({ opacity: 0.2 }, fadeSpeed);
	$('#navthird').stop().animate({ opacity: 0.2 }, fadeSpeed);
	$('#navtop').stop().animate({ opacity: 0.2 }, fadeSpeed);		
} else if ( (winScroll + navOffset) &amp;lt; thirdTop &amp;amp;&amp;amp; (winScroll &amp;lt;= maxTop) ) {
	// current section = second
	$('#navfirst').css({'color' : '#FFFFFF'});
	$('#navsecond').css({'color' : '#CC0000'});
	$('#navthird').css({'color' : '#FFFFFF'});
	// animate
	$('#navsecond').stop().animate({ opacity: 1.0 }, fadeSpeed);
	$('#navfirst').stop().animate({ opacity: 0.2 }, fadeSpeed);
	$('#navthird').stop().animate({ opacity: 0.2 }, fadeSpeed);
	$('#navtop').stop().animate({ opacity: 0.2 }, fadeSpeed);			
} else {
	// current section = third
	$('#navfirst').css({'color' : '#FFFFFF'});
	$('#navsecond').css({'color' : '#FFFFFF'});
	$('#navthird').css({'color' : '#CC0000'});
	// animate
	$('#navthird').stop().animate({ opacity: 1.0 }, fadeSpeed);
	$('#navsecond').stop().animate({ opacity: 0.2 }, fadeSpeed);			
	$('#navfirst').stop().animate({ opacity: 0.2 }, fadeSpeed);
	$('#navtop').stop().animate({ opacity: 0.2 }, fadeSpeed);				
}
// current section = last section &amp;amp; if end of page is reached
if ($('body').height() &amp;lt;= ($(window).height() + $(window).scrollTop())) {
	// current section = design
	$('#navfirst').css({'color' : '#FFFFFF'});
	$('#navsecond').css({'color' : '#FFFFFF'});
	$('#navthird').css({'color' : '#CC0000'});
	// animate
	$('#navthird').stop().animate({ opacity: 1.0 }, fadeSpeed);
	$('#navsecond').stop().animate({ opacity: 0.2 }, fadeSpeed);			
	$('#navfirst').stop().animate({ opacity: 0.2 }, fadeSpeed);
	$('#navtop').stop().animate({ opacity: 0.2 }, fadeSpeed);			
}			
</pre>
<h3>Step 5: Final touch</h3>
<p>This step is optional but gives the navigation a nice touch. By adding the following code the navigation items will fade in on hover.</p>
<pre class="brush: jscript; title: ; notranslate">
var hoverSpeed = 200;
// on hover
$('#navigation a').hover(function(e) {
	$(this).hoverFlow(e.type, { opacity: 1.0 }, hoverSpeed);
}, function(e) {
	if( $(this).hasClass('current') || $('html,body').is(':animated') ) return false;
	$(this).hoverFlow(e.type, { opacity: 0.2 }, hoverSpeed);
}); 
</pre>
<p>Since this would also include the current section we have to filter it. This is done by the <em>current</em>-class, which has to be added and remove when entering or leaving a section. E.g.:</p>
<pre class="brush: jscript; title: ; notranslate">
$('#navfirst').addClass('current');
$('#navsecond').removeClass('current');
$('#navthird').removeClass('current');	
</pre>
<h3>Conclusion</h3>
<p>That&#8217;s it! If you have any questions or suggestions don&#8217;t hesitate to post a comment below.</p>
<div class="action-buttons"><a class="goto-demo" href="http://demo.distractedbysquirrels.com/one_page_fixed_nav/">Demo</a><a class="download-src" href="http://www.distractedbysquirrels.com/wp-content/uploads/2011/04/one_page_fixed_nav.zip">Download</a></div>
Greetings,<br/><img class="sig" src="http://www.distractedbysquirrels.com/wp-content/themes/DistractedBySquirrels/img/sig.png" alt="Sebastian"/>
]]></content:encoded>
			<wfw:commentRss>http://www.distractedbysquirrels.com/blog/one-page-layout-with-fixed-navigation-and-jquery/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>Realigning tanzmusik-online.de</title>
		<link>http://www.distractedbysquirrels.com/blog/realigning-tanzmusik-online-de/</link>
		<comments>http://www.distractedbysquirrels.com/blog/realigning-tanzmusik-online-de/#comments</comments>
		<pubDate>Fri, 08 Apr 2011 07:00:39 +0000</pubDate>
		<dc:creator>Sebastian</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[online]]></category>
		<category><![CDATA[realign]]></category>
		<category><![CDATA[tanzmusik]]></category>
		<category><![CDATA[tmo]]></category>

		<guid isPermaLink="false">http://www.distractedbysquirrels.com/?p=1298</guid>
		<description><![CDATA[A good friend of mine, named Simon, is webmaster at tanzmusik-online.de. If you wanna dance to your favorite song, but don&#8217;t know what, this is the place to go to. It is almost impossible to not find your song because the data base behind the website is huge and every new submission is personally validated by Simon. A lot of work but it&#8217;s worth it. The songs range from Abba to ZZ Top, from Pop to Heavy Metal and from &#8217;70 until today. But there is one thing that&#8217;s bothering me. The design doesn&#8217;t fit the great service. 2006 was the last time the website got a new skin. But in it looks more like a millennium design. In this post I&#8217;ll present some ideas, which hopefully help to improve the usability and appearance for the next design. The front page When you land on the front page you&#8217;ll see a lot of stuff. You cannot focus on one thing. There is an ad for the community, a small banner, whose only purpose is to be there, some news, the newest submissions and so on, and so on. The problem is not that there is too much stuff on the<p><a class="more-link" href="http://www.distractedbysquirrels.com/blog/realigning-tanzmusik-online-de/">read more</a></p>]]></description>
				<content:encoded><![CDATA[<img title="Realigning tanzmusik-online.de" alt"Realigning tanzmusik-online.de" src="http://www.distractedbysquirrels.com/wp-content/uploads/2011/04/tmo_front.png" />
<p>A good friend of mine, named Simon, is webmaster at <a href="http://www.tanzmusik-online.de">tanzmusik-online.de</a>. If you wanna dance to your favorite song, but don&#8217;t know what, this is the place to go to. It is almost impossible to not find your song because the data base behind the website is huge and every new submission is personally validated by Simon. A lot of work but it&#8217;s worth it. The songs range from Abba to ZZ Top, from Pop to Heavy Metal and from &#8217;70 until today.</p>
<p>But there is one thing that&#8217;s bothering me. The design doesn&#8217;t fit the great service. 2006 was the last time the website got a new skin. But in it looks more like a millennium design. In this post I&#8217;ll present some ideas, which hopefully help to improve the usability and appearance for the next design.<br />
<span id="more-1298"></span></p>
<h3>The front page</h3>
<p>When you land on the front page you&#8217;ll see a lot of stuff. You cannot focus on one thing. There is an ad for the community, a small banner, whose only purpose is to be there, some news, the newest submissions and so on, and so on. The problem is not that there is too much stuff on the front page. The alignment is just not quite right and a new visitor has no clue what the purpose of the website is. The latter bothers me the most. Instead of the banner and the community ad, tell the visitor what he/she can do here! There is enough space below for the rest.</p>
<p>The possibility to search is obviously the most important part, but on the front page (and every other page) there is only this little search field at the upper right. TMO (TanzMusik-Online) is more or less a search engine, thus the search field should be easily visible at all time. At least on the front page I would suggest a big search form.</p>
<p>The rest of the information presented on the front page can be summarized. The news, which inform about site updates, don&#8217;t need to be on the front page. It would be better to have a small blog for that. Rather put the last submission, charts and a tag cloud on the front page. These three are the most important information for new and returning visitors. The top submitter and top dances are nice to know at most.</p>
<p>This leaves us with a layout like this:</p>
<img title="New layout for tanzmusik-online.de" alt"New layout for tanzmusik-online.de" src="http://www.distractedbysquirrels.com/wp-content/uploads/2011/04/tmo_layout.png" />
<p>I also created some drafts, which outline a possible &#8220;update&#8221; for the design. The graphics shouldn&#8217;t be fancy or awesome. They are awesome if they support the usability.</p>
<p><a class="zoomimg" title="New header for TMO" href="http://www.distractedbysquirrels.com/wp-content/uploads/2011/04/tmo_header.png"><img alt="New header for TMO" src="http://www.distractedbysquirrels.com/wp-content/uploads/2011/04/tmo_header.png" /></a> <a class="zoomimg" title="Intro for TMO" href="http://www.distractedbysquirrels.com/wp-content/uploads/2011/04/tmo_intro.png"><img alt="Intro for TMO" src="http://www.distractedbysquirrels.com/wp-content/uploads/2011/04/tmo_intro.png" /></a></p>
<p>Since I moved the navigation to the top and made it horizontal there is not enough space for every sub items anymore. Some of them are redundant and can be removed (e.g. home, search). The dance sub menu (&#8220;Latein&#8221;, &#8220;Standard&#8221;, &#8220;Modetänze&#8221;) on the other hand is very important for browsing the site. I propose another solution for the navigation dilemma. Everything not listed in the navigation will be moved to the footer.</p>
<a class="zoomimg" title="New TMO navigation" href="http://www.distractedbysquirrels.com/wp-content/uploads/2011/04/tmo_dropdown.png"><img alt="New TMO navigation" src="http://www.distractedbysquirrels.com/wp-content/uploads/2011/04/tmo_dropdown.png" /></a>
<h3>Search Results</h3>
<p>Another important part is the listings of songs. The listing is used everywhere (e.g. display charts, search results or dance categories). This is how the look right now:</p>
<a class="zoomimg" title="Current TMO listing" href="http://www.distractedbysquirrels.com/wp-content/uploads/2011/04/tmo_old_listing.png"><img alt="Current TMO listing" src="http://www.distractedbysquirrels.com/wp-content/uploads/2011/04/tmo_old_listing.png" /></a>
<p>And this is my proposal:</p>
<a class="zoomimg" title="New TMO listing" href="http://www.distractedbysquirrels.com/wp-content/uploads/2011/04/tmo_list.png"><img alt="New TMO listing" src="http://www.distractedbysquirrels.com/wp-content/uploads/2011/04/tmo_list.png" /></a>
<p>Yeah, I made it bigger. But this doesn&#8217;t necessary means that it&#8217;s better. But in this case the additional space provides more readability. I think the old listing displayed too much information. The details should be displayed later.</p>
<h3>Social Networks</h3>
<p>The current design is old and because of this there is no integration of social networks. I am not sure if Simon wants to implement social networking or if he will solely rely on his own message board. I certainly would add some Twitter and Facebook buttons to (hopefully) improve the conversion rate even further.</p>
<p>At least a TMO Facebook page should be considered. Nobody has a guestbook anymore. It is so convenient to use Facebook instead. This also may help boost the forum, because you can sign up with your Facebook account.</p>
<h3>Conclusion</h3>
<p>The designs presented are all drafts. They should be considered anchor points for further development. I promised Simon that as soon as I finished my blog I would help him redesigning TMO. This posting illustrates my first thoughts on what (in my opinion) has to improve.</p>
<p>Now is your turn. Do you have some suggestions? What do you like/dislike about the current TMO?</p>
Greetings,<br/><img class="sig" src="http://www.distractedbysquirrels.com/wp-content/themes/DistractedBySquirrels/img/sig.png" alt="Sebastian"/>
]]></content:encoded>
			<wfw:commentRss>http://www.distractedbysquirrels.com/blog/realigning-tanzmusik-online-de/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WordPress: Improved dynamic Excerpt</title>
		<link>http://www.distractedbysquirrels.com/blog/wordpress-improved-dynamic-excerpt/</link>
		<comments>http://www.distractedbysquirrels.com/blog/wordpress-improved-dynamic-excerpt/#comments</comments>
		<pubDate>Mon, 04 Apr 2011 07:00:12 +0000</pubDate>
		<dc:creator>Sebastian</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[excerpt]]></category>
		<category><![CDATA[functions.php]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.distractedbysquirrels.com/?p=1259</guid>
		<description><![CDATA[Let’s be honest, the default WordPress excerpt function is bad. It is nice to have access to a quick post summary but the only thing you can control is the length, which refers to the first x words of the post’s content. But that is not enough if you have limited space. The length will differ widely from word to word. Aside from that the excerpt will almost always cut off mid-sentence, which doesn’t look very nice in my opinion (even if there is the good old [...] at the end). This post will explain how to display an excerpt, which is not longer than a predetermined length and doesn&#8217;t cut off in mid-sentence. Standard excerpt and dynamic length If you take a look at the WordPress Codex the standard procedure to change the excerpt length is as follows: But, as already mentioned, words have different lengths. Even if you take an average word length into account, it will fail sometimes. Therefore it is not sufficient to limit the excerpt by word count, if you have limited space. It also doesn&#8217;t solve the problem with excerpts cutting off in mid-sentence. I searched for a solution and found a very close<p><a class="more-link" href="http://www.distractedbysquirrels.com/blog/wordpress-improved-dynamic-excerpt/">read more</a></p>]]></description>
				<content:encoded><![CDATA[<p>Let’s be honest, the default WordPress excerpt function is bad. It is nice to have access to a quick post summary but the only thing you can control is the length, which refers to the first x words of the post’s content. But that is not enough if you have limited space. The length will differ widely from word to word. Aside from that the excerpt will almost always cut off mid-sentence, which doesn’t look very nice in my opinion (even if there is the good old <em>[...]</em> at the end).</p>
<p>This post will explain how to display an excerpt, which is not longer than a predetermined length and doesn&#8217;t cut off in mid-sentence.<br />
<span id="more-1259"></span></p>
<h3>Standard excerpt and dynamic length</h3>
<p>If you take a look at the <a href="http://codex.wordpress.org/Function_Reference/the_excerpt">WordPress Codex</a> the standard procedure to change the excerpt length is as follows:</p>
<pre class="brush: php; title: ; notranslate">
function new_excerpt_length($length) {
	return 20;
}
add_filter('excerpt_length', 'new_excerpt_length');
</pre>
<p>But, as already mentioned, words have different lengths. Even if you take an average word length into account, it will fail sometimes. Therefore it is not sufficient to limit the excerpt by word count, if you have limited space. It also doesn&#8217;t solve the problem with excerpts cutting off in mid-sentence.</p>
<p>I searched for a solution and found a very close solution for the problem. Sadly I cannot find the source anymore. If anyone knows the origin of the following snippet, please post it in the comments.</p>
<pre class="brush: php; title: ; notranslate">
// Variable excerpt length.
function dynamic_excerpt($length) { // Variable excerpt length. Length is set in characters
	global $post;
	$text = $post-&gt;post_excerpt;
	if ( '' == $text ) {
		$text = get_the_content('');
		$text = apply_filters('the_content', $text);
		$text = str_replace(']]&gt;', ']]&gt;', $text);
	}
	$text = strip_shortcodes($text); // optional, recommended
	$text = strip_tags($text); // use ' $text = strip_tags($text,'&lt;p&gt;&lt;a&gt;'); ' if you want to keep some tags

	$text = substr($text,0,$length);
	// echo $text; // Use this is if you want a unformatted text block
	echo apply_filters('the_excerpt',$text); // Use this if you want to keep line breaks
}
</pre>
<h3>Improving the function</h3>
<p>Although you can determine the length exactly with the previous snippets, it has the same problem the code from the WordPress Codex had. It cuts off excerpts in mid-sentence. But it is still a better solution if you want to have the same length every time. So it satisfies at least one of the two requirements. </p>
<p>In order to not cut off in mid-sentence we only have to adjust the code a little bit. After the excerpt got shortened to the desired length, we search for the last occurrence of a dot. PHP doesn&#8217;t support this. There is only the <a href="http://www.php.net/manual/en/function.strrchr.php"><em>strrchr</em></a>-method, which returns the portion after the last dot. Fortunately someone else posted a reverse-strrchr in the php.net-comments.</p>
<pre class="brush: php; title: ; notranslate">
// Returns the portion of haystack which goes until the last occurrence of needle
function reverse_strrchr($haystack, $needle, $trail) {
    return strrpos($haystack, $needle) ? substr($haystack, 0, strrpos($haystack, $needle) + $trail) : false;
}
</pre>
<h3>Final result</h3>
<p>Just add the following function to the dynamic_excerpt function and it will return an excerpt, which is not longer than the given length and always ends with a complete sentence. Paste the following code to your theme&#8217;s <em>functions.php</em> and you are done.</p>
<pre class="brush: php; title: ; notranslate">
// Variable &amp; intelligent excerpt length.
function print_excerpt($length) { // Max excerpt length. Length is set in characters
	global $post;
	$text = $post-&gt;post_excerpt;
	if ( '' == $text ) {
		$text = get_the_content('');
		$text = apply_filters('the_content', $text);
		$text = str_replace(']]&gt;', ']]&gt;', $text);
	}
	$text = strip_shortcodes($text); // optional, recommended
	$text = strip_tags($text); // use ' $text = strip_tags($text,'&lt;p&gt;&lt;a&gt;'); ' if you want to keep some tags

	$text = substr($text,0,$length);
	$excerpt = reverse_strrchr($text, '.', 1);
	if( $excerpt ) {
		echo apply_filters('the_excerpt',$excerpt);
	} else {
		echo apply_filters('the_excerpt',$text);
	}
}

// Returns the portion of haystack which goes until the last occurrence of needle
function reverse_strrchr($haystack, $needle, $trail) {
    return strrpos($haystack, $needle) ? substr($haystack, 0, strrpos($haystack, $needle) + $trail) : false;
}
</pre>
<p>Here is an example how to use the function in your theme templates. It will return the excerpt with a maximum length of 50 characters and removes everything after the last sentence within the excerpt.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php print_excerpt(50); ?&gt;
</pre>
Greetings,<br/><img class="sig" src="http://www.distractedbysquirrels.com/wp-content/themes/DistractedBySquirrels/img/sig.png" alt="Sebastian"/>
]]></content:encoded>
			<wfw:commentRss>http://www.distractedbysquirrels.com/blog/wordpress-improved-dynamic-excerpt/feed/</wfw:commentRss>
		<slash:comments>28</slash:comments>
		</item>
	</channel>
</rss>
