I've been struggling with various posting methods with Drupal for a while - editing raw HTML, manually uploading images and cutting and pasting embed links for videos has been a real pain. I've tried the various wysiwyg editors, they all end up lacking in some way or another - buggy, poor image/media support, bad spell-check implementations, etc.

Windows Live Writer has been a popular choice for other platforms for a while. It is rock solid, offers an MS Word-like editing environment and supports images, video and tons of other content types through plugins. Unfortunately getting it to work with Drupal (without giving up features) is tricky.

Many of the solutions out there work partially (i.e. no image, no category download support, etc.). Really getting it to work requires a couple of minor modifications to the Drupal code and the addition of a simple module.

Here is how to get WLW fully functional with Drupal 6 (I'm on 6.3 currently):

Step 1: Patch Drupal's blogapi Module

There is a bug in Drupal's blogapi module that will prevent WLW from downloading your categories. To fix it, you can download and apply this patch or you can simply edit modules/blogapi/blogapi.module and add the following code to the top of the of the blogapi_metaweblog_get_category_list function.

  $user = blogapi_validate_user($username, $password);
  if (!$user->uid) {
    return blogapi_error($user);
  }

For more discussion of this issue, see: http://drupal.org/node/221677#comment-755721

Step 2: Setup a Sane Default Filter

Drupal's default behavior is to apply the system default filter to all new content that is added through the blogapi module. This is filtered HTML by default which won't allow images, video or other media unless you either change the filter or the default filter type (and thus allow everyone to post such content). To get around this problem, I use the simple Filter Default module which selects a default filter based on the role of the user.

Filter Default hasn't yet been officially updated for Drupal 6, but there is an unofficial version here that has. Download and install this version.

Now open modules/filter_default/filter_default.module and add the following function:

/**
 * Implements hook_nodeapi()
 */
function filter_default_nodeapi($node, $op) {
  if ($op == "blogapi new" || $op == "blogapi edit") {
    global $user;
    $roles = user_roles();
    for ($i = 1; $i < count($roles)+1; ++$i) {
      list($role, $format) = variable_get('filter_default_'. $i, array());
      if (array_key_exists($role, $user->roles)) {
        $node->format = $format;
        break;
      }
    }
  }
}

Now go to the Input Formats admin page and set up the desired default filters for each role. For the role that will be posting via WLW, you will likely want to enable Full HTML to be able to post images, etc.

Step 3: Install and Configure Windows Live Writer

After installing WLW, launch it and the Add Account wizard should appear. If not, or if you already had it installed, select Weblog | Add Weblog Account... from the menu.

  1. Choose "Another weblog service"
  2. In the "Weblog Homepage URL" field, enter your blog's URL followed by "/node/add/blog". Example: "http://mysite/node/add/blog". Replace "blog" with "story", "page" or whatever content type you will be posting from WLW.
  3. Enter your credentials in the username/password fields
  4. In the "Type of weblog that you are using" dropdown, select "Movable Type API"
  5. In the "Remote posting URL" field, enter your website's URL followed by "/xmlrpc.php". Example: "http://mysite/xmlrpc.php"
  6. Now select the same content type you chose above in step 2 (e.g. blog, story, page) from the list
  7. WLW will detect some settings and download some content from your site
  8. You might want to change the name in the "Weblog Name" field - this is just the name that will be listed in WLW
  9. Click Finish

Credit where credit is due: These instructions are based on this how-to guide with some suggested updates from forum posts here on drupal.org.

Enjoy!

That's it. It sounds harder than it is :). Once you're finished, you'll have a deluxe wysiwyg editor, automatic image upload capability, video embedding and more. You'll never want to go back. Trust me.

A couple of notes:

WLW's notion of Tags is different than Drupal's taxonomy. The WLW "Insert Tags" function will insert links to an external tag provider like Technorati. For setting Drupal taxonomy, use the "Categories" dropdown at the bottom of the window and check the categories you want.

There are many WLW plugins. Check them out at http://gallery.live.com/results.aspx?c=0&bt=9&pl=8&st=5.

Comments

shushu’s picture

While following those steps made it possible to publish blog posts, I wasn't able to make it publish other content types, such as pages.

I don't have Clean URLs working, which requires me to change the "Weblog Homepage URL". Do you think this makes the problem ?

I would appreciate your help.

Regards,
Shushu

keathmilligan’s picture

It's not your clean URLs setting.

It looks like WLW doesn't understand the notion of different content types, so in order to support using WLW to publish different types of nodes, I have to set up additional blogs in WLW - one for each content type I want to publish.

Also, since I wrote this, I've run into a bug in Drupal's blogapi that some of you might get hit by as well: Under some circumstances, blogapi will not allow you publish images returning an exceeded max allowed size error. To work around this until it is fixed, you can set up WLW to use FTP to publish images.

Navinjohnson’s picture

Thanks keathmilligan. Great post.

I got this to work great.

Two updates.

*The filter default module has been ported to 6 so that dev module worked for me without adding your patch.

*I ran into the publish image error you encountered so I had to check the 'administer content with blog api' permission tab for authenticated user and it now it works.

rmaclean’s picture

The max size error is correct, check your PHP settings and your file upload settings. Default is 1Mb

rmaclean’s picture

Hi,

I am using the latest beta of WLW (Build 14.0.3913.522) and there is no need for step 3. It detects Drupal fine (even calls it Drupal!). Step 1 and 2 are still required though!

Update: I take it back, keep doing step 3. The Drupal support doesn't handle tags or themes at this point. Good sign it is there though.

reb00tz’s picture

Thanks for the heads-up. This is the patch that I created for the latest (as of 16th September 2008) Filter Default module for Drupal 5.x...

--- filter_default.module.old	2008-08-27 20:26:20.000000000 -0500
+++ filter_default.module	2008-09-16 02:45:11.000000000 -0500
@@ -165,7 +165,7 @@
 * Set the default filter on new blog posts coming in through blogapi module.
 */
 function filter_default_nodeapi(&$node, $op) {
-  if ($op == "blogapi new") {
+  if ($op == "blogapi new" || $op == "blogapi edit") {
     global $user;
     $roles = user_roles();
     for ($i = 1; $i < count($roles)+1; ++$i) {
rmaclean’s picture

Checking the code for 6.5 and it appears the code for step 1 is already included. After upgrading I ran a quick test and it seems fine.

jdleonard’s picture