Two of the toughest obstacle courses Great Britain has to offer

Posted on: No Comments

The Suffering Obstacle Race

There’s a new race in town from Ultimate Adventures and it’s something that should have other obstacle races quaking in their boots.

Don’t get me wrong I’m biased because I’m putting on the race, but I am also someone who has run the course hundreds of times so I’m in a unique position to tell you this is not easy, it’s no where near easy. In fact I would say it truly will be 2 of the toughest races I’ve ever seen. It’s not just the obstacles which trust me will be harsh. It’s not the 12% gradient hill leading up to Rockingham Castle (ask runners in the area, the hill alone is a f*cker!), it’s not the 3 ponds scattered around, one of which is 7 feet deep. It’s all this plus long grass sapping your legs with each stride, it’s hills, valleys and mud. It’s 10′s of acres of Land Rover course. It’s something to be feared, to be trained for and to be respected. It’s called The Suffering for a reason!

Oh and the T-Shirts are really cool!

The Suffering

Twitter For WordPress Fix

Posted on: No Comments

Good day all,
I use twitter for wordpress a great plugin for showing your twitter timeline. The plugin broke yesterday and here’s the fix:
// $messages = fetch_rss(‘http://twitter.com/statuses/user_timeline/’.$username.’.rss’);
$messages = fetch_rss(‘https://api.twitter.com/1/statuses/user_timeline.rss?screen_name=’ . $username);

Pagination, Why So Complicated?

Posted on: No Comments

Hi,

At stylecompare.co.uk we’ve been playing around with our pagination in an effort to increase both “next / prev page clicks” and “view 200 per page”. I found an amazing article on pagination written by Al Stevens on which this work is based. The ideas here are really good. Combining this with a mobile first viewpoint where pagination is normally just next & prev buttons and we where on our way. I’m not gonna go into loads of detail because the article lays out all the stuff we were thinking.

Gamification

With this as a base we have done a few more nice little touches to help increase our targets. First off we added a little bit of gamification in there. How have we done this? Well it’s nothing intrusive or obvious just a bit of a language change. So here at the top of the product list we’re letting the customer know where they are and how many pages there are to get to the end.


gamification


And at the bottom in the 20% advanced customer group we’re giving a bit more. We’re now using larger numbers; the amount of dresses. We’re also giving the customer the ability to get to any page in the dataset. We’ve got a nice bit of instructional text on the next and prev button’s. This cements the purpose of the button and the customer knows exactly what to expect. No nasty surprises here.


gamification - pagination hover


View 20 / View 200 Per Page

The last part of the page is the 2 state view 20 / view 200 tabs. Ideally we want the customer to view a the page at view 200. This is the equivalent of a customer pressing next 10 times, so let’s make this option prominent. We’ve wrapped the product list in what appear to be tabs. Rolling over either the tab or the line has a hover effect, just something to grab the attention. At the top the tab is on left but at the bottom it’s above the next page pagination and more prominent than the pagination link, so the customer is more likely to press view 200 (which is 10 next pages) than view the next 20 dresses. Now that’s pretty cool, but here’s the nice bit. When the customer is in view 200 mode the view 20 tabs are styled to be less prominent making the “See the Next 200 Dresses” link the most prominent.

View 20 / View 200 states


Resources:
A Great Book For Gamefication *: Seductive Interaction Design: Creating Playful, Fun, and Effective User Experiences
Pagination Design Patterns By Al Stevens

* This is an affiliate link

Useful 404 pages

Posted on: No Comments

Hi,

here at Stylecompare we’ve been looking heavily into our 404 / out of stock pages. I think we’ve done some nice work and wanted to share some of the stuff we’ve done.

First question we asked was “what makes a great 404 page?”

There are a million and one best 404 posts so I won’t link to these. What they do have in common is way of lightening a frustrating situation; Whether that be with an amusing graphic or video to keep you entertained. We decided to venture away from this type of 404 page and went for the useful instead. We tend to think of a 404 as a dead end, we offer ways to back track to a happier less 404′y time. But wait let’s see what we can do here. We know some information about what’s happening so let’s open the door instead of shutting it.

We have a few different types of 404 on our site. The first is the “Sorry, this page doesn’t exist”, the second is our out of stock pages. We 404 these pages but return a really useful page to the customer.

Sorry, this page doesn’t exist…

Ahhh… how many times have I seen this kind of page with some standard back to the homepage links and a funny image next to it. Well let’s change this into something a bit more useful. First thing how about making the links relevant. Our first section tries to give you a closest match and if nothing is available we go for the most popular items. John our resident .Net ninja has created some great logic for this. Secondly we offer up a set of 3 standard links:

  1. Visit our homepage
  2. Choose to shop from 52 retailers
  3. Browse over 1,500 labels

We have a cascading route out of the 404, best match, standard links, search and on the left we have opened out the menu so the customer doesn’t need to search for the category they need. We now have something useful that gives customers several options of how to get to something more meaningful.


Here is an example page:
Style Compare 404 page



Out of stock

In retail items go out of stock, it’s a fact of life. Those non-updated links in google can a pain. But how frustrating is that to the customer, well think of the last time you found the perfect item only to be told it wasn’t available. It’s annoying right. Ok, so what can we do about this? Well for a start let’s make the out of stock item look out of stock. We’ve made it smaller, greyed out the text and shown a sorry message. I think saying sorry is important, after all it’s not the customers fault.

Now for the cool part, we’ve got a really nice message that says “Don’t panic – your dream product could be right here.” and a big arrow showing the customer where to go next; we’re using green as a positive colour and to associate it with a next step option. Then we’ve got between 20-60 similar products, so that’s cool we’re giving accurate alternatives. Then at the end of the alternatives we’ve got a green box with additional options which takes the customer back a level to a category page packed full of alternatives. We’re also 404′ing this page, so hopefully when google recrawls us this link will drop out of the listings. We also do some nifty stuff with alternate colourways but that’s for another time. Here’s an example of our new Out Of Stock page.


Style Compare Out Of Stock Page

Function For Related Items

Posted on: No Comments

Hello,
Today I’ve been working on a related items section for wordpress posts. I found some really useful resources (see the end of the post). And set to work. The result is below:


Related Items Box From Style Compare

Related Items Box From Style Compare


The function code

function getRelatedPosts($num, $imgWidth, $imgHeight, $className, $boxTitle) {
        
        // store category objects for current post in an array
	$current_post_categories = get_the_category(); 
	
	$catArray       = array(); // Initiate empty category array
	$posts_array 	= array(); // Initiate empty posts array
	
	$numberOfPosts = 0;
	
	// Puts category IDs into the $catArray
	foreach( $current_post_categories as $category) { 
		array_push($catArray, $category->cat_ID);
	}
	
	// I'm getting a random catID from my array, 
        // if there's only one caetgory we'll just get that
	for ($i=0; $i < $num; $i++) {	
	        
                // -1 because arrays are zero based
		$randomNum = rand(0, (count($catArray)-1)); 
	
		$args = array(
			'numberposts'     => 1,
			'category'        => $catArray[$randomNum],
			'orderby'         => 'post_date',
			'order'           => 'DESC',
			'offset'	  => $i, // add offset so we don't get 
                                                 // the same record again and again
			'exclude'         =>  get_the_ID(), // exlude the current post
			'post_type'       => 'post',
			'post_status'     => 'publish' 
		);		
			
		$posts = get_posts( $args );
		
		if ($posts[0] != "") {
                        // put the post array into a new array
			array_push($posts_array, $posts); 
		}
	}	
	
	$currentPostNumber = count($posts_array);
	$postsLeft = ($num - $currentPostNumber);
	$authorID	= get_the_author_meta();	
	
	// If we still haven't got enough, 
        // let's get the most recent author posts and 
	// stack um high so we have loads to choose from, better safe than sorry
	if ($currentPostNumber < $num) {
		
		for ($i=0; $i < $num; $i++) { 
		
			$args = array(
				'author'	  => $authorID,
				'numberposts'     => 1,
				'offset'	  => $i,
				'orderby'         => 'post_date',
				'order'           => 'DESC',
				'exclude'         =>  get_the_ID(), 
                                // exlude the current post
				'post_type'       => 'post',
				'post_status'     => 'publish' 
			);	
			
			$posts = get_posts( $args );
			
			array_push($posts_array, $posts);
		}
	}
	
	// Let's build our related item's box
	echo '<div class="' . $className . '">';
	echo '<h2>' . $boxTitle . '</h2>';
		echo '<ul>';
	
			for ($i=0; $i<$num; $i++) {
				
				$postID = $posts_array[$i][0]->ID;
				$desc  = $posts_array[$i][0]->post_content;
				
				$first_img = '';
				$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $desc, $matches);
				$first_img = $matches [1] [0];
				
				if(empty($first_img)){ 
                                        //Defines a default image
					$first_img =  "/images/Default-Post-Image.jpg";
				}
				
				$url   = get_permalink($postID);
				$title = $posts_array[$i][0]->post_title;
				
				echo '<li><a href="'. $url .'"><img title="' . $title . '" src="' . $first_img . '" width="' . $imgWidth . 'px" height="' . $imgHeight . 'px"><h3>' . $title . '</h3></a></li>';
			}
	
		echo '</ul>';
	echo '</div>';
}


