CSSOff final placement: 34th

OK, this is my first post after months and it’s not the latest news, but still important for me. After waiting a long time i got my scores and feedback from UnmatchedStyle CSSOff 2012.

To put it in a nutshell: Final Score: 68.67pts | Final Placement: 34th

Loving all the custom hover animations in here. Topbar, logo, title, obstacles and prizes all have very fun transitions. Form could use some validation, select input display could be customized more, and I wish the timer did something besides loop. Overall, pretty solid entry.

Yeah! What a surprise! You can watch my result here: http://dl.dropbox.com/u/4799476/CSSOFF-GH/index.html and, if you want, the winners here: CSSOff Winners 2012

WordPress archive for single category

During a new WordPress project I’d the problem to generate an archive just for the “News” category and only for posts until 1998. The wordpress function wp_get_archives dosn’t support such parameters and I also wanted to use the Archive Widget in the sidebar.

At first I added some filters in functions.php:

// join term_relationships and term_taxonomy
 add_filter( 'getarchives_join', 'customarchives_join' );
 // add where condition for category
 add_filter( 'getarchives_where', 'customarchives_where' );
 // add where condition for date
 add_filter('getarchives_where','filter_until_year_archives');
function customarchives_join($join_clause) {
 global $wpdb;
 return $join_clause." INNER JOIN $wpdb->term_relationships ON ($wpdb->posts.ID =  $wpdb->term_relationships.object_id) INNER JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)";
 }
function customarchives_where($where_clause) {
 global $wpdb;
 $include = get_cat_ID('news');  // category id to include
 return $where_clause." AND $wpdb->term_taxonomy.taxonomy = 'category' AND $wpdb->term_taxonomy.term_id IN ($include)";
 }
function filter_until_year_archives($where_clause) {
 $year = '1998.01.01 00:00:00';
 return $where_clause." AND post_date > '".$year."'";
 }

Now you can use the Archive Widget and you’ll only get an archive for the “News” category with posts older than 1998-01-01.

Last of all it’s necessary to edit the archive template in your theme. Because you’ll still get posts from all categories on your archive page.

Add this code to archive.php after get_header and before the loop:

query_posts( $query_string . '&cat='.get_cat_ID('news') );

It’s working on this site: politik-digital.de/category/news/. I applied the Flexo Archive Widget for the archive list in the sidebar .

Rails matching PHP

At first the problem: After the VegiKochbuch relaunch as Rails project I realized that all old links to recipes are broken and this causes a lot of 404 errors.

The old PHP link structure was: http://vegikochbuch.de/rezepte/rezept175.php
And now in Rails it’s: http://vegikochbuch.de/recipes/175

My solution was adding

match '/rezepte/rezept:id.php' => 'recipes#show'

to routes.rb

It works and is realy simple. I don’t really know if this is the best way, but I like it!