DokuWiki

It's better when it's simple

ユーザ用ツール

サイト用ツール


ja:plugin:tag

タグプラグイン

互換性のある DokuWiki バージョン

Weatherwax, Binky, Ponder Stibbons, Hrun, Detritus, Elenor of Tsort

plugin wikiページにカテゴリタグを割り当てます。

最終更新日
2016-01-16
種類
Syntax, Helper, Action
リポジトリ
ソース
必要
pagelist

この拡張は二年以上更新されていません。もはや維持管理や対応がされておらず、互換性に問題がある可能性があります。

This extension is not in the 'plugin' or 'template' namespace and is therefore ignored.

類似 blogtng, geotag, subjectindex, tagging, tagsections

タグ blog, listing, navigation, tags

必要とされるプラグイン editor, feed, include, tagadd, tagalerts, tagentry, tagfilter, tagsections, tr-twitter

:!: 2013年2月15日リリースでセキュリティ上の問題(XSS脆弱性)を修正しました。タグプラグインの古いバージョンを使用している場合は、できるだけ早くアップグレードする必要があります! :!:

説明

タグプラグイン は、wikiページにカテゴリタグを割り当てることができます。

2012年8月24日以前からの更新:タグプラグインを削除し、再インストールしてください。 プラグイン管理のバグのため、アップデートはプラグインにとって不要な部分を削除しません。 タグプラグインのタグ格納方法に大きな変更があります。 タグのあるページへのアクセスによるタグ索引の自動的な再構築を待てない場合、手動でタグ索引を再構築できます。 クラウドプラグインも更新する必要があります。 そうしないと、タグクラウドは動かなくなるでしょう。

構成要素

Tag

{{tag>[list of tags]}}
[list of tags] 現在のページの内容を記述したタグをスペースで区切ったリスト 必須項目

wikiページを分類することができます。 指定されたタグ名前空間内に同名のページが存在する場合、そのページへのリンクとなります。 別の名前空間内のページにリンクをしたい場合、タグ名の前に名前空間を指定する必要があります。 ページが存在しない場合は、それらのいずれかのリンクをたどると、同じタグを持つページのリストだけが表示されます。

例:

  • {{tag>tag1 tag2 tag3}}
  • 名前空間を指定: {{tag>ns1:tag1 ns1:tag2 ns2:subns1:tag3}}
  • 複数単語のタグ: {{tag>tag1_with_multiple_words tag2 tag3_part}}

Topic

{{topic>[tag]&[flags]}}
[tag] 表示したいページ一覧のカテゴリータグ 必須項目
[flags] &区切りのページ一覧フラグ。flags参照 任意項目

指定したカテゴリタグを含むすべてのページ一覧を表示します。 一覧はページIDを使ってアルファベット順にソートされています。 また +- という修飾子をカテゴリータグの前に付けることができます。 + は、事前に指定されたタグによって選択されたページ一覧と + を付けたタグによって選択されたページとの交点を作成します(AND検索)。 - は、事前に指定されたタグによって選択されたページ一覧から、 - を付けたタグを含んだページを全て削除します。

例:

  • {{topic>tag1 -tag2}} – tag1 を持ち tag2 を持っていないページの一覧。
  • {{topic>tag1 +tag2}} – tag1 と tag2 を両方持っているページの一覧。
  • {{topic>tag1 tag2}} – tag1 か tag2 のどちらか、又は両方持っているページの一覧。
  • {{topic>ns1?tag1 tag2}} – ns1 名前空間内の、tag1 か tag2 のどちらかを持っているページの一覧。
  • {{topic>.?tag1 tag2}} – 現在の名前空間内の、tag1 か tag2 のどちらかを持っているページの一覧。
  • {{topic>tag1 tag2 tag3&nodate&desc&sort}} (デザインを変更するためのpagelist オプションを追加)

Searchtags

 {{searchtags&[flags]}}
[flags] &区切りのページ一覧フラグ。flags参照 任意項目

名前空間の選択と全タグ一覧からタグを含む・含まないを選択できる検索フォームが表示されます。

名前空間の選択と全タグ一覧からタグの選択ができる検索フォームを表示します。 タグを AND や OR と関連付ければ、選択したタグを含むのか除外するのかの選択オプションとなります。 結果は Topic 構成要素のように表示されます。

これはあなたが逃すべきではない素晴らしい機能です。 このクールな機能のスクリーンショットを追加してください。 FIXME

また、 タグフィルター プラグインを同様の目的で別のシナリオでチェックアウトすることもできます。

例:

  • {{searchtags}} – 基本構文
  • {{searchtags&nodate&desc&sort}} – 表示を変更するための pagelist オプション

Count

{{count>[tag]}}
[tag] 使用回数を表示したいカテゴリータグ 必須項目

現在使用されているタグの概要を表示することができます。 Wiki 内のタグと使用回数(タグの使用頻度)を表示します。 タグ名に +を指定すると、使用されているすべてのタグのリストが得られます。 あるいは、スペースで区切られたタグを指定するだけです。