The CSS for the div

.relatedPostsBox {
	 display: block;
	 border-bottom: dotted 1px #ccc;
	 margin-top: 20px;
	 margin-bottom: 20px;
	 font-family:Tahoma, Geneva, sans-serif;
	 padding-left: 20px;
	 padding-bottom: 20px;
}

.relatedPostsBox h2 {
	 margin-bottom:20px;
}

.relatedPostsBox h3 {
	 font-family:Tahoma, Geneva, sans-serif;
	 font-size:12px;
	 padding:0;
	 margin:0;
}

.relatedPostsBox ul {
	 display:inline-block;
	 list-style:none;
	 list-style-type:none;
	 margin:0;
	 padding:0;
}

.relatedPostsBox li {
	 width: 140px;
	 display:inline-block;
	 float: left;
	 margin-right: 5px;
	 border: 1px #EFEFEF solid;
	 padding:5px;
	 overflow: hidden;
	 min-height:200px;
	 margin-right: 10px;
}

.relatedPostsBox ul img {
	 display: inline;
	 margin-bottom: 10px;
}

.relatedPostsBox ul h3, .relatedPostsBox ul p {
	 width: 140px;
}

.relatedPostsBox ul h3 {
	 margin:0;
	 font-size:11px;
	 line-height:15px;
	 font-weight:bold;
}

