relatedlist.inc.php

関連付けられているページを、listプラグインのように、ページ名の頭の文字で分類して一覧表示します。

書式

#relatedlist([pagename])
pagename
対象とするページ名。ここで指定されたページに関連付けられているページ一覧を表示する。省略時は、設置してあるページ。

使い方

例を示す。

#relatedlist(FrontPage)

とすると、次のようになる。

P

仕様

relatedプラグインと違って、そのページからリンクしているページはリストにしません。

ダウンロード

簡単なので、コードを貼り付けておきます。

  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
<?php
 
//relatedlist.inc.php
//based on related.inc.php
//Version 0.0.1
//作成者:どぼん!
 
//除外するページの正規表現パターン
define('PLUGIN_RELATEDLIST_EXCEPT', '/(?:^|\/)template$/');
 
function plugin_relatedlist_init()
{
    global $whatsnew, $whatsdeleted, $menubar;
    
    //除外するページを指定する
    $_plugin_relatedlist_messages = array(
        '_plugin_relatedlist_except_pages'=>
            array($whatsnew, $whatsdeleted, $menubar),
    );
    set_plugin_messages($_plugin_relatedlist_messages);
}
 
function plugin_relatedlist_convert()
{
    global $vars, $script, $non_list, $defaultpage;
    global $_plugin_relatedlist_except_pages;
 
    $args = func_get_args();
 
    $page = isset($args[0]) ?
        strip_bracket(array_shift($args)) : $vars['page'];
    if (empty($page)) $page = $defaultpage;
 
    $data = links_get_related_db($page);
 
    $pages = array_keys($data);
    //$non_listを除外する
    $pages = array_diff($pages,
        preg_grep('/' . $non_list . '/', $pages));
    //設定によりさらにページを除外する
    if (PLUGIN_RELATEDLIST_EXCEPT != '')
        $pages = array_diff($pages,
            preg_grep(PLUGIN_RELATEDLIST_EXCEPT, $pages));
    if (!empty($_plugin_relatedlist_except_pages))
        $pages = array_diff($pages, $_plugin_relatedlist_except_pages);
 
    if (empty($pages))
        return '<ul><li>No related pages found.</li></ul>' . "\n";
    
    return page_list($pages);
}
 
?>

ライセンス

GPL

コメント



ページ情報
[ トップ ]   [ 新規 | 子ページ作成 | 一覧 | 単語検索 | 最終更新 | ヘルプ ]