例:

  • {{count>+}} – 使用回数付きの全仕様タグ。
  • {{count>tag1 tag2}} – tag1 tag2 の使用回数。
  • {{count>tag1 tag2 tag3&. ns1 ns2}} – 名前空間(ピリオドはルート名前空間の指定)内の指定タグの使用回数。

Tagpage

 {{tagpage>[tag][&dynamic][|title]}}

Tag 構文と同様ですが、そのタグでページをタグ付けすることなく、全タグ一覧へのリンクを表示します。 オプションの dynamic フラグを指定すると、現在のユーザーにとってそのタグを持つページ一覧が空の場合、リンクは赤くなります。 リンクの色が常に正しいことを確認するために、dynamic フラグは現在のページのキャッシュを無効にします。 リンク名として使用される title は任意で指定できます。

例:

  • {{tagpage>test_foo}} – 基本構文
  • {{tagpage>test_foo&dynamic}} – dynamic リンク色のリンク
  • {{tagpage>test_foo|my title}} – カスタムタイトルのリンク
  • {{tagpage>test_foo&dynamic|my | title}} – dynamic リンクの色でカスタムタイトル(| を含むことも可能)のリンク

設定

管理者メニューにある設定管理画面上で、プラグインの設定ができます。

namespace タグプラグインがタグページを探し、存在している場合、デフォルトのタグ概要の代わりにそのページへのリンクする名前空間。そのページでタグの一覧を表示するのに、例えば Topic 構成要素を利用できます。(デフォルト値 tag)
sortkey Topic 構成要素でタグ付きページがソートされる順序。利用可能なオプションは、作成日 cdate、修正日 mdate、ページ名 pagename、ページID id、名前空間 ns 、タイトル title
sortorder トトピック概要の並べ替えの順序
pagelist_flags トピック概要の表示で使用するpagelist プラグインフラグカンマ区切り
toolbar_icon 編集ツールバーにタグ追加ボタンを表示する。
list_tags_of_subns 指定する名前空間内のタグを数える際、下位の名前空間内タグも含む
tags_list_css 標準との間でタグのリストスタイルを選択するか、ページの先頭位置に合わせて最適化します。

タグインデックスの再構築

タグインデックスが(ページ移動を使用するなど)何らかの理由で破損した場合、 searchindexbin/indexer.phpを使用してタグインデックスを再構築することができます。

デモ/スクリーンショット

変更履歴

  • 2014-02-16
    • 新規翻訳と更新された翻訳
    • Fixed tag searching with out of date indexes and numbers
    • 新しい Dokuwiki 機能を使用できるようにするために、2013-05-10 “Weatherwax” より古い Dokuwiki との互換性を止める。
  • 2013-04-14
    • 新しいソートキー “ns” 。名前空間内のページをページ名でソート後、名前空間名で全名前空間をソートする。
    • ソートキーがタイトルなのにタイトルがない場合、(pagelistプラグインで表示される)ページ名でソートする。
    • topic 構文の中で、“+” や “-” を持ったタグで始まる問い合わせは、全ページに対する暗黙の問い合わせとします。これによって “+tag +tag2” は “tag +tag2” と同じ意味になり、“-tag1” は tag1 以外の全ページを返します。
    • The tagRefine-function (used by the blog plugin) now also supports tags without “+” or “-”
    • Revert the tag query change that was introduced in version 2012-08-24, before this change the query was executed as if all tags with a “+” or “-” were at the end while the documentation actually describes that the order matters. Each part of the query modifies the existing result set and either adds new pages (tag without “+” or “-”) or removes all pages with (“-”) or without a tag (“+”).
  • 2013-04-05:
    • New tagpage feature for creating a link to the list of all pages with a certain tag without tagging the page
    • Removed the Technorati ping feature as Technorati is no longer using any pings
    • zh-tw translation updated
  • 2013-02-15:
    • :!: セキュリティ上の問題(XSS脆弱性)の修正。タグプラグインの古いバージョンを使用している場合は、できるだけ早くアップグレードする必要があります!
  • 2012-11-25
    • New searchtags feature, displays a search form for the topic syntax
    • Fix section edit button styles for the new dokuwiki template
    • In the topic syntax now really only namespaces and not pages are matched by namespace parameter
    • When sorting by the title the case is ignored now
    • The topic syntax of the tag plugin is now used instead of the topic syntax of the blogtng plugin when both are installed
    • Fix problems that tags could be missing when another page is rendered during the preview or when an old revision is diplayed
  • 2012-08-24
    • The tag plugin is now using the metadata index of DokuWiki instead of its own index for storing tags. Most plugins that need the tag plugin need to be adapted.
    • Tags are now normalized in the same way as page ids are normalized

開発版 変更履歴:

このプラグインを利用しているサイト

自由に追加してください:

FAQ

複数の単語で構成されたタグを使用する方法?

“_” を使用します。“_” は自動的に “ ” に置換えられます。 例:

{{tag>tag_with_multiple_words}}

また、引用符も作動するようです:

{{tag>"tag with multiple words"}}

既存のタグに応じてCSSスタイルを変更する

これはキーワード 'deprecated'がタグとして指定されている場合、ページの背景を赤に色付けします。

function _handle_keywords(&$data) {
        global $ID;
 
        // Fetch tags for the page; stop proceeding when no tags specified
        $tags = p_get_metadata($ID, 'subject', METADATA_DONT_RENDER);
        if(is_null($tags)) true;
 
        // Replace underscores with blanks
        foreach($data->data['meta'] as &$meta) {
            if($meta['name'] == 'keywords') {
                $meta['content'] = str_replace('_', ' ', $meta['content']);
 
                $t = explode(',', $meta['content']);
                if(in_array('deprecated', $t)) {
                    $data->data['style'][] = array('type'  => 'text/css',
                                                     '_data' => '.dokuwiki .page {background-color: red;}');
                }
            }
        }       
}

パンくずリストのカスタマイズ

あなたが pagelist / helper.php に追加した場合

function tpl_youarehere2_help($id){
    $result = '';
    global $conf;
    global $ID;
    global $lang;
    // check if enabled
    if(!$conf['youarehere']) return false;
    $parts = explode(':', $id);
    $count = count($parts);
    // always print the startpage
    $result .= html_wikilink(':'.$conf['start']);
    // print intermediate namespace links
    $part = '';
    for($i=0; $i<$count - 1; $i++){
        $part .= $parts[$i].':';
        $page = $part;
        if ($page == $conf['start']) continue; // Skip startpage
        // output
        $result .= ' &raquo '.html_wikilink($page);
    }
    // print current page, skipping start page, skipping for namespace index
    resolve_pageid('',$page,$exists);
    if(isset($page) && $page==$part.$parts[$i]) return $result;
    $page = $part.$parts[$i];
    if($page == $conf['start']) return $result;
    $result .= ' &raquo '.html_wikilink($page);
    return $result;
}
 
function tpl_youarehere2($id) {
    $str = $this->tpl_youarehere2_help($id);
    $pos = strrpos($str , '&raquo');
    if ($pos == -1)
    return $str;
    return substr($str, 0, $pos);
}
 
function addPage2($page) {
    $id = $page['id'];
    if (!$id) return false;
    $this->page = $page;
    $this->_meta = NULL;
    // priority and draft
    if (!isset($this->page['draft'])) {
        $this->page['draft'] = ($this->_getMeta('type') == 'draft');
    }
    $class = '';
    if (isset($this->page['priority'])) $class .= 'priority'.$this->page['priority']. ' ';
    if ($this->page['draft']) $class .= 'draft ';
    if ($this->page['class']) $class .= $this->page['class'];
    if(!empty($class)) $class = ' class="' . $class . '"';
    $this->doc .= DOKU_TAB.'<tr'.$class.'>'.DOKU_LF;
    $this->_pageCell($id);
    if ($this->column['date']) $this->_dateCell();
    if ($this->column['user']) $this->_userCell();
    if ($this->column['desc']) $this->_descCell();
    foreach ($this->plugins as $plug => $col) {
        if ($this->column[$col]) $this->_pluginCell($plug, $col, $id);
    }
    $this->doc .= DOKU_TAB.'</tr>'.DOKU_LF;
    $this->doc .= DOKU_TAB.'<tr'.$class.'>'.DOKU_LF;
    $this->doc .= DOKU_TAB.DOKU_TAB.'<td style="padding-left:19px; padding-right:15px; padding-bottom:15px; font-size:10px;">';
    $this->doc .= $this->tpl_youarehere2($id);
    $this->doc .='</td>'.DOKU_LF;
    $this->doc .= DOKU_TAB.'</tr>'.DOKU_LF;
    return true;
}

また tag/action.php を修正してください。

$pagelist->setFlags($flags);
$pagelist->startList();
foreach ($pages as $page) {
    $pagelist->addPage($page);
}

$pagelist->setFlags($flags);
$pagelist->startList();
foreach ($pages as $page) {
    $pagelist->addPage2($page);
}

その後、その下にあるページ自体の名前を除いて、タグを含むページのリストも、これらのページへのパンくずリストになります。

ページの上部にタグを表示する場合の外観不良

:!:メインコードに統合されています( tags_list_css を参照)。

Wikiページの上部に構文を挿入すると、プラグインの出力がTOC(目次)の下に表示されます。 視覚的外観をより滑らかにするには、 lib / plugins / tag / style.css を次のコードに変更します:

div.dokuwiki div.tags {
  border-top: 2px dotted __border__;
  font-size: 95%;
  text-align: right;
/*  clear: both; */
}

別の言語にタグとトピックの単語を変更する方法

議論

Discussion 参照。

ja/plugin/tag.txt · 最終更新: 2016-12-17 18:05 by hosimori

特に明示されていない限り、本Wikiの内容は次のライセンスに従います: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki