使用方法/datatable2:修订间差异
来自康健生活
| 第11行: | 第11行: | ||
With '''<datatable2>''' tags, you display tabular data and optionally store it for use on other pages (or elsewhere on the same page). As a simple example, the following wikitext: | With '''<datatable2>''' tags, you display tabular data and optionally store it for use on other pages (or elsewhere on the same page). As a simple example, the following wikitext: | ||
{{leftrightflex| | |||
<pre> | <pre> | ||
<datatable2 table="demo table" class="wikitable"> | <datatable2 table="demo table" class="wikitable"> | ||
| 第19行: | 第20行: | ||
! Type | ! Type | ||
</head> | </head> | ||
FULLPAGENAME|interesting page|extension description | |||
MW:Manual:Contents!Manua]|very interesting page|manual page | |||
</datatable2> | </datatable2> | ||
</pre> | </pre> | ||
| | |||
<datatable2 table="demo table" class="wikitable"> | |||
<head> | |||
|- | |- | ||
! Page | ! Page | ||
! Rating | ! Rating | ||
! Type | ! Type | ||
</head> | |||
FULLPAGENAME|interesting page|extension description | |||
| interesting page | MW:Manual:Contents!Manua]|very interesting page|manual page | ||
| extension description | </datatable2> | ||
}} | |||
| very interesting page | |||
| manual page | |||
The <code>table</code> argument tells the extension to store the data for later use in a logical table called 'demo table'; this has no influence on what is displayed here. A <code><head></code> tag is provided, which implies that the whole thing is wrapped into a wikitable, with the CSS class given in the <code>class</code> argument. Note the use of the <code><nowiki>{{!}}</nowiki></code> template in the data, which is necessary because the pipe character is used as a field separator. | The <code>table</code> argument tells the extension to store the data for later use in a logical table called 'demo table'; this has no influence on what is displayed here. A <code><head></code> tag is provided, which implies that the whole thing is wrapped into a wikitable, with the CSS class given in the <code>class</code> argument. Note the use of the <code><nowiki>{{!}}</nowiki></code> template in the data, which is necessary because the pipe character is used as a field separator. | ||
| 第45行: | 第41行: | ||
We can demonstrate some more features with a similar example: | We can demonstrate some more features with a similar example: | ||
{{leftrightflex| | |||
<pre> | <pre> | ||
<datatable2 table="another demo" | <datatable2 table="another demo" | ||
| 第54行: | 第51行: | ||
<!-- one-line comments are possible --> | <!-- one-line comments are possible --> | ||
Extension:DataTable2;interesting page;extension description | Extension:DataTable2;interesting page;extension description | ||
MW:Manual:Contents|Manual;very interesting page;manual page | |||
</datatable2> | </datatable2> | ||
</pre> | </pre> | ||
| | |||
<datatable2 table="another demo" | |||
columns="page|rating|type" | |||
fs=";"> | |||
<template> | |||
'''page''': ''rating'' - type | |||
</template> | |||
<!-- one-line comments are possible --> | |||
Extension:DataTable2;interesting page;extension description | |||
MW:Manual:Contents|Manual;very interesting page;manual page | |||
</datatable2> | |||
}} | |||
This will display | This will display | ||
| 第62行: | 第72行: | ||
'''Extension:DataTable2''': ''interesting page'' - extension description | '''Extension:DataTable2''': ''interesting page'' - extension description | ||
''' | '''MW:Manual:Contents|Manual''': ''very interesting page'' - manual page | ||
This time, each record is formatted using template code provided in a <code><template></code> tag, the columns have names which can be used in the template code, and the result is not automatically wrapped into a wikitable. You can also combine <code><head></code> and <code><template></code>, in which case they must be given in this order. | This time, each record is formatted using template code provided in a <code><template></code> tag, the columns have names which can be used in the template code, and the result is not automatically wrapped into a wikitable. You can also combine <code><head></code> and <code><template></code>, in which case they must be given in this order. | ||