バージョン | 1.4.7 |
---|---|
投稿者 | あき |
状態 | 完了 |
投稿日 | 2009-01-27 (火) 12:47:34 |
ある階層のページ数をカウントし、その合計数を表示することのできるプラグインはありますでしょうか?
例えば以下のようなページがあって、4階層目を指定すると「6」と表示されるような感じです。
用語/A~C/A/aa
用語/A~C/A/ab
用語/A~C/B
用語/A~C/C/c
用語/D~F/D/da
用語/D~F/D/de
用語/D~F/E
用語/D~F/F/fab
<?php function plugin_pagecount_inline() { if(func_num_args() > 2) list($prefix, $depth) = func_get_args(); else return ' pagecount usage:&pagecount(<em>prefix</em>,<em>depth</em>); '; if(!is_numeric($depth) || $depth <= 0) return ' pagecount error: Invalid <em>depth</em> value.'; $all = ($prefix == ''); $depth--; $count = 0; foreach (get_existpages() as $page) if($all || strpos($page,$prefix) === 0) if(substr_count($page,'/') == $depth) $count++; return $count; } ?>使い方は&pagecount(カウント対象ページ名の頭,カウント対象階層);のような感じで、上の例なら「&pagecount(用語/,4);」のように書いてやれば「6」と出力されると思います。適当に作ったので問題があったらすみません。 -- 2009-01-31 (土) 03:23:45