.relatedPostsBox ul p {
	 margin:0;
	 font-size:11px;
	 line-height:15px;
}

.relatedPostsBox ul a {
	 text-decoration: none;
	 color: #333;
}

.relatedPostsBox li:hover {
	 border: solid 1px #ccc;
}

Resources:
http://www.daniweb.com/web-development/php/threads/265806/get-the-category-link-inside-the-loop-in-wordpress
http://www.wprecipes.com/how-to-get-the-first-image-from-the-post-and-display-it

Function For Creating Columned Archives Using wp_get_archives

Posted on: No Comments

Hi,
this is a function for creating WordPress wp_get_archives into 12 month columns. I’m using it in conjunction with my archiveRanger function to create columns. An I have used it here at Style Platform in the archives mega menu at the top.


Archive List Style Platform

Archive List Style Platform


The next version will include auto startYear & endYear as well as more customisation of the lists formatting. The formatting here is for Style Platform

I hope you like it.

/*
	 Author: 	Drew Tavernier
	 Name:		archiveAsYears
	 Version:	1.0
	 Explanation:	Used in combination with archiveAsYears() to retrieve 
	 	 	Columned Year Output
	 Usage:		archiveAsYears ('9', '2011');
	 Properties:	archiveAsYears ($startMonth, $startYear)
	  		$startMonth:	Month of the first archive from beginning of time. 
	 	 	 	 	Must be the first month. This will be replaced for
	 	 	 	 	auto date in the next version
			$startYear:	Year of the first archive from beginning of time. 
	 	 	 	 	Must be the first year. This will be replaced for 
	 	 	 	 	auto date in the next version
	  Notes:	Add in auto startYear & endYear
			Add in list formatting when archiveRanger is called
*/					

function archiveAsYears ($startMonth,$startYear ) {
						
	$thisYear  = date("Y");
	$thisMonth = date("n");					
	
	$archiveArray 	= explode('</li>', wp_get_archives('echo=0'));
	$totalMonths 	= count($archiveArray)-1;
						
	$output = "";
						
						
	if ($startYear == $thisYear) {
		// Only one year
		$endArrayPos = $thisMonth - ($startMonth-1);
		$output .= archiveRanger ('<dl class="march-dl">', '</dl>', 0, $endArrayPos, 'custom', '<dd>', '</dd>', true);
	} else {
							
		$startMonth 	-= 1;						
		$year_1_end	= 12 - $startMonth;
							
		$monthsLeft	= $totalMonths - $year_1_end;
		$monthsLeft	= floor($monthsLeft % 12);
							
		$yearsTotal	= floor(($totalMonths - ($monthsLeft + $year_1_end)) / 12);
							
		// Start Year:
		$output .= archiveRanger ('<dl class="march-dl">', '</dl>', 0, $year_1_end, 'custom', '<dd>', '</dd>', true);
							
		// Whole Years
		if ($yearsTotal > 0) {
								
			$yearStart = $year_1_end + 1;
								
			for ($i=0; $i < $yearsTotal; $i++ ) {
									
				$yearStepper 	= $i * 12;
				$yearStart 	= $yearStart + $yearStepper ;
									
				$output .= archiveRanger ('<dl class="march-dl">', '</dl>', $yearStart, $yearStart + 11, 'custom', '<dd>', '</dd>', true);
			}						
		}
	
		// End Months
		if ($monthsLeft > 0) {
			$monthsLeftStart = $totalMonths - ($monthsLeft - 1);
			$output .= archiveRanger ('<dl class="march-dl">', '</dl>', $monthsLeftStart, $totalMonths - 1, 'custom', '<dd>', '</dd>', true);
		}
	}
						
	return $output;
}

Function For Retrieving A Set Number Of Months From wp_get_archives

Posted on: No Comments

Hi,
I’ve been doing a bit more playing around with WordPress. This time I have written a function to get a set number of months from wp_get_archives() with a start and amount returned parameter. It’s even got some nice formatting params in there for you. This shows you how to create a DL list but you can use UL, OL, whatever you want. I’ve started writing comments in my functions now together with version numbers etc, so hopefully this will all make sense.

/*
     Author:		Drew Tavernier
     Name:		archiveRanger
     Version:		1.0
     Explanation:	Retrieve archives months within a range and display in custom format.
			Can be used in combination with archiveAsYears() to retrieve 
			Columned Year Output

     Usage:		archiveRanger ('<dl>', '</dl>', $startNum, $endNum, 'custom', 
			'<dd>', '</dd>', true);

     Properties:	archiveRanger ($startWrap, $endWrap, $startPosition, 
			$endPosition, $format, $before, $after, $show_post_count);

	  		$startWrap: Start of list wrapper, replaces <ul>
			$endWrap: 		End of list wrapper, replaces </ul>
			$startPosition: 	Start Number in array for retrieving data
			$endPosition: 		End Number in array for retrieving data
			$format:		Same as wp_get_archives function
			$before:		Same as wp_get_archives function
			$after:			Same as wp_get_archives function
			$show_post_count: 	Same as wp_get_archives function
*/
					
function archiveRanger ($startWrap, $endWrap, $startPosition, $endPosition, $format, $before, $after, $show_post_count) {
						
	$output = "";
						
	$stringToSplit = wp_get_archives( 
				'type=monthly&limit='	. $monthsInYear . 
				'&show_post_count='	. $show_post_count . 
				'&format='		. $format . 
				'&before='		. $before .
				'&after='		. $after .
				'&echo='		. false
	);
									
	$archiveArray = explode( $before , $stringToSplit );
						
		// delete first empty value
		array_shift($archiveArray); 
						
		// Make sure there is an endPosition value
		if ($endPosition == 0) { 
			$endPosition = sizeof($archiveArray);
		}
						
		// Wrap it up nicely
		$output .= $startWrap;
						
		for ($i = $startPosition; $i <= $endPosition; $i++) {
			$output .= $before . $archiveArray[$i];
		}
						
		$output .= $endWrap;
											
		return $output;
	}					
}

Function For Columns In wp_list_categories

Posted on: 1 Comment

Hello all,
I’ve been working on splitting the wp_list_categories function into columns. Not as easy as one might think, if you’ve tried you’ll know what I mean. So with this in mind I’ve created a function which splits the category list into equal columns based on a list length. I’ve added the ability to customise the output too.

It’s nice and easy. Copy this function into your functions file:


function splitCategorysIntoColumns ($listLength, $before, $after, $replaceULopen, $replaceULclose) {
						
	$categoriesArray 	= explode('</li>', wp_list_categories('echo=0&title_li='));
	$totalCategories 	= count($categoriesArray);	
						
	$columns = ceil($totalCategories / $listLength);
	$catCounter = 0;
						
	for ($i = 0; $i < $columns ; $i++) {
							
		$output .= $replaceULopen;
			for ($j = 0; $j < $listLength; $j++) {
								
				$output .= $categoriesArray[$catCounter] . $after; // replace exploded value with new value
								
				$catCounter ++;
				if ($catCounter > $totalCategories) { 
					break; 
				}
			}
							
			$output .= $replaceULclose;
							
	}

	$output = str_replace('<li', $before, $output);

	return $output;
}

Then just echo this function when ever you want it split:
splitCategorysIntoColumns ($listLength, $before, $after, $replaceULopen, $replaceULclose)

Here are the properties:

$listLength:		The amount of items in each column
$before:		Replaces <li , <li can be used here if you need it
$after:			Replaces </li> , </li> can be used here if you need it
$replaceULopen		Replaces <ul> , <ul> can be used here if you need it
$replaceULclose		Replaces </ul> , </ul> can be used here if you need it

Customising WordPress Comments

Posted on: No Comments

Hello,

Welcome to my first tech post. Hopefully this will make sense and be useful.

In the past few days I have been hunting around for comment styling for WordPress. I have found some really great articles but no solid here’s some code and have fun with it posts. So I have put together a copy and paste version of the comments style on this blog.

Wordpress enables you to have custom comments by use of callbacks. See here for a great post and where I learnt a lot about the wp_list_comments function. http://www.studiograsshopper.ch/code-snippets/customising-wp_list_comments/

Ok, so here’s the code bit:

Firstly we add a new function (themeComments) to the functions.php file, you’ll see I’ve added in some new div tags in so we can style the comments a little easier


function themeComments($comment, $args, $depth) {
   $GLOBALS['comment'] = $comment; ?>
   <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
     <div id="comment-<?php comment_ID(); ?>">
      <div class="comment-author vcard">
		 <div class="comment-by">
         	<?php printf(__('<cite class="fn">%s</cite><br /><span class="says">says:</span>'), get_comment_author_link()) ?>
		 </div>
         <div class="comment-avatar">
		 	<?php echo get_avatar($comment,$size='48' ); ?>
		 </div>
      </div>

	  <div class="commentsWrapper">
		  <?php if ($comment->comment_approved == '0') : ?>
			 <em><?php _e('Your comment is awaiting moderation.') ?></em>
			 <br />
		  <?php endif; ?>

		  <div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"><?php printf(__('%1$s at %2$s'), get_comment_date(),  get_comment_time()) ?></a><?php edit_comment_link(__('(Edit)'),'  ','') ?></div>

		  <?php comment_text() ?>

		  <div class="reply">
			 <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
		  </div>
	 </div>

	 <div class="commentSpeech"></div>

    </div>
<?php
    }

In the comments.php we add in the wp_list_comments params to the callback function and tell wp_list_comments that this is a comment type.


wp_list_comments('type=comment&callback=themeComments');

Then all we need to do is some nice CSS to handle the new code. I've done everything with percentages so you don't need to continually create new styles to cope with different depths of comments. I've tested it down to 10 replies and it still works.

Also all this CSS has resets applied, so if you're not using a reset it will need tweaking.


.comment{
    width:100%;
    margin-bottom:20px;
    clear:both;
}

.comment-meta{
    width:98%;
    padding-bottom:5px;
    border-bottom:1px dashed #ccc;
    font-size:0.9em;
}

.comment-reply-link{
    display:inline-block;
    padding:5px;
    background-color:black;
    color:white;
    font-family:Verdana,Arial,Helvetica,sans-serif;
    margin-top:20px;
}

.comment-meta a{
    color:#666;
}

.comment-by cite{
    font-weight:bold;
}

.comment-by{
    display:block;
    position:relative;
    padding-top:10px;
    padding-bottom:10px;
    top:0;
    text-align:left;
    float:left;
}

.comment-avatar{
    display:block;
    padding-top:10px;
    padding-bottom:10px;
    float:left;
    clear:both;
    border-top:1px dashed #ccc;
}

.commentlist{
    margin:0;
    padding:0;
    margin-top:20px;
    margin-bottom:50px;
    padding-bottom:50px;
}

.commentlist ul,.commentlist li{
    list-style-type:none;
    position:relative;
}

.children{
    padding-left:20px;
}

.comment-author{
    position:relative;
    width:10%;
    float:left;
    display:inline-block;
    margin-bottom:20px;
    margin-bottom:20px;
    border-left:2px solid #009999;
    padding-left:10px;
}

.commentSpeech{
    float:right;
    width:10px;
    display:inline-block;
    background-image:url('_/images/leftArrow.gif');
    background-repeat:no-repeat;
    background-position:0px 10px;
    height:100%;
    min-height:73px;
}

.children .comment .commentsWrapper{
    background-color:#f5f5f5;
}

.commentsWrapper{
    float:right;
    padding:10px;
    border:1px solid #ccc;
    width:81%;
    display:inline-block;
    margin-bottom:20px;
    -moz-box-shadow:2px 2px #eee;
    -webkit-box-shadow:2px 2px #eee;
    box-shadow:2px 2px #eee;
}

And that's it, enjoy!