May 14th, 2008 by Henrik Melin
Undeniably inspired by the iPod Touch, I put together a WordPress plugin that displays covers in the ‘Coverflow’ fashion. The actual animated browser comes from Weber Design Labs (open source and brilliant), but I hacked it slightly, adding parameters specifying what posts to get using query arguments sent to dymanically generated xml file. I also changed the colours, reflection, and changed the slider from being images to being vectors (so that we can change the colours and scale it).
This is currently being used for the advanced search.
Here’s what it looks like.
Pretty!
Tags: browser, coverflow, covers
Posted in dagensskiva | 1 Comment »
May 2nd, 2008 by Henrik Melin
I thought I’d share my current and favorite, .screenrc settings:
vbell off
autodetach on
defscrollback 10000
startup_message off
pow_detach_msg "Screen session of \$LOGNAME \$:cr:\$:nl:ended."
caption always "%{= gk}%-Lw%{= rW}%50> %n%f* %t %{-}%+Lw%< %= %{= Gk} %H %{= rW} %l %{= Gk} %0c:%s %d/%m %{-}"
shell -$SHELL
Looking like:
From the bottom left to right:
- Screen name ‘tabs’: %-Lw%{= rW}%50> %n%f* %t %{-}%+Lw%<
- Server name: %H
- Server load: %l
- Date & time: %0c:%s %d/%m
I put this togehter a few years ago, back in London, when working at multimap, but I cannot remember where I sourced it from. So, I’m putting it here for posterity.
What is your favourite .screenrc configuration?
Tags: screen screenrc linux osx terminal
Posted in note | No Comments »
April 21st, 2008 by Henrik Melin
For the type of content written for dagensskiva.com the ‘code’ button in the editor has no use whatsoever. Instead we find much more use for a ‘cite’ button, a tag that is frequently added to posts, but there is no button for it. This JavaScript snippet will replace the code button with a functional cite button:
index = edButtons.length;
edButtons[index] = new edButton('ed_cite', 'cite', '<cite>', '<\/cite>','c');
jQuery('#ed_code').attr('value', 'cite');
jQuery('#ed_code').attr('onclick', 'edInsertTag(edCanvas, ' + index + ');');
jQuery('#ed_code').attr('id', 'ed_cite');
This code registers the button, then changes the properties of the ‘code’ button to transform it into a ‘cite’ button. Works in both WordPress 2.3 and 2.5.
Posted in Uncategorized | No Comments »
April 2nd, 2008 by Henrik Melin
For some reason or other there are actions in WordPress that have translatable fields in them, so when these actions are used on other languages than English, they change. They are actions involving the $page_hook variable., e.g. admin_head-$page_hook. I ran into this problem when updating More Fields. The problem in the context of plugins is that the language is not loaded when the plugins are loaded, so that the needed translation is not available. To get around this, the actions requiring translation are called at the ‘admin_init’ action instead.
function mf_pre_queue_js () {
add_action('load-' . sanitize_title(__('Settings')) . '_page_more-fields', 'mf_queue_js');
}
add_action('admin_init', 'mf_pre_queue_js');
I got help with this on the wp-hackers mailng list - a great source for WordPress insights.
>Try adding your actions on the init hook, I think that runs after
>the translatable stuff has been loaded and setup.
Correct.
Everything related to languages should be done at init or later, so that everything is loaded and any plugins that modify the content are loaded.
So, at the init/admin_init hook, we’re safe to assume that the appropriate language has been loaded.
Tags: actions, locale, more fields, plugin, wordpress
Posted in wordpress | No Comments »
March 31st, 2008 by Henrik Melin
I’ve just updated More Fields to version 0.6, compatible with WordPress 2.5.
New features:
- Compatible with the new admin introduced in WordPress 2.5
- Set default value in a select list.
- Enable right hand column boxes in WP 2.5.
- Option of removing the ‘Related’ links on the right hand side on the Write/Edit page.
- A new set of actions, enabling users to change the behavior of More Fields. The documentation has been updated to include an example on how to use these actions.
The plugin can be downloaded from wordpress.org.
Any feedback is always greatly appreciated.
Tags: more fields, wordpress
Posted in announcement, wordpress | No Comments »
March 22nd, 2008 by Henrik Melin
We’ve had a confusing way of specifying the medium (physical, or virtual) and format (i.e. length) of a record release at dagensskiva.com. We have now restructured how this is represented, into two main components:
Formats:
- album
- single
- ep
- song
- box
- playlist
Media:
- cd
- 7”
- 10”
- 12”
- mp3
- aac
- wma
- myspace
In addition to this, we specify how mauy of the specified media constitutes the release, so that an album can be specified as, e.g. album (2×cd), song (mp3), box (10×12″), etc…
Did we miss anything?
Tags: dagensskiva, format, media
Posted in dagensskiva | 3 Comments »
March 20th, 2008 by Henrik Melin
I hashed together a plugin that enables authors to specify a specific template file to be used for a post (this functionality is already built in for pages, but not for posts).
<?php
/*
Plugin Name: Template for posts
Plugin URI: http://labs.dagensskiva.com
Description: Set the template file for a post by setting the Custom Field 'dsc_template' to the filename of the template
Version: 0.1
Author: Henrik
*/
?>
function dsc_post_template() {
global $post, $wp_query;
if (count($wp_query->posts) == 1) {
$id = $wp_query->posts[0]->ID;
if ($temp = get_post_meta($id, 'dsc_template', true)) {
include( TEMPLATEPATH . '/' .$temp );
exit(0);
}
}
}
add_filter('template_redirect', 'dsc_post_template', 9);
Usage: a Custom Field called ‘dsc_template’ is set to equal the basename of the file, e.g. ‘interview.php’, placed inside your theme folder. Simple as that. It only applies the template file if $wp_query contains only one post, i.e. where the template file ’single.php’ would normally be applied.
Tags: plugin, template, wordpress
Posted in dagensskiva, wordpress | 2 Comments »
March 19th, 2008 by Kal Ström
Added functionality to post content to MySpace. Altered the function to allow for Javascript being turned off.
<a href="http://www.myspace.com/Modules/PostTo/Pages/?t=<?php the_title(); ?> | dagensskiva.com&u=<?php the_permalink(); ?>&c=dagensskiva.com&l=3" onclick="GetThis('<?php the_title(); ?< | dagensskiva.com', '<?php echo wptexturize(dsc_generate_excerpt(get_the_content(), 20, 20)); ?>', '<?php the_permalink(); ?>', 1); return false;" class="myspace">Myspace</a>

