ListPagesモジュール
コピーされたページのリビジョン: 13、最終編集日: 2017年7月13日11時27分 (880日前) 元の文書 http://www.wikidot.com/doc-modules:listpages-module

ListPagesモジュールは、サイト内のページを選択して表示する、汎用的で広く使われているツールです。

ListPagesを使用するには、次の一部または全部を決定します。

  • 選択するページ(サイト、カテゴリ、親、タグ、日付など)
  • ページの並び順(昇順、降順)
  • 出力をブロックに分割(ページネーション)
  • 結果をWikidotのテキストとして表示(モジュール本体のテンプレート化)
  • 結果をRSSフィードとしてエクスポート

ListPagesの一般的な構文は以下の通りです。

[[module ListPages 引数...]]
モジュール本体
[[/module]]

デフォルトでは、ListPagesは現在のカテゴリで表示されているすべてのページを、最新のものから最も古いものまで表示します。

モジュール本体には[[code]]や[[html]]を含めることはできません。これらのタグが含まれている場合、モジュールは動作しません。

この例では、現在のカテゴリのページを、作成者と作成日時の詳細とともに一覧表示しています。

[[module ListPages separate="no" limit="5"]]
%%title_linked%% - [[user %%created_by%%]] - %%created_at%%
[[/module]]

実行中:

興味深いリンク - Quintijn - 23 Oct 2023 08:57
Z - Quintijn - 09 Sep 2023 09:23
Y - Quintijn - 09 Sep 2023 09:23
X - Quintijn - 09 Sep 2023 09:22
データフォーム - Rokurokubi - 10 Jul 2020 22:35

命名規則

古い引数名は大文字と小文字が混在 (inMixedCase) しています。最近の引数名は小文字 (in_lower_case) になり、Wikidotではこのスタイルがより体系的に使われるようになります。日付は常に「something_at」、ユーザー名は常に「someone_by」です。リンクされたフィールドは常にsomefield_linkedです。

ページの選択

コピーされたページのリビジョン: 6、最終編集日: 2017年7月13日11時26分 元の文書 http://www.wikidot.com/doc-include:page-selection

次のセレクタのうち1つ以上を指定して、選択するページのセットを絞り込みます。各セレクタには、次のような制約が追加されます。

引数 意味
pagetype ページタイプで選択
category カテゴリで選択
tags タグで選択
parent 親ページで選択
link_to 発リンクで選択
created_at 作成日時で選択
updated_at 更新日時で選択
created_by 原著者で選択
rating 評価で選択
votes 投票数で選択
offset ページのオフセットの後にリストを開始
range ページ範囲を選択
name ページ名で選択
fullname フルネームで選択
_<data-form-field-name> データフォーム内のフィールド値で選択

ページタイプセレクタ:

  • "normal"は名前にアンダースコアがないページを意味します(デフォルト)。
  • "hidden"はアンダースコアで始まるページを意味します。
  • "*"はアンダースコアの有無にかかわらず、すべてのページを意味します。

カテゴリセレクタ:

  • "."は現在のカテゴリを意味します(デフォルト)。
  • "*"はすべてのカテゴリを意味します。
  • それ以外の場合、スペーズまたはカンマで区切られたカテゴリのリストになります。
  • カテゴリはデフォルトでは追加式です(カテゴリ OR カテゴリ OR カテゴリ)。
  • "-category"はこのカテゴリのページを除外することを意味します(AND NOT)。
  • "%%category%%"は現在のページと同じカテゴリを意味します(_templateページで使用されている場合)。

タグセレクタ:

  • "-"は、(可視または不可視の) タグがないページを意味します。
  • "="は、このページと同じ可視タグのいずれかを持つページを意味します。
  • "=="は、このページとまったく同じ可視タグを持つページを意味します。
  • それ以外の場合、スペースまたはカンマで区切られたタグのリストになります。
  • タグはデフォルトでは追加式です(タグ OR タグ OR タグ)。
  • "-tag"は、そのタグが付いていないページを意味します (AND NOT)。
  • "+tag"は、そのタグが付いたページを意味します (AND)。

親ページセレクタ:

  • "-"は親ページがないページを意味します。
  • "="は現在のページの兄弟(同じ親)を意味します。
  • "-="は現在のページとは異なる親を持つことを意味します。
  • "."は現在のページの子(このページが親)を意味します。
  • それ以外の場合、単一のフルページ名を指定します。

発リンクセレクタ:

  • 既存のページのフルネームを入力することで、そのページにリンクしているページを選択します。
  • "."は現在のページにリンクしているページを意味します。

作成日セレクタ:

  • "="は現在のページと同じ日に作成されたことを意味します。
  • "yyyy"は特定の年を意味します。
  • "yyyy.mm"は特定の年と月を意味します。
  • オプションで">", "<", "=", "<=", ">=", "<>"を先頭に付けます(デフォルトは"=")。
  • 日付はサイトローカルのものではなく、現在はすべて協定世界時(グリニッジ標準時)です。
  • "last n unit"または"older than n unit"、'n'はカウント(デフォルトは1)、unitは"hours", "day", "week", "month"です。

更新日セレクタ:

  • 日付はサイトローカルのものではなく、現在はすべて協定世界時(グリニッジ標準時)です。
  • "last n unit"または"older than n unit"、'n'はカウント(デフォルトは1)、unitは"hours", "day", "week", "month"です。

原著者セレクタ:

  • "="は現在のページの著者が作成したことを意味します。
  • "-="は現在のページの著者が作成していないことを意味します。
  • それ以外の場合、単一のユーザー名を指定します。

評価セレクタ:

  • "n"は評価がnに等しいページを意味します。
  • "="現在のページと同じ評価のページを意味します。
  • オプションで">", "<", "=", "<=", ">=", "<>"を先頭に付けます(デフォルトは"=")。

注意: 多数のカテゴリのページをリストアップする場合、カテゴリの中には(サイトマネージャーにて)レーティングの種類が+、+/-、または「スター」に設定されているものがあり、評価による選択や順序付けが正しく行われない場合があります。解決策は、同じ評価モードを持つカテゴリからページをリストアップして順序付けすることです。

投票数セレクタ:

  • "n"はnに等しい票を持つページを意味します。
  • "="は現在のページと同じ票数のページを意味します。
  • オプションで">", "<", "=", "<=", ">=", "<>"を先頭に付けます(デフォルトは"=")。

オフセットセレクタ:

  • "n"は最初のnページを表示しないことを意味します(デフォルトは0)。

範囲セレクタ:

  • "."は現在のページを意味します
  • "before"は現在までのページを意味しますが、現在のページは含みません(ソート後の順序)。
  • "after"は現在のページの後のページを意味します(ソート後の順序)。
  • "others"は現在のページ以外のページを意味します。

ページ名セレクタ:

  • enter a single name (means the name part without the category!) of an existing page to select exact this page of a given category - or pages of different categories if also selected. You can use a dataform field of the current page
  • "=" means pages that have exact the same name as the current page ( makes sence only with other selected categories)
  • "s%" means all pages starting with given character "s" or
  • "s*" means all pages starting with given character "s"

フルネームセレクタ:

  • この1ページを正確に選択するために、既存のページのフルネームを入力します(現在のページのデータフォームフィールドを使用することができます)。

データフォームセレクタ:

  • データフォーム内のフィールド値で選択します。
  • 構文: _data-form-field-name="data-form-field-value"
  • 例: _gender="m" - データフォームの'gender'フィールドの値として'm'が設定されているページをすべて選択します。

ページの並べ替え

ページを並べ替えるには、次の引数を使用します。

引数 意味
order 順序の基準を指定

順序基準:

  • "プロパティ"は"このプロパティによる昇順"を意味します。
  • オプションで、"降順"を意味する" desc"が続きます。
  • オプションで、"昇順"を意味する" desc desc"が続きます。これにより、任意のソート順に"desc"を追加しても安全です。
  • デフォルトは"created_at desc"です。
プロパティ 意味
name ページ名順
fullname カテゴリとページ名順
title ページタイトル順
created_by 著者のスクリーンネーム順
created_at 作成日順
updated_at 更新日順
size ページ内の文字数順
rating 評価順
votes 投票数順
revisions 改訂数順
comments コメント数順
random ランダムに並べ替え、60秒間キャッシュ
_data-form-field-name データフォームのフィールド順

For example to order by rating in descending order:

order="rating desc"

Caution: When listing pages from many categories, where some categories have rating type set to + or +/- and others to "stars" (in Site Manager), selecting and ordering by rating may not funtion properly. The solution is to list and order pages from categories having the same rating mode.

This example shows how to order pages using a data form field. Note that you must prefix the data form field name with an underscore. This lists all pages from the dictionary category and sorts them by the data form's mainword field (a wiki field type in this example). The body of the module then lists the contents of the mainword field and creates a link to the page.

[!--
Note: Use %%form_raw{fieldname}%% for wiki field types,
 %%form_data{fieldname}%% for other field types
--]
[[module ListPages category="dictionary" order="_mainword"]]
%%form_raw{mainword}%%@<&nbsp;>@@<&nbsp;>@([/%%fullname%% see dictionary entry])
[[/module]]

Note that "property asc" is not allowed and unknown order criteria give you the default order, which is "created_at desc".

Type casting for doc:data-forms fields:
Default order method is sort by text. You can enforce numerical sorting.

[[module ListPages category="band" order="_albums::integer desc"]]
...
[[/module]]

ページャー

To control how many items (wiki pages) will be shown in total, and how these are paginated (confusingly, also into 'pages'), use any of:

Argument Meaning
limit 総項目数の制限
perPage ページネーションごとの制限
reverse ページを逆順に表示

合計制限:

  • "number"は選択されたページの合計数を制限することを意味します。
  • デフォルトでは、条件に一致するすべてのページがリストアップされます。

Pagination limit:

  • "number" - means limit the number of page items shown on per pagination.
  • default is 20, maximum is 250.

Reversed display:

  • "yes" - means show wiki pages from last to first on given page.

モジュール本体

The body of the module allows you to specify how page properties and content is formatted. To control this formatting, you can use these module arguments:

引数 意味
separate Separation specifier
wrapper Wrapper specifier
prependLine Header specifier
appendLine Footer specifier

Separation specifier:

  • "yes" means place each page item into a separate container (divs).
  • "no" means put all items into one container, so they can become a single list, for example.
  • default is "yes".

With separate set to true, each of the page is compiled (converted from wiki source to HTML) separately. While it is false, wiki compiler is invoked only once on a combined source from all selected pages.

As a result, some page-specific variables and constructs such as iftags can generate different results. iftags, with separate="yes", will be aware of tags of individual pages, while with separate="no" it will read tags of the main page that holds the ListPages module.
Also [[image :first ...]] will only work with separate="yes".

Wrapper specifier:

  • "yes" means place all items into container (div).
  • "no" means do not place all items into container (div).
  • default is "yes".

Header specifier:

  • "text" means output this text at the start of the list of pages, only if the separation specifier is false.

Footer specifier:

  • "text" means output this text at the end of the list of pages, only if the separation specifier is false.

head/body/footセクション

さらに、prependLineやappendLineを単純に置き換え、[[head]][[body]][[foot]]のセクションを使用することもできます。これにより、ListPages用のより複雑なヘッダーやフッターを作成できます。これは特に、複雑な表やリストを作成する場合に適しています。

セクションの使用例

[[module ListPages category="carousel" wrapper="no" separate="no" _active="yes"]]
 [[head]]
 [[ul id="u-myList" class="..."]]
 [[/head]]
 [[body]]
 [[li class="list-item"]]%%title_linked%% by (%%created_by%%)[[/li]]
 [[/body]]
 [[foot]]
 [[/ul]]
 [[/foot]]
[[/module]]

テンプレートは、%%variable-name%%として指定された変数を含むWikiテキストで構成されています。次のページプロパティを使用できます。

プロパティ 意味
ページのライフサイクル
%%created_at%% Date page was created
%%created_by%% User who created page
%%created_by_unix%% "Unixified" name of user who created page — to be used for constructing URLs
%%created_by_id%% "ID" number of user who created page — to be used for constructing URLs
%%created_by_linked%% Icon and link to user who created page
%%updated_at%% Date page was updated (edited, tagged, parented)
%%updated_by%% User who updated page
%%updated_by_unix%% "Unixified" name of user who updated page — to be used for constructing URLs
%%updated_by_id%% "ID" number of user who updated page — to be used for constructing URLs
%%updated_by_linked%% Icon and link to user who updated page
%%commented_at%% Date of last comment
%%commented_by%% User who made last comment
%%commented_by_unix%% "Unixified" name of user who made last comment — to be used for constructing URLs
%%commented_by_id%% "ID" number of user who made last comment — to be used for constructing URLs
%%commented_by_linked%% Icon and link to user who made last comment
ページ構造
%%name%% カテゴリなしのページ名
%%category%% ページのカテゴリ (存在する場合)
%%fullname%% カテゴリ (存在する場合) 付きのページ名
%%title%% ページのタイトル
%%title_linked%% ページへのリンク (タイトルをテキストとして表示)
%%parent_name%% カテゴリなしの親ページ名
%%parent_category%% 親ページのカテゴリ (存在する場合)
%%parent_fullname%% カテゴリ (存在する場合) 付きの親ページ名
%%parent_title%% 親ページのタイトル
%%parent_title_linked%% 親ページへのリンク (タイトルをテキストとして表示)
%%link%% ページを指すURL
%%content%% ページのコンテンツ
%%content{n}%% 番号付きのコンテンツセクション
%%preview%% ページの最初の200文字
%%preview(n)%% ページの最初のn文字
%%summary%% コンテンツの要約
%%first_paragraph%% ページの最初の段落
%%tags%% ページの可視タグ (アンダースコアで始まらないもの)
%%tags_linked%% ページの可視タグ (system:page-tags/tag/{tag} にリンク)
%%tags_linked|link_prefix%% ページの可視タグ (link_prefix{tag} にリンク)
%%_tags%% ページの不可視タグ (アンダースコアで始まるもの)
%%_tags_linked%% ページの不可視タグ (system:page-tags/tag/{tag} にリンク)
%%_tags_linked|link_prefix%% ページの不可視タグ (link_prefix{tag} にリンク)
%%form_data{name}%% ページのデータフォームのフィールド値 (存在する場合)
%%form_raw{name}%% For select fields, the internal value saved in the page form data, if any
%%form_label{name}%% The label of the field as defined in the data form if any
%%form_hint{name}%% The hint of the field as defined in the data form if any
ページレポート
%%children%% Number of child pages
%%comments%% Number of comments on page
%%size%% Number of characters in page
%%rating%% Page rating value (number or stars depending on Rating settings in Site Manager
%%rating_votes%% Number of votes
%%rating_percent%% Percent value of 5-star rating only
%%revisions%% Number of revisions to page
%%index%% Page index in ListPages output + offset (1 to %%total%%)
%%total%% Total number of pages ignoring limit (may be higher than %%limit%%)
%%limit%% Limit passed to ListPages (empty if not passed)
%%total_or_limit%% Total number of pages in ListPages output (highest %%index%%).
If limit is passed to the module, %%total_or_limit%% is %%total%% or %%limit%% whichever is smaller
現在のコンテキスト
%%site_title%% Title of current site
%%site_name%% Wikidot Unix name for site
%%site_domain%% Active domain name of current site

Date formatting:

  • All _at fields are dates and allow a custom format via the |format specifier.

Most tokens from PHP's strftime are accepted. You may find the howto contributed by community useful.

Editor's note: this section needs expanding with the most useful formatting options.

Tag linking:

  • If no link_prefix is specified, tags link to system:page-tags/tag/name-of-tag
  • If link_prefix is specified, tags link to link_prefixname-of-tag (colors irrelevant)
  • if link_prefix is empty but the pipe is present, %%tags_linked|%% generates links to pages with names corresponding to tags
  • Examples
if syntax is: "shiny" tag will link to:
%%tags_linked%% /system:page-tags/tag/shiny
%%tags_linked|system:page-tags/tag/%% /system:page-tags/tag/shiny
%%tags_linked|interesting-list/category/%% /interesting-list/category/shiny
%%tags_linked|player:%% /player:shiny
%%tags_linked|very_%% /very_shiny
%%tags_linked|http://myothersite.wikidot.com/see-also/tag/%% http://myothersite.wikidot.com/see-also/tag/shiny
%%tags_linked|%% /shiny

高度な使い方

ここでは、上級者に役立つ追加機能について説明します。

RSSフィード

ListPagesの結果をRSSフィードとしてエクスポートすることができます。RSSフィードの生成を制御するには、次の引数を使用します。

引数 意味
rss feed title
rssDescription feed description
rssHome feed homepage
rssLimit feed limit
rssOnly only show feed link

Feed title:

  • "text" means use this text for the RSS feed title.
  • Default is to not generate any RSS feed.

Feed description:

  • "text" means use this text for the RSS feed description.

Feed homepage:

  • "pagename" means tell RSS clients this is the home page for the feed.
  • Default is http://your-site.wikidot.com
  • Setting value to "blog:_start" actually means http://your-site.wikidot.com/blog:_start

Feed limit:

  • sets limit for RSS feed, and can be different to the ListPages limit
  • Default RSS limit inherits lower value from limit and perPage arguments

Feed only:

  • "true" or "yes" displays the RSS feed link without showing ListPages results

Important: RSS feed ignores "created_at" selector.

URL経由で引数を渡す

ListPages lets you create variations of a single list using specially constructed links, consisting of the page URL (link) followed by arguments and values. These are mainly useful to invoke new selectors, and change the ordering or display.

You can pass any arguments in the URL by specifying argument="@URL|default-value" as the argument value and then appending "/name/value" to the URL used to invoke the page. If the URL does not contain a value for the argument, the default is used. Arguments that do not have @URL in their value cannot be set via the URL. The default value is optional: if you use only argument="@URL" and do not provide a value on the URL, then the argument behaves as if it was not set.

The two main ways of using arguments-by-URL are (a) to create links to a page explicitly, on another page and (b) to generate links within the ListPages itself, so it will reshow itself with different configurations. Here is a simple example:

[[module ListPages category="@URL|design"]]
%%name%% in category %%category%%
[[/module]]

Another example shows how to select blog entries by created_at date:

[[module ListPages category="blog" created_at="@URL"]]

and the module will read the created_at argument from the properly-constructed URL, e.g.

http://www.wikidot.com/blog/created_at/2008.07

You can specify multiple arguments like this:

http://www.wikidot.com/blog/created_at/2008.07/order/rating desc/limit/3

To pass tags with (+/-) "+" need to be encoded with "%2b"
+apple,-banana

http://www.wikidot.com/blog/tags/%2bapple,-banana

You can create the URLs manually or within ListPages itself. Some modules also generate compatible URLs.

Editor's note: list of modules that produce compatible URLs should be documented here.

ページ内の複数モジュール

Since some of the arguments can be passed in the URL of the request there might be conflict when more than one ListPages module is present in the page. One most likely conflict can occur when both modules use pagination — clicking "next" on one of them would also affect the other.

To prevent such conflicts use the urlAttrPrefix argument. This prepends a text (unique for each of the modules) to the argument names in the URL. So the …/created_at/2008.7 would become …/prefix_created_at/2008.07. If you can set unique prefixes for each of the ListPages instances you would avoid any conflicts.

推奨されない機能

これらの引数と変数は引き続き使用できますが、お勧めできません。可能であれば最新の代替品を使用してください。将来、非推奨の機能が削除される可能性があります。

非推奨 代替品
skipCurrent="yes" range="others"
categories= category=
tag= tags=
tagTarget="pagename" %%tags_linked|/pagename/tag/%%
date= created_at=
order="dateCreatedAsc" order="created_at"
order="dateCreatedDesc" order="created_at desc"
order="dateEditedAsc" order="updated_at"
order="dateEditedDesc" order="updated_at desc"
order="titleAsc" order="title"
order="titleDesc" order="title desc"
order="ratingAsc" order="rating"
order="ratingDesc" order="rating desc"
order="pageLengthAsc" order="size"
order="pageLengthDesc" order="size desc"
rssTitle= rss=
%%linked_title%% %%title_linked%%
%%page_unix_name%% %%fullname%%
%%full_page_name%% %%fullname%%
%%page_name%% %%name%%
%%author%% %%created_by%%
%%author_edited%% %%updated_by%%
%%user_edited %%updated_by%%
%%date%% %%created_at%%
%%date_edited%% %%updated_at%%
%%description%% %%summary%%
%%short%% %%summary%%
%%text%% %%content%%
%%long%% %%content%%
%%body%% %%content%%

ListPagesは、モジュール本体を指定せず、[[/module]]も指定しない「デフォルトフォーマット」をサポートしています。この機能は非推奨であるため、使用しないでください。

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License
Click here to edit contents of this page.
Click here to toggle editing of individual sections of the page (if possible). Watch headings for an "edit" link when available.
Append content without editing the whole page source.
Check out how this page has evolved in the past.
If you want to discuss contents of this page - this is the easiest way to do it.
View and manage file attachments for this page.
A few useful tools to manage this Site.
Change the name (also URL address, possibly the category) of the page.
View wiki source for this page without editing.
View/set parent page (used for creating breadcrumbs and structured layout).
Notify administrators if there is objectionable content in this page.
Something does not work as expected? Find out what you can do.
General Wikidot.com documentation and help section.
Wikidot.com Terms of Service - what you can, what you should not etc.
Wikidot.com Privacy Policy.

AltStyle によって変換されたページ (->オリジナル) /