Table of contents
WordPressモジュールのコメントをd3forumに統合 
まだ途中です。何とか動くようになりました。(2007-06-13)- WordPressモジュールはnobunobuさん版です。0.6.0で試してます。
- nobunobuさん版はXOOPSのコメントシステムにも対応しているので、カスタマイズができるかなと思って。でも、テンプレートがないのでファイルに直書きですね。
- ちなみに、このサイトの「ごくろぐ」で使っているWordPressモジュールはXPressです。なのでこの作業は別のサイトでためしてます。
作業の覚え書き 
xoops-comments-template.phpの修正 
- /modules/worpress/themes/themes_files/xoops-comments-template.phpに以下を記述。$forum_idはd3forumに作成したWordPressモジュール用のフォーラム番号にする。
<?php require_once(XOOPS_TRUST_PATH.'/modules/d3forum/include/comment_functions.php'); $dirname = "d3forum"; $forum_id = "2"; $post_title = get_the_title(); $params = array("dirname" => $dirname, "forum_id" => $forum_id, "itemname" => "p", "subject" => $post_title); ?> <div id="comments"> <?php d3forum_display_comment( $dirname , $forum_id , $params ) ; ?> </div>
template-functions-comment.phpの修正 
- 各記事ごとのコメント数表示がおかしいので、修正。(2007-06-09、2007-06-13再修正)
- /modules/wordpress/wp-includes/template-functions-comment.phpのfunction comments_numberを修正。
の後に、
$number = $commentHandler->getCount($criteria); }
を追記。require_once(XOOPS_TRUST_PATH.'/modules/d3forum/include/comment_functions_2.php'); $number = d3forum_display_comment_topicscount ( $GLOBALS['dirname'] , $GLOBALS['forum_id'] , $GLOBALS['params'] ) ;
- /modules/wordpress/wp-includes/template-functions-comment.phpのfunction comments_popup_linkを修正。
の直前に、
$comments_popup_link .= comments_number($zero, $one, $more, $number, false);
を追記。$dirname = "d3forum"; $forum_id = "2"; $params = array("dirname" => $dirname, "forum_id" => $forum_id, "link_id" => $wp_post_id);
- /modules/wordpress/wp-includes/template-functions-comment.phpのfunction comments_numberを修正。
index-template.phpの修正 
- /modules/worpress/themes/themes_files/index-template.phpを修正。
のすぐ前に、 を追記。
<?php comments_popup_link(_WP_TPL_COMMENT0, _WP_TPL_COMMENT1, _WP_TPL_COMMENTS); ?>
(2007-07-04追記)
- /modules/worpress/themes/themes_files/content_block-template.phpにも同じ修正を加えると幸せになれるかも。
comment_functions_2.phpの作成 
(2007-06-13追記)
- XOOPS_TRUST_PATH/modules/d3forum/includeに以下の内容のファイル(comment_functions_2.php)を作成。comment_functions.phpのfunction d3forum_display_comment_topicscountの最後のechoをreturnに変えただけです。
<?php function d3forum_display_comment_topicscount_2( $mydirname , $forum_id , $params , $mode = 'post' ) { global $xoopsUser , $xoopsConfig ; $mydirpath = XOOPS_ROOT_PATH.'/modules/'.$mydirname ; $mytrustdirpath = dirname( dirname( __FILE__ ) ) ; $db =& Database::getInstance() ; // external_link_id if( ! empty( $params['link_id'] ) ) { $external_link_id = $params['link_id'] ; } else if( ! empty( $params['itemname'] ) ) { $external_link_id = @$_GET[ $params['itemname'] ] ; } else { echo "set valid link_id or itemname in the template" ; return ; } if( empty( $external_link_id ) ) return ; // check the d3forum exists and is active $module_hanlder =& xoops_gethandler( 'module' ) ; $module =& $module_hanlder->getByDirname( $mydirname ) ; if( ! is_object( $module ) || ! $module->getVar('isactive') ) { return ; } // check permission of "module_read" $moduleperm_handler =& xoops_gethandler( 'groupperm' ) ; $groups = is_object( $xoopsUser ) ? $xoopsUser->getGroups() : array( XOOPS_GROUP_ANONYMOUS ) ; if( ! $moduleperm_handler->checkRight( 'module_read' , $module->getVar( 'mid' ) , $groups ) ) { return ; } $select = $mode == 'topic' ? 'COUNT(t.topic_id)' : 'SUM(t.topic_posts_count)' ; $sql = "SELECT $select FROM ".$db->prefix($mydirname."_topics")." t WHERE t.forum_id=$forum_id AND ! t.topic_invisible AND topic_external_link_id='".addslashes($external_link_id)."'" ; if( ! $trs = $db->query( $sql ) ) die( 'd3forum_comment_error in '.__LINE__ ) ; list( $count ) = $db->fetchRow( $trs ) ; // echo intval( $count ) ; return intval( $count ) ; } ?>
- XOOPS_TRUST_PATH/modules/d3forum/includeに以下の内容のファイル(comment_functions_2.php)を作成。comment_functions.phpのfunction d3forum_display_comment_topicscountの最後のechoをreturnに変えただけです。
以上で、何とか動いています。
Counter: 659,
today: 1,
yesterday: 0
Last-modified: 2008-05-11 (Sun) 03:45:37 (JST) (241d) by gokuraku
新しくコメントをつける
コメント一覧