Tags: dagensskiva.com, myspace, share
Posted in dagensskiva | 1 Comment »
March 4th, 2008 by Henrik Melin
I’ve been working on exporting the content of the old dagensbok.com site, which runs ASP and MSSQL, into an installation of WordPress. Using the MSSQL functionality in PHP, the MSSQL server is accessed from within the WordPress installation I’m importing into. The PHP code that performs the import is contained in a plugin.
A few basic notes on MSSQL versus MySQL:
- The MySQL LIMIT 10 clause becomes ‘SELECT TOP 10‘
- ‘SHOW TABLES‘ becomes ‘“SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = ‘BASE TABLE’”;‘
- Selecting a random row in MSSQL can be done by ‘ORDER BY NEWID()‘
To do the import into WordPress I’m populating the $_POST variable, as if the post was created in the Admin:
<?
$_POST = array();
$_POST['post_title'] = $ret['header'];
$_POST['post_type'] = 'post';
$_POST['content'] = $ret['text'];
$id = wp_write_post();
add_post_meta($id, 'dbc_author', $ret['fname'] . ' ' . $ret['lname']);
...
?>
where $ret is the variable returned from mssql_fetch_assoc(). Similarly, the comments to a post are added using wp_insert_comment($commentdata); - populating the $commentdata array first.
Tags: dagensbok, export, import, mssql, mysql
Posted in dagensbok, wordpress | No Comments »
February 12th, 2008 by Henrik Melin
WordPress is an excellent platform and it provides us at dagensskiva.com with a lot of built-in functionality that is required to run the site. The functionality that WordPress does not supply internally, we can add using our own custom made plugins, and, of course, plugins that other developers wrote. However, as any piece of software, WordPress is not perfect, and there are php files that we have to hack manually to get the desired functionality, particularly in the admin. To help WordPress become a better platform, I submitted this change to WordPress trac - now proposed to be part of WordPress 2.6 2.5. The change is very small but solves a problem that have been vexing us for quite some time.
One hack down, a handfull to go!
UPDATE: It got bumped to 2.5!
Tags: patch, trac, wordpress
Posted in wordpress | 1 Comment »