Strict Standards: Non-static method Protector::getInstance() should not be called statically in /home/suehirogari/suehirogari.com/xoops_trust_path/modules/protector/include/precheck_functions.php on line 12

Strict Standards: Non-static method XCube_Root::getSingleton() should not be called statically in /home/suehirogari/suehirogari.com/public_html/include/common.php on line 18

Deprecated: Non-static method XCube_Root::getSingleton() should not be called statically, assuming $this from incompatible context in /home/suehirogari/suehirogari.com/public_html/modules/user/preload/Primary/Primary.class.php on line 13
D3blogモジュールに、人気記事一覧ブロックを追加する方法 | 社内SEのウェブ制作

2013.08.13xoopsズープス

D3blogモジュールに、人気記事一覧ブロックを追加する方法

 

まずはブロックを作る。
最新記事一覧(latest_entries)が機能的にとても近いので、これをコピーして作る。
(ブロックのコードは xoops_trust_path/modules/d3blog/blocks/ にある)

変更点はたったの4箇所。
最初の2箇所は関数名だ。
b_d3blog_latest_entries_show と b_d3blog_latest_entries_edit をそれぞれ
b_d3blog_popular_entries_show と b_d3blog_popular_entries_edit に書き換えるのだ。
次に利用するテンプレート名を変更する。
_block_latest_entries.php を block_popular_entries.php に書き換える。
そして、最後の1箇所はソート条件。
published を counter に書き換える。
これでコードの書き換えは完了だ。

... function b_d3blog_popular_entries_show($options) {    ...     $opt_template = empty( $options[10] ) ? 'db:'.$mydirname.'_block_popular_entries.html' : trim( $options[10] );    ...         $criteria->setSort('counter');    ... function b_d3blog_popular_entries_edit($options) {    ... 

同様にテンプレートを作る。
テンプレートは単純に block_latest_entries.html をコピーして、 block_popular_entries.html として保存する。
(テンプレートは xoops_trust_path/modules/d3blog/templates/ にある)
これでOK

次にブロックを登録する。
xoops_version.php を開いて、これもコピー&ペースト。

$m++; $modversion['blocks'][$m]['file'] = 'blocks.php'; $modversion['blocks'][$m]['name'] = constant($constpref.'_POPULAR_ENTRIES'); $modversion['blocks'][$m]['description'] = constant($constpref.'_POPULAR_ENTRIES_DESC'); $modversion['blocks'][$m]['show_func'] = 'b_d3blog_popular_entries_show'; $modversion['blocks'][$m]['edit_func'] = 'b_d3blog_popular_entries_edit'; $modversion['blocks'][$m]['template'] = ''; $modversion['blocks'][$m]['options'] = $mydirname.'|5|25|Y/m/d|1|0|0|0|||'; $modversion['blocks'][$m]['can_clone'] = true ; 

次に言語定数を追加する。
modinfo.php を開いて、これまたコピー&ペーストで追加する。

define ( $constpref.'_POPULAR_ENTRIES','人気のエントリ'); define ( $constpref.'_POPULAR_ENTRIES_DESC','人気エントリの一覧'); 

ここまで準備できたら、

  • block_popular_entries.php
  • block_popular_entries.html
  • xoops_version.phpmodinfo.php

 

をアップロード。その後xoopsの管理画面で、
モジュールアップデートを行う。


そうすると、ブロック一覧に、

「人気エントリの一覧」ブロックが追加されてます。

 

記事もとは以下のページです。

http://xcl.masa-lab.net/modules/d3blog/details.php?bid=179


このカテゴリの人気記事



  • コメント (0)
  • トラックバック (0)
  • 閲覧 (18306)

トラックバック

トラックバックpingアドレス http://www.suehirogari.com/modules/blog/tb.php/827

コメントの投稿

コメント投稿に関するルール : コメントは全て承認が必要

キーワードでサイト内を検索
人気のエントリ