Jump to Navigation

写了一个分类的显示区块

Drupal升级到4.6之后,不知道什么缘故,原来的分类区块被省略掉了,没有了这个区块,多少会让人觉得不方便,所以自己写了一个分类区块,如下:

if (user_access('access content')) {
$result = db_query("SELECT d.tid, d.name, MAX(n.created) AS updated, COUNT(*) AS count FROM {term_data} d INNER JOIN {term_node} USING (tid) INNER JOIN {node} n USING (nid) WHERE n.status = 1 GROUP BY d.tid, d.name ORDER BY updated DESC, d.name");
//读取分类关键词,最新文章创建的时间,降序排列
$items = array();
while ($category = db_fetch_object($result)) {
$items[] = l($category->name .' ('. $category->count .')', 'taxonomy/term/'. $category->tid) .'
'. t('%time ago', array('%time' => format_interval(time() - $category->updated)));
}
//按照以前的格式显示分类区块,包括最后一片帖子的发布时间。
return theme('item_list', $items);
}
?>
我的blog的左侧有一个例子,如果你不需要显示“最近更新时间”,代码可以简化许多,hoho,其实没必要用PHP了,用HTML做个静态链接就行了:)

Trackback URL for this post:

http://www.kzeng.info/trackback/761

guenstig uebernachten in gelsenkirchen

[...] Janet Cohen, a director of Charterhouse Bank, The Yorkshire Building Society, and BPP Holdings, at JOHN WADDINGTON. On,significant He said the leadership must fight "shortcomings, bureaucracy, inertia and conservatism" and cooperate more closely ...

Comments

very good.!

very good.!

很好

我现在在使用你的代码,真的很好用,谢谢!

Post new comment

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.