d3forumの他のforumとの集約表示
★ d3diary側のブロックに標準でこの機能を取り込み済みのため、このテクは不要になりました。 ただ、他の応用としては一つの方法論として有効かと思い、残しておきます。 :hammer:
背景
d3diaryで実装した、d3forum統合コメントの元記事閲覧権限連動ブロック。
このブロックを単独表示している分には、d3diaryの閲覧権限に連動してくれるので安心なんですが、 他のモジュールのコメントや、他の掲示板のトピックと同一ブロック内に表示することができません。
そこで、それを可能にする方法を1つ、紹介しておきます。 この方法なら、閲覧権限を気にせず従来のようにd3forumトピックブロックをまとめて表示できます。
多少、重くなりぎみですが、実用上は問題にならないかもしれないレベルです。 お試しください。
方法
XUGJ_BLOCKの準備
「XUGJ_BLOCK」smartyプラグインを使用します。 ここでは詳細を省略しますが、入手方法などはあちこちに情報がありますので、各人で準備してください。 
カスタムテンプレート作成
カスタムテンプレート、「_custom_d3diary_d3com_topics.html」 を以下のような内容で作成します。
ただし、内容を編集する必要がありますので、後述します。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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
74
75
76
77
78
79
80
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
| <{xugj_block file="modules/d3forum/blocks/blocks.php" func="b_d3forum_list_topics_show" options="d3forum|10|false|time|false|||2,3,4,2,24,29,30|" item="block2"}> <{php}> $topics = array(); $reg_time = array(); $block = $this->get_template_vars('block'); //d3diaryのブロックからアサインされた foreach ($block['topics'] as $topic) { $topics[] = $topic; $reg_time[] = $topic['last_post_time']; } $block2 = $this->get_template_vars('block2'); //xugj_blockのd3forumブロックからアサインされた foreach ($block2['topics'] as $topic) { $topics[] = $topic; $reg_time[] = $topic['last_post_time']; } array_multisort($reg_time,SORT_DESC,$topics); $block['topics']=$topics; $this->assign('block',$block); <{/php}> <{if $block.full_view == true}> //以下d3forumの「d3forum_block_list_topics.html」より転記 <table class="outer" cellspacing="1"> <thead> <tr> <th><{$block.lang_forum}></th> <th><{$block.lang_topic}></th> <th align="center"><{$block.lang_replies}></th> <th align="center"><{$block.lang_views}></th> <th align="center" colspan="2"><{$block.lang_lastpost}></th> </tr> </thead> <{foreach item=topic from=$block.topics}> <{strip}> <tr class="<{cycle values="even,odd"}>"> <td><a href="<{$block.mod_url}>/index.php?forum_id=<{$topic.forum_id}>"><{$topic.forum_title}></a></td> <td> <a href="<{$block.mod_url}>/index.php?topic_id=<{$topic.id}>#post_id<{$topic.last_post_id}>"> <{if $topic.u2t_marked}><img src="<{$block.mod_imageurl}>/block_marked.gif" alt="<{$block.lang_alt_marked}>" /><{/if}> <{* displays the last post's subject or topic title *}> <{if $block.disp_last_subject }> <{$topic.last_subject}> <{else}> <{$topic.title}> <{/if}></a> <{if ! $topic.solved}><img src="<{$block.mod_imageurl}>/block_unsolved.gif" alt="<{$block.lang_alt_unsolved}>" /><{/if}></td> <td align="center"><{$topic.replies}></td> <td align="center"><{$topic.views}></td> <td align="center" nowrap="nowrap"><{$topic.last_uname}></td> <td align="right" nowrap="nowrap"><{$topic.last_post_time_formatted}></td> </tr> <{/strip}> <{/foreach}> </table> <div style="text-align:right; padding: 5px;"> <a href="<{$block.mod_url}>/index.php?page=search"><{$block.lang_linktosearch}></a> <{if is_numeric( $block.forums ) }> <a href="<{$block.mod_url}>/index.php?forum_id=<{$block.forums}>"><{$block.lang_linktolisttopics}></a> <{else}> <a href="<{$block.mod_url}>/index.php?cat_ids=<{$block.categories}>"><{$block.lang_linktolisttopics}></a> <{/if}> <{if is_numeric( $block.categories ) }> <a href="<{$block.mod_url}>/index.php?cat_id=<{$block.categories}>"><{$block.lang_linktolistforums}></a> <{/if}> <a href="<{$block.mod_url}>/index.php"><{$block.lang_linktolistcategories}></a> </div> <{else}> <ol style="padding:3px;margin:0;"> <{foreach item=topic from=$block.topics}> <li> <a href="<{$block.mod_url}>/index.php?topic_id=<{$topic.id}>#post_id<{$topic.last_post_id}>"> <{$topic.title}></a>(<{$topic.replies}>) <{$topic.last_uname}> <{$topic.last_post_time_formatted}></li> <{/foreach}> </ol> <{/if}>
|
カスタムテンプレート編集
xugj_blockを使って、集約表示する他の掲示板群データを取得します。
- file="modules/d3forum/blocks/blocks.php"
ここの「d3forum」は、集約表示する対象のd3forum掲示板群の、d3forumのhtml側ディレクトリ名に変更します。
- options="d3forum|10|false|time|false|||2,3,4,2,24,29,30|"
ブロック関数に渡される各パラメータが、| | で区切られています。
- 第1引数 「d3forum」は、集約表示する対象のd3forum掲示板群の、d3forumのhtml側ディレクトリ名に変更します。
- 第3引数 「false」は、ここでは意味はありません。
- 第4引数 「time」で、最新の記事から取得します。
- 第5引数 「false」は、チェックしたトピックの優先表示を行う場合にtrueとします。
- 第6引数 「」には、取得対象のd3forumのカテゴリ番号を記載します。但し、第8引数とのOR条件にはなりませんので要注意。
- 第8引数 「2,3,4,2,24,29,30」には、取得対象のd3forumのforum_id番号を「,」(カンマ)区切りで記載します。 ここでは、別ブロックから取得される日記コメントのforum_idは除外します。(そうしないと、コメントがだぶって表示されてしまいます。) また、第5引数とのOR条件にはなりませんので要注意。
39行目付近と78行目付近の下記のように記述することも可能です。
ここで「$topic.forum_id == 5」の部分は、d3diaryのコメント統合したforum_id番号(ここでは5でしたが、実際の番号)を指定することでd3diaryコメントのリンク飛び先を変更できます。 こうすることで、ユーザーは直に日記記事とコメント表示画面に飛べますので、必要に応じて設定してください。
もちろん、編集せずにオリジナル記述のままでも構いません。
| <{if $topic.forum_id == 5}>
<a href="<{$xoops_url}>/modules/diary/index.php?page=detail&bid=<{$topic.link_id}><{$block.unique_key}><{$topic.unique_path}>">
<{else}>
<a href="<{$block.mod_url}>/index.php?topic_id=<{$topic.id}>#post_id<{$topic.last_post_id}>">
<{/if}>
|
ブロックの複製
- d3diaryの「日記コメントトピック 」を「複製」します。
- 複製したブロックの「編集」
- 表示件数は、d3diaryコメント分のみの取得件数になります。
- フルサイズ表示するかどうか、ここの指定が表示時に有効になります。
- 「このブロックのテンプレート」に、先ほど作成したカスタムテンプレート「_custom_d3diary_d3com_topics.html」を指定します。
結果のスクリーンショット
- 閲覧権限フィルター付き日記コメントトピックと、他の掲示板トピックの集約表示
- 閲覧権限フィルター付き日記コメントトピックと、他の掲示板トピックの別ブロック表示
(単に2つの標準ブロックを表示しただけ)
実体ページ:inc/d3diary/d3com_aggre
関連ページ:d3diary開発日記