石锅拌饭

Tag: keyword

How to make ecto work with Ultimate Tag Warrior – Part II

by on Mar.19, 2006, under Uncategorized

[update: I have updated downloadable xmlrpc.php example for wordpress 2.1. It also fixes the wordpress 2.1 bug when getting category via xmlrpc. Check the end of the post. 2007-02-20]

I once wrote about “How to make ecto work with Ultimate Tag Warrior”. In that article, I discussed how to make the wordpress with UTW plugin recognize tag information sent by ecto. It works well except that some friends reported after the post is published, the tag information can not be stored in ecto. It means you lose track of all the tag information in ecto. When you edit a post, you have to set the tags again, which is very inconvenient.

From a post in the ecto forum, I knew that ecto recognizes mt_keywords. After some more hacking of xmlrpc.php, I fixed the problem. Now, you can not only use ecto to publish your post with tag information but also get tag information from your post. Here’s how (UPDATE: be sure to follow the steps in Part I before applying following steps. Thank Bruce for your reminding and all the helps):

First, you need to add one function in xmlrpc.php before the class wp_xmlrpc_server is defined:

/* ROBIN LU HACK get keywords */
function ecto_get_keywords($postid) {
$utw = new UltimateTagWarriorCore();
$tags = $utw->GetTagsForPost($postid);
$postkeywords = '';
if (is_array($tags)) {
foreach($tags as $data) {
if(!empty($data) &&
!empty($postkeywords))
$postkeywords .= ", ";
$postkeywords .= $data->tag;
}
}
return ($postkeywords);
}

Then, add this line

'mt_keywords' => ecto_get_keywords($postdata['ID']),

in function mw_getPost at where $resp is set:

$resp = array(
'dateCreated' => new IXR_Date($post_date),
'userid' => $postdata['post_author'],
'postid' => $postdata['ID'],
'description' => $post['main'],
'title' => $postdata['post_title'],
'link' => $link,
'permaLink' => $link,
// commented out because no other tool seems to use this
//	      'content' => $entry['post_content'],
'categories' => $categories,
'mt_excerpt' => $postdata['post_excerpt'],
'mt_text_more' => $post['extended'],
'mt_allow_comments' => $allow_comments,
//ROBIN LU HACK
'mt_keywords' => ecto_get_keywords($postdata['ID']),
'mt_allow_pings' => $allow_pings
);

Then add this line:

'mt_keywords' => ecto_get_keywords($entry['ID']),

in function mw_getRecentPosts() at where $struct[] is assigned like this:

$struct[] = array(
'dateCreated' => new IXR_Date($post_date),
'userid' => $entry['post_author'],
'postid' => $entry['ID'],
'description' => $post['main'],
'title' => $entry['post_title'],
'link' => $link,
'permaLink' => $link,
// commented out because no other tool seems to use this
//	      'content' => $entry['post_content'],
'categories' => $categories,
'mt_excerpt' => $entry['post_excerpt'],
'mt_text_more' => $post['extended'],
'mt_allow_comments' => $allow_comments,
//ROBIN LU HACK
'mt_keywords' => ecto_get_keywords($entry['ID']),
'mt_allow_pings' => $allow_pings
);

Save your xmlrpc.php and refresh in ecto. You will get all the tag information back to you.
There are xmlrpc.php files for different wordpress version:

53 Comments :, , , , , , more...

How to make ecto work with Ultimate Tag Warrior

by on Dec.29, 2005, under Uncategorized

I once wrote about “How to make ecto work with Jerome’s Keywords“. Unfortunately, Jerome’s Keywords does not work well with WordPress 2.0. With suggestion from Meng Yan, I switched to Ultimate Tag Warrior. Again, I met the problem of how to make ecto work with it. Here’s the solution.

  1. make sure Ecto is using Movable Type API to contact with your wordpress. You can check it out in the Account settings.
  2. set up the template of tags in Ecto. Set the “Tag separator” as “,” which is the default setting and “Put tags in” as “keywords” which is NOT the default setting.
  3. update the xmlrpc.php in the directory of your blog system. add the following line into the function mw_newPost and mw_editPost after where $content_struct is initialized:

$_POST[‘tagset’] = $content_struct[‘mt_keywords’];

Here’s the sample code to show where to make the modification (below the comments “ROBINLU HACK”):

/* metaweblog.newPost creates a post */
function mw_newPost($args) {
global $wpdb, $post_default_category;
... ...
$post_excerpt = $content_struct['mt_excerpt'];
$post_more = $content_struct['mt_text_more'];
// ROBIN LU HACK
$_POST['tagset'] = $content_struct['mt_keywords'];
$comment_status = (empty($content_struct['mt_allow_comments'])) ?
... ...
}
... ...
/* metaweblog.editPost ...edits a post */
function mw_editPost($args) {
global $wpdb, $post_default_category;
$this->escape($args);
$post_ID     = $args[0];
... ...
$post_title = $content_struct['title'];
$post_content = apply_filters( 'content_save_pre', $content_struct['description'] );
$catnames = $content_struct['categories'];
// ROBINLU HACK
$_POST['tagset'] = $content_struct['mt_keywords'];
$post_category = array();
... ...
}

Update: See Part II to get ecto fully functional with UTW.

42 Comments :, , , , , , more...

讨厌的caps lock键

by on Nov.29, 2005, under Uncategorized

键盘上最没用的恐怕就是大小写锁定键(caps lock)了。没用就罢了,还占了个好位置。早年SUN工作站的键盘把这个位置让给了ctrl,绝对正确的选择,这两年却莫名其妙地改了。
年初去日本,很看中这种Happy Hacking键盘:

主要原因就是Control键放对了位置。只可惜价格太贵。
把caps lock从键盘上干掉并不难。如果使用Linux,比较新版本的GNOME在系统配制里就有选项选择,可以把caps lock变成你想要的键。Mac OS X 10.4的系统预置里也有这样的选项。如果是Mac OS X 10.3,可以用uControl,虽然有些小bug,但不碍事。如果使用的是Windows 2000以上的版本,下载导入这个注册表文件,可以直接把caps lock变成ctrl。

1 Comment :, , more...

How to make ecto work with Jerome’s Keywords

by on Sep.15, 2005, under Uncategorized

The support for tags in WordPress 1.5.2 still depends on plugins. I use Jerome’s Keywords for this purpose. However, it does not work well with Ecto. I digged into the source code of the plugin and wordpress implementation of xml-rpc a bit. Although I am not familiar with php, I managed to make Ecto work with Jerome’s Keywords plugin. Here’s how to do it:

  1. make sure Ecto is using Movable Type API to contact with your wordpress. You can check it out in the Account settings.
  2. set up the template of tags in Ecto. Set the “Tag separator” as “,” which is the default setting and “Put tags in” as “keywords” which is NOT the default setting.
  3. update the xmlrpc.php in the directory of your blog system. add the following line into the function mw_newPost and mw_editPost after where $content_struct is initialized:

$_REQUEST[‘keywords_list’] = $content_struct[‘mt_keywords’];

Have a try with your Ecto. Set tags when you are composing blogs. After publishing, you can find the tags you set in ecto work just fine with Jerome’s Keywords Plugin.

If you have no interesting in how it works, you can stop here. Now I’d like to explain how I made it.

First, Ecto supports submit tag information as keyword with Movable Type API as mt_keywords. What you have to do is just to enable it in Templates settings. Meanwhile, Jerome’s Keywords hooks the action “publish_post” and “edit_post” to add keywords into post meta table. It extracts the keyword from the HTML REQUEST. So, my hack is to fake the request parameter “keywords_list” with the information in mt_keywords. They happend to use the same structure to present the tags so all I have to do is to add a single line in each post related method in xmlrpc.php

2 Comments :, , , , more...

Search

Archives

Browse by tags

agile apple blog book design ecto extension firefox git google hack ichm iphone keyword life mac madfox movie nonsense opensource plugin pm ruby rubyonrails sns software startup wordpress work 财帮子