minidiaryモジュールで、d3コメント統合
手順と方法
テンプレートだけでなく、ソースの変更も必要ですので、細かく記しておきます。
なお、個別のアップロードも編集も面倒、という人のために、minidiary-0.14aとしてminidiary-0.14との差分ファイルと、d3commentのAPI、xugj_blockも同梱して固めたファイルを、ここに置いておきます。 解凍後、夫々のフォルダにアップロードして使えます。
xugj_blockの準備
xugj_blockを使います。 入手はこちら(PEEK XOOPS)、 → 「xoops_root_path/class/smarty/plugins/」内にファイル名「function.xugj_block.php」で保存します。
解説はこちら(XFIELD TWCHNOTE)を参照いただければわかります。
D3commentクラス
D3commentクラスは、下記ファイルをダウンロード後、「minidiary/class」内にアップロードして使用します。
当然ながら、d3forumの方にコメント統合用に掲示板を追加し、(必要があれば)過去のxoopsコメントをインポート後、「コメント統合時の参照方法」に
minidiary::minidiaryD3commentContent::
と記載します。
なお、d3forumは0.83a以降のバージョンが必須で、D3commentの最新のAPIクラス群を忘れずにアップして下さい。
minidiaryソースの変更
4つのソースファイルに手を入れます。 こんな方法で良いのか自信はありませんが、間違いではないと思うのでご勘弁。
xoops_version.php
「xoops_version.php」を編集し、管理画面にmodule_config項目を追加します。
下記の103~119行目を追記します。
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
| $modversion['config'][] = array(
'name' => 'xsns_dirname' ,
'title' => '_MI_XSNS_DIRNAME' ,
'description' => '_MI_XSNS_DIRNAMEDESC' ,
'formtype' => 'textbox',
'valuetype' => 'text',
'default' => ''
);
$modversion['config'][] = array(
'name' => 'com_agent' ,
'title' => '_MI_COM_AGENT' ,
'description' => '_MI_COM_AGENTDSC' ,
'formtype' => 'textbox',
'valuetype' => 'text',
'default' => ''
);
$modversion['config'][]= array(
'name' => 'com_agent_forumid',
'title' => '_MI_COM_AGENTID',
'description' => '_MI_COM_AGENTIDDSC',
'formtype' => 'textbox',
'valuetype' => 'int',
'default' => '0'
);
$modversion['config'][] = array(
'name' => 'use_simplecomment' ,
|
languages/japanese/modinfo.php
「modinfo.php」を編集し、上の作業で追加した管理画面の項目に日本語テキストを追加します。
以下の49~53行目を追記します。
46
47
48
49
50
51
52
53
54
55
| define("_MI_XSNS_DIRNAME","xsnsのディレクトリ名");
define("_MI_XSNS_DIRNAMEDESC","xsnsのディレクトリ名を変更している場合は、その名称を入力してください。<br/>空白にした場合はデフォルトのディレクトリ名になります。");
define("_MI_COM_AGENT","コメントシステムの設定");
define("_MI_COM_AGENTDSC","d3forumのコメント統合機能を使用する場合は<br/>フォーラムのhtml側ディレクトリ名を指定します。<br/>xoopsコメントを使用する場合やコメント機能を無効にする場合は空欄です。");
define("_MI_COM_AGENTID","コメントのforum_id");
define("_MI_COM_AGENTIDDSC","コメント統合を選択した場合、forum_idを必ず指定してください。");
define("_MI_USE_SIMPLECOMMENT","コメントの表示モード");
|
header.php
「header.php」に、下記のように6~15行目を追記します。
module_config設定項目を、smarty変数でテンプレートに渡すために必要です。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| <?php
// 定義ファイルのインクルード
include '../../mainfile.php';
include XOOPS_ROOT_PATH.'/modules/minidiary/functions.php';
// モジュールID // added by naao
$module_handler =& xoops_gethandler('module');
$this_module =& $module_handler->getByDirname('minidiary');
$mid = $this_module->getVar('mid');
// モジュールconfig // added by naao
$config_handler =& xoops_gethandler("config");
$yd_config = $config_handler->getConfigsByCat(0, $mid);
$xoopsTpl->assign("yd_moduleConfig", $yd_config);
?>
|
blocks/b_diarylist.php
「b_diarylist.php」に、下記のように171~174行目を追記します。
ブロック表示のd3コメント統合のために必要です。
166
167
168
169
170
171
172
173
174
175
176
177
178
179
| $block[$j]['other']=1;
$j++;
$i++;
}
// モジュールconfig // added by naao
$config_handler =& xoops_gethandler("config");
$yd_config = $config_handler->getConfigsByCat(0, $mid);
$block[0]['yd_moduleConfig']=$yd_config;
return $block;
}
?>
|
テンプレートの編集
続いて、テンプレートを5つ、Altsysなどで編集します。
b_diarylist.html
「b_diarylist.html」の、30~49行目 を編集します。
29
30
31
32
33
34
35
36
37
38
39
40
|
| <tr><td colspan=2><{$block[num2].diary}>
<{if $block[num2].com_num > 0}>
<br />
<a href="<{$xoops_url}>/modules/minidiary/detail.php?bid=<{$block[num2].bid}>#viewcomment">
<img src="<{$xoops_url}>/modules/minidiary/images/comments.png" border=0 style="vertical-align:middle;" title="コメントあり" alt="コメントあり" /> <{$block[num2].com_num}></a>
<{if $block[num2].newcom > 0}>
<img src="<{$xoops_url}>/modules/minidiary/images/new.gif" border=0 style="vertical-align:middle;" title="new" alt="new" />
[<{$block[num2].newcom_y}>年<{$block[num2].newcom_m}>月<{$block[num2].newcom_d}>日 <{$block[num2].newcom_h}>:<{$block[num2].newcom_i}>]
<{/if}>
<{/if}>
</td></tr>
|
↓ 以下のように変更。
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
| <tr><td colspan=2><{$block[num2].diary}>
<{if $block.0.yd_moduleConfig.com_agent}>
<br />
<{d3comment mode="count" var="comcount" mydirname='minidiary' id=$block[num2].bid class="minidiaryD3commentContent"}>
<{if $comcount}>
<a href="<{$xoops_url}>/modules/minidiary/detail.php?bid=<{$block[num2].bid}>#comment" title="コメントあり">
<img src="<{$xoops_url}>/modules/minidiary/images/comments.png" border=0 style="vertical-align:middle;" title="コメントあり" alt="コメントあり" /> (<{$comcount}>)</a>
<{/if}>
<{else}>
<{if $block[num2].com_num > 0}>
<br />
<a href="<{$xoops_url}>/modules/minidiary/detail.php?bid=<{$block[num2].bid}>#viewcomment">
<img src="<{$xoops_url}>/modules/minidiary/images/comments.png" border=0 style="vertical-align:middle;" title="コメントあり" alt="コメントあり" /> <{$block[num2].com_num}></a>
<{if $block[num2].newcom > 0}>
<img src="<{$xoops_url}>/modules/minidiary/images/new.gif" border=0 style="vertical-align:middle;" title="new" alt="new" />
[<{$block[num2].newcom_y}>年<{$block[num2].newcom_m}>月<{$block[num2].newcom_d}>日 <{$block[num2].newcom_h}>:<{$block[num2].newcom_i}>]
<{/if}>
<{/if}>
<{/if}>
</td></tr>
|
yd_detail.html
「yd_detail.html」の、82~124行目 を編集します。
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
| <{if $yd_use_simplecomment == 0}>
<{$commentsnav}>
<center><{$lang_notice}></center>
<{if $comment_mode == "flat"}>
<{include file="db:system_comments_flat.html"}>
<{elseif $comment_mode == "thread"}>
<{include file="db:system_comments_thread.html"}>
<{elseif $comment_mode == "nest"}>
<{include file="db:system_comments_nest.html"}>
<{/if}>
<{else}>
<{if $comments.0.id >0}>
<a name="viewcomment"></a>
<table class="outer"><tr><th>
コメント
</th></tr><tr><td>
<div style="margin: 1px; padding: 1px;">
<{include file="db:system_comments_flat.html"}>
</div>
</td></tr></table>
<br />
<{/if}>
<table class="outer"><tr><th>
コメントを書く
</th></tr><tr><td>
<{if $xoops_isuser==1}>
<{$yr_comment_form}>
<{else}>
コメントを書くには<a href="<{$xoops_url}>/user.php">ログイン</a>が必要です。<br />
<{/if}>
</td></tr></table>
<{/if}>
|
↓ 以下のように変更。(08/08/28 84行目の未修正箇所を修正。)
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
|
<a name="viewcomment"></a>
<{if $yd_moduleConfig.com_agent}>
<{d3comment mydirname='minidiary' id=$yd_data.bid subject=$yd_data.title class="minidiaryD3commentContent}>
<{else}>
<{if $yd_use_simplecomment == 0}>
<{$commentsnav}>
<center><{$lang_notice}></center>
<{if $comment_mode == "flat"}>
<{include file="db:system_comments_flat.html"}>
<{elseif $comment_mode == "thread"}>
<{include file="db:system_comments_thread.html"}>
<{elseif $comment_mode == "nest"}>
<{include file="db:system_comments_nest.html"}>
<{/if}>
<{else}>
<{if $comments.0.id >0}>
<table class="outer"><tr><th>
コメント
</th></tr><tr><td>
<div style="margin: 1px; padding: 1px;">
<!-- start comments loop -->
<{include file="db:system_comments_flat.html"}>
<!-- end comments loop -->
</div>
</td></tr></table>
<br />
<{/if}>
<!-- start comment form -->
<table class="outer"><tr><th>
コメントを書く
</th></tr><tr><td>
<{if $xoops_isuser==1}>
<{$yr_comment_form}>
<{else}>
コメントを書くには<a href="<{$xoops_url}>/user.php">ログイン</a>が必要です。<br />
<{/if}>
</td></tr></table>
<!-- end comment form -->
<!-- end comment area -->
<{/if}>
|
yd_diarylist.html
「yd_diarylist.html」の、56~66行目 を編集します。
55
56
57
58
59
60
61
62
63
64
65
66
|
| <tr><td colspan=2><{$yd_data[num2].diary}>
<{if $yd_data[num2].com_num > 0}>
<br />
<a href="<{$xoops_url}>/modules/minidiary/detail.php?bid=<{$yd_data[num2].bid}>#viewcomment">
<img src="images/comments.png" border=0 style="vertical-align:middle;" title="コメントあり" alt="コメントあり" /> <{$yd_data[num2].com_num}></a>
<{if $yd_data[num2].newcom > 0}>
<img src="images/new.gif" border=0 style="vertical-align:middle;" title="new" alt="new" />
[<{$yd_data[num2].newcom_y}>年<{$yd_data[num2].newcom_m}>月<{$yd_data[num2].newcom_d}>日 <{$yd_data[num2].newcom_h}>:<{$yd_data[num2].newcom_i}>]
<{/if}>
<{/if}>
</td></tr>
|
↓ 以下のように変更。
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
| <tr><td colspan=2><{$yd_data[num2].diary}>
<{if $yd_moduleConfig.com_agent}>
<{d3comment mode="count" var="comcount" mydirname='minidiary' id=$yd_data[num2].bid class="minidiaryD3commentContent"}>
<{if $comcount}>
<a href="<{$xoops_url}>/modules/minidiary/detail.php?bid=<{$yd_data[num2].bid}>#comment" title="コメントあり">
<img src="images/comments.png" border=0 style="vertical-align:middle;" title="コメントあり" alt="コメントあり" /> (<{$comcount}>)</a>
<{/if}>
<{else}>
<{if $yd_data[num2].com_num > 0}>
<br />
<a href="<{$xoops_url}>/modules/minidiary/detail.php?bid=<{$yd_data[num2].bid}>#viewcomment">
<img src="images/comments.png" border=0 style="vertical-align:middle;" title="コメントあり" alt="コメントあり" /> <{$yd_data[num2].com_num}></a>
<{if $yd_data[num2].newcom > 0}>
<img src="images/new.gif" border=0 style="vertical-align:middle;" title="new" alt="new" />
[<{$yd_data[num2].newcom_y}>年<{$yd_data[num2].newcom_m}>月<{$yd_data[num2].newcom_d}>日 <{$yd_data[num2].newcom_h}>:<{$yd_data[num2].newcom_i}>]
<{/if}>
<{/if}>
<{/if}>
</td></tr>
|
yd_index.html
「yd_index.html」の、60~64行目 を編集します。
59
60
61
62
63
64
65
|
| <td style="border:1px gray solid;border-bottom:2px gray solid;text-align:right;">
<a href="<{$xoops_url}>/modules/minidiary/detail.php?bid=<{$yd_data[num].bid}>#viewcomment">
コメント(<{$yd_data[num].comment_num}>)
</a> |
<a href="<{$xoops_url}>/modules/minidiary/detail.php?bid=<{$yd_data[num].bid}>">
続きを読む</a>
<{if $yd_editperm==1}>
|
↓ 以下のように変更。
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
| <td style="border:1px gray solid;border-bottom:2px gray solid;text-align:right;">
<{if $yd_moduleConfig.com_agent}>
<{d3comment mode="count" var="comcount" mydirname='minidiary' id=$yd_data[num].bid class="minidiaryD3commentContent"}>
<{if $comcount}>
<a href="<{$xoops_url}>/modules/minidiary/detail.php?bid=<{$yd_data[num].bid}>#comment" title="コメント">コメント (<{$comcount}>)</a>
<{else}>コメント (0)
<{/if}>
<{else}>
<a href="<{$xoops_url}>/modules/minidiary/detail.php?bid=<{$yd_data[num].bid}>#viewcomment">
コメント <{$yd_data[num].comment_num}>
</a>
<{/if}>
|
<a href="<{$xoops_url}>/modules/minidiary/detail.php?bid=<{$yd_data[num].bid}>">
続きを読む</a>
<{if $yd_editperm==1}>
|
yd_rightarea.html
「yd_rightarea.html」の、50~57行目 を編集します。
49
50
51
52
53
54
55
56
57
58
59
|
| <th>最近のコメント</th></tr>
<{section name=num loop=$yd_comment max=3}>
<tr>
<td><img src="<{$xoops_url}>/modules/minidiary/images/enum1.png" border=0 /><a href="<{$xoops_url}>/modules/minidiary/detail.php?bid=<{$yd_comment[num].bid}>#viewcomment"><{$yd_comment[num].title}></a> <{$yd_comment[num].uname}>[<{$yd_comment[num].month}>/<{$yd_comment[num].day}> <{$yd_comment[num].time}>]</td>
</tr>
<{/section}>
<tr>
<td style="border-top:1px gray solid;text-align:right;">
<img src="<{$xoops_url}>/modules/minidiary/images/arrow1.png" border=0 style="vertical-align:middle;" /> <a href="<{$xoops_url}>/modules/minidiary/viewcomment.php?req_uid=<{$yd_uid}>">コメント一覧へ</a></td>
</tr>
</table>
|
↓ 以下のように変更。 (08/08.30 XUGJ_blockの指定が変数になっていない分を修正)
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
| <th>最近のコメント</th></tr>
<tr><td>
<{if $yd_moduleConfig.com_agent}>
<{xugj_block file=modules/`$yd_moduleConfig.com_agent`/blocks/blocks.php func="b_d3forum_list_posts_show" opt="`$yd_moduleConfig.com_agent`,10,time,,,`$yd_moduleConfig.com_agent_forumid`" item="block"}>
<{section name=num max=3}>
<ol style="padding:3px;margin:0;">
<{foreach item=post from=$block.posts}>
<li style="margin:1px;"><a href="<{$block.mod_url}>/index.php?post_id=<{$post.id}>"><{$post.subject}></a> <{$post.uname}> <{$post.post_time_formatted}></li>
<{/foreach}>
</ol>
<{/section}>
<img src="<{$xoops_url}>/modules/minidiary/images/arrow1.png" border=0 style="vertical-align:middle;" /> <a href="<{$block.mod_url}>/index.php?forum_id=17">コメント一覧へ</a></td>
<{else}>
<{section name=num loop=$yd_comment max=3}>
<tr>
<td><img src="<{$xoops_url}>/modules/minidiary/images/enum1.png" border=0 /><a href="<{$xoops_url}>/modules/minidiary/detail.php?bid=<{$yd_comment[num].bid}>#comment"><{$yd_comment[num].title}></a> <{$yd_comment[num].uname}>[<{$yd_comment[num].month}>/<{$yd_comment[num].day}> <{$yd_comment[num].time}>]</td>
</tr>
<{/section}>
<tr>
<td style="border-top:1px gray solid;text-align:right;">
<img src="<{$xoops_url}>/modules/minidiary/images/arrow1.png" border=0 style="vertical-align:middle;" /> <a href="<{$xoops_url}>/modules/minidiary/viewcomment.php?req_uid=<{$yd_uid}>">コメント一覧へ</a></td>
<{/if}>
</tr>
</table>
|
モバイル用テンプレート
モバイルテンプハウスで、作成・公開済。
インストールと設定
xoops管理画面の「モジュールの管理」で、「minidiary」をモジュールアップデートします。 これで、「minidiary」の管理画面に、2つの項目が追加されます。
ここで、
- コメントシステムの設定 : d3forumのコメント統合機能を使用する場合はd3forumのhtml側ディレクトリ名を指定します。xoopsコメントを使用する場合やコメント機能を無効にする場合は空欄です。
- コメントのforum_id : コメント統合を選択した場合、統合先のforum_id値を必ず指定してください。
これらを設定すれば完了です。(この編集を行うまでは、xoopsコメントシステムが有効です。)
その他
関連情報