トップ  >  趣味の部屋  >  XOOPSサイト構築  >  d3commentハック  >  myalbum-P d3コメント選択対応とd3commentクラス
xoops d3forum コメント統合

このページの情報は古く、現在はXoopsX版にて最新版としてコメント統合を組み込み済みのmyalbum-pを配布しています。どうぞそちらをご使用ください。
https://github.com/XoopsX/myalbum-p

概要 anchor.png

以前より、myalbum-Pモジュール をコメント統合で使ってはいましたが、携帯用テンプレートの共有化を行う際に、テンプレートにサイト毎に異なるd3forum_dirnameとforum_idを記述する部分で支障があり、何とかしたいと考え、myalbumP-ver2.88をベースに手を入れてみました。

  1.  D3コメントクラスは、photositeさん配布のもの(ver0.5)をベースにして手を入れています。

  2.  コメント統合先のd3forumディレクトリ名・フォーラムid値は、d3blog d3pipes のコメント統合を参考に、myalbum-Pの管理画面でmodule_configに保存する方式としました。 そして、コメント統合のクラスはd3forum-0.83a以降で実装された新方式(「d3comment」で呼ぶほう)を採用しています。 また、D3commentクラス内でforum_idまで認識するため、テンプレート内に記述する必要がありません。
     こうすることで、複数サイトを共有化している場合でも、携帯用のテンプレートを共通化できますし、テンプレート配布の際にも神経を使わずに済みます。

手順と方法 anchor.png

テンプレートだけでなく、ソースの変更も必要ですので、細かく記しておきます。

なお、個別のアップロードも編集も面倒、という人のために、myalbumP-ver2.88との差分ファイルパックを、ここに置いておきます。 解凍後、夫々のフォルダに上書きアップロードして使えます。

D3commentクラス anchor.png

 D3commentクラスは、下記ファイルをダウンロード後、「(myalbum)/class」内にアップロードして使用します。

filemyalbumD3commentContent.class.php
(081013)
 参照元の、photositeさんの不具合修正版に差し替えました。
 お手数ですが、以前のバージョンをお使いの方は差し替え願います。

 当然ながら、d3forumの方にコメント統合用に掲示板を追加し、(必要があれば)過去のxoopsコメントをインポート後、「コメント統合時の参照方法」に

myalbum::myalbumD3commentContent::

と記載します。(最初の「myalbum」の部分は、インストールディレクトリ名に合わせて変更します。)
 なお、d3forumは0.83a以降のバージョンが必須で、D3commentの最新のAPIクラス群を忘れずにアップして下さい。

myalbumソースの変更 anchor.png

 5つのソースファイルに手を入れます。 こんな方法で良いのか自信はありませんが、間違いではないと思うのでご勘弁。 <img src=" src="http://www.naaon.com/uploads/smil3dbd4d4e4c4f2.gif" />

 (08/09/01:config変数名を、d3pipesなどと同様の標準的なものに変更しました)

xoops_version.php anchor.png

 「xoops_version.php」を編集し、管理画面にmodule_config項目を追加します。
 下記の393~421行目を追記します。

 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
$modversion['config'][] = array(
    'name'            => 'myalbum_usesiteimg' ,
    'title'            => '_ALBM_CFG_USESITEIMG' ,
    'description'    => '_ALBM_CFG_DESCUSESITEIMG' ,
    'formtype'        => 'yesno' ,
    'valuetype'        => 'int' ,
    'default'        => '0' ,
    'options'        => array()
) ;
 
$modversion['config'][] = array(
        'name'            => 'comment_dirname' ,
        'title'            => '_MI_COM_AGENT' ,
        'description'        => '_MI_COM_AGENTDSC' ,
        'formtype'        => 'textbox',
        'valuetype'        => 'text',
        'default'        => '',
    'options'        => array()
);
 
$modversion['config'][]= array(
        'name'            => 'comment_forum_id',
        'title'            => '_MI_COM_AGENTID',
        'description'        => '_MI_COM_AGENTIDDSC',
        'formtype'        => 'textbox',
        'valuetype'        => 'int',
        'default'        => '0',
    'options'        => array()
);
 
$modversion['config'][] = array(
    'name'            => 'comment_view' ,
    'title'            => '_MI_COM_VIEW' ,
    'description'        => '_MI_COM_VIEWDSC' ,
    'formtype'        => 'select' ,
    'valuetype'        => 'text' ,
    'default'        => 'listposts_flat' ,
    'options'        => array( '_FLAT' => 'listposts_flat' , '_THREADED' => 'listtopics' )
) ;
 
// Search
languages/japanese/modinfo.php anchor.png

 「modinfo.php」を編集し、上の作業で追加した管理画面の項目に日本語テキストを追加します。
 以下の117~行目を追記します。

117
118
119
120
121
122
123
124
125
126
//d3comment integration
define("_MI_COM_AGENT","コメント統合するd3forumのdirname");
define("_MI_COM_AGENTDSC","d3forumのコメント統合機能を使用する場合は<br/>フォーラムのhtml側ディレクトリ名を指定します。<br/>xoopsコメントを使用する場合やコメント機能を無効にする場合は空欄です。");
define("_MI_COM_AGENTID","コメント統合するフォーラムの番号");
define("_MI_COM_AGENTIDDSC","コメント統合を選択した場合、forum_idを必ず指定してください。");
define("_MI_COM_VIEW","コメント統合の表示方法");
define("_MI_COM_VIEWDSC","フラット表示かスレッド表示化かを選択します。");
}
 
?>
header.php anchor.png

08/09/01 このファイル「header.php」の編集では、xoops2.0.16a-JPで問題がありましたので、訂正します。

index.php anchor.png

「index.php」の、54行目以降を以下のように編集します。

54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
while( $fetched_result_array = $xoopsDB->fetchArray( $prs ) ) {
    $xoopsTpl->append( 'photos' , myalbum_get_array_for_photo_assign( $fetched_result_array , true ) ) ;
}
 
        // モジュールID  // added by naao
        $module_handler =& xoops_gethandler('module');
        $this_module =& $module_handler->getByDirname($mydirname);
        $mid = $this_module->getVar('mid');
 
        // モジュールconfig  // added by naao
        $config_handler =& xoops_gethandler("config");
        $mod_config = $config_handler->getConfigsByCat(0, $mid);
        $xoopsTpl->assign("moduleConfig", $mod_config);
 
include( XOOPS_ROOT_PATH . "/footer.php" ) ;
 
?>
photo.php anchor.png

「photo.php」の、117行目以降を以下のように編集します。

115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
$xoopsTpl->assign( 'photo_nav' , $photo_nav ) ;
 
// comments
        // モジュールID  // added by naao
        $module_handler =& xoops_gethandler('module');
        $this_module =& $module_handler->getByDirname($mydirname);
        $mid = $this_module->getVar('mid');
 
        // モジュールconfig  // added by naao
        $config_handler =& xoops_gethandler("config");
        $mod_config = $config_handler->getConfigsByCat(0, $mid);
        $xoopsTpl->assign("moduleConfig", $mod_config);
 
include XOOPS_ROOT_PATH.'/include/comment_view.php';
 
include( XOOPS_ROOT_PATH . "/footer.php" ) ;
 
?>
viewcat.php anchor.png

「viewcat.php」の、139行目以降を以下のように編集します。

136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
        $xoopsTpl->append( 'photos' , $photo ) ;
    }
}
        // モジュールID  // added by naao
        $module_handler =& xoops_gethandler('module');
        $this_module =& $module_handler->getByDirname($mydirname);
        $mid = $this_module->getVar('mid');
 
        // モジュールconfig  // added by naao
        $config_handler =& xoops_gethandler("config");
        $mod_config = $config_handler->getConfigsByCat(0, $mid);
        $xoopsTpl->assign("moduleConfig", $mod_config);
 
include( XOOPS_ROOT_PATH . "/footer.php" ) ;
 
?>

テンプレートの編集 anchor.png

 続いて、テンプレートを2つ、Altsysなどで編集します。 

myalbum_photo.html anchor.png

 「myalbum_photo.html」の、97行目付近を以下のように編集します。

Everything is expanded.Everything is shortened.
 98
 99
100
101
 
 
 
 
    <{* COMMENT COUNTS *}>
    <img src='<{$mod_url}>/images/comments.gif' width='16' height='16' alt='<{$lang_commentsc}>' title='<{$lang_commentsc}>' /><{$photo.comments}> &nbsp; &nbsp;
 
    <{* RANK & RATING *}>

 ↓ ここを変更

Everything is expanded.Everything is shortened.
 98
 99
100
101
102
103
104
105
106
107
108
109
110
 
 
 
 
 
 
 
 
 
 
 
 
 
    <{* COMMENT COUNTS *}>
    <img src='<{$mod_url}>/images/comments.gif' width='16' height='16' alt='<{$lang_commentsc}>' title='<{$lang_commentsc}>' />
    <{if $moduleConfig.comment_dirname}>
        <{d3comment mode="count" var="comcount" mydirname=$xoops_dirname id=$photo.lid class="myalbumD3commentContent"}>
        <{if $comcount}>
            (<{$comcount}>)
        <{else}>
            (0)
        <{/if}>
    <{else}>
        <{$photo.comments}>
    <{/if}> &nbsp; &nbsp;
    <{* RANK & RATING *}>

そして、153行目付近を変更

Everything is expanded.Everything is shortened.
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
<div style="margin: 3px; padding: 3px;">
<{if $moduleConfig.comment_dirname}>
 <{d3comment mydirname=$xoops_dirname id=$photo.lid subject=$photo.title class="myalbumD3commentContent"}>
 
<{else}>
 <div style="text-align: center; padding: 3px; margin: 3px;">
  <{$commentsnav}>
  <{$lang_notice}>
 </div>
 
<!-- start comments loop -->
<{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}>
<!-- end comments loop -->
<{/if}>
</div>
myalbum_photo_in_list.html anchor.png

 「myalbum_photo_in_list.html」の、97行目付近を以下のように編集します。

Everything is expanded.Everything is shortened.
89
90
91
92
 
 
 
 
    <{* COMMENT COUNTS *}>
    <img src='<{$mod_url}>/images/comments.gif' width='16' height='16' alt='<{$lang_commentsc}>' title='<{$lang_commentsc}>' /><{$photo.comments}> &nbsp; &nbsp;
 
    <{* RANK & RATING *}>

 ↓ ここを変更

Everything is expanded.Everything is shortened.
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
 
 
 
 
 
 
 
 
 
 
 
 
 
 
    <{* COMMENT COUNTS *}>
    <img src='<{$mod_url}>/images/comments.gif' width='16' height='16' alt='<{$lang_commentsc}>' title='<{$lang_commentsc}>' />
    <{if $moduleConfig.comment_dirname}>
        <{d3comment mode="count" var="comcount" mydirname=$xoops_dirname id=$photo.lid class="myalbumD3commentContent"}>
        <{if $comcount}>
            (<{$comcount}>)
        <{else}>
            (0)
        <{/if}>
    <{else}>
        <{$photo.comments}> &nbsp; &nbsp;
    <{/if}>
 
    <{* RANK & RATING *}>

モバイル用テンプレート anchor.png

 モバイルテンプハウスで、作成・公開中。 

インストールと設定 anchor.png

 xoops管理画面の「モジュールの管理」で、「myalbum」をモジュールアップデートします。 これで、「myalbum」の管理画面に、3つの項目が追加されます。

myalbum_config.gif

ここで、

  1. コメント統合するd3forumのdirname : d3forumのコメント統合機能を使用する場合はd3forumのhtml側ディレクトリ名を指定します。xoopsコメントを使用する場合やコメント機能を無効にする場合は空欄です。
  2. コメント統合するフォーラムの番 : コメント統合を選択した場合、統合先のforum_id値を必ず指定してください。
  3. コメント統合の表示方法 : フラット表示かスレッド表示かを選択します。

これらを設定すれば完了です。(この編集を行うまでは、xoopsコメントシステムが有効です。)

その他 anchor.png

ライセンス anchor.png

  • myalbumソース、d3forumソース、photositeさんのd3commentクラス:GPL

実体ファイル:inc/myalbum_d3com
関連記事:

プリンタ用画面
投票数:47 平均点:5.96
前
piCal d3コメント選択対応とd3commentクラス
カテゴリートップ
d3commentハック

コメント一覧

投稿ツリー

トピック


なーお  投稿日時 2008/9/1 0:29 | 最終変更

myalbum-Pの、コメント統合の簡単化の中で、module_configをassignする場所、「header.php」ではxoops2.0.16a-JPでFatalエラーが出てしまっていたのに気づき、あわてて修正しました。 :-P

「index.php」「photo.php」の2つのファイル +「viewcat.php」計3つのファイル に追記することにしました。

・・ まったく、XCLだけでなくてX2でもきちんと検証しないとだめですよね。申し訳ありません。 GIJOEさんに怒られそうです。 :-?

photosite サイトURL  投稿日時 2008/10/4 14:03

こん○○は :-)

myalbum-P と piCalの コメント統合クラスに、私の大ボケが原因で、バグがあることに、ようやく気がつきました :cry:

なーおさんが配布されているコメント統合クラスにも、同じバグがあるようですので、修正していただきますでしょうか。

私が配布している最新版のコメント統合クラスは、次の URL でダウンロードすることができます。

【myAlbum-Pの d3forumコメント統合用クラス】
http://www.photositelinks.com/modules/mydownloads/index.php?page=singlefile&cid=1&lid=1

【piCalの d3forumコメント統合用クラス】
http://www.photositelinks.com/modules/mydownloads/index.php?page=singlefile&cid=1&lid=5

よろしくお願いします。

なーお  投稿日時 2008/10/4 15:04

photositeさん、こんにちは。

こちらまでわざわざご連絡いただき、ありがとうございます! :-)

了解しました。後日、私のページも更新しておきます。

また何かありましたら、よろしくお願いします。 どうもありがとうございました。

なーお  投稿日時 2008/10/13 10:52 | 最終変更

photositeさんからご連絡を受けた、myalbumのコメント統合クラスの差し替え版を公開しました。

文中の

・myalbum_288a4_diff.zip か、
・myalbumD3commentContent.class.php

 をご使用ください。 :-)

なーお  投稿日時 2009/3/21 19:43 | 最終変更

myalbum-P d3コメント対応 のバージョンアップをしました。

「myalbum_288a5_diff.zip」をダウンロードし、上書きしてください。
本バージョンでは、d3forum-0.85で追加されたコメント統合の以下の機能に対応しています。 アップデート後にmyalbum-Pの管理画面で指定してください。

  1. コメント元ページでのコメントの昇順/降順指定
  2. 2. コメント元ページでのコメントの最大表示数

なお、本アップデートに伴うテンプレート変更はありません。



新しくコメントをつける

題名
ゲスト名
投稿本文
より詳細なコメント入力フォームへ

ブックマーク