Help:Filtered format/zh-hans

From semantic-mediawiki.org
< Help:Filtered format(Redirected from Help:Filtered format/zh-hans)
Filtered formatHelp:Filtered format/zh-hans
Filtered format/zh-hans
用于将查询结果显示为可切换型视图(switchable views),并提供筛选功能
更多信息
提供者: Semantic Result Formats(语义结果格式)/zh-hans
添加版本: 1.7.1
移除版本: 依然支持
需求:
格式名称: filtered
启用?表明安装相应扩展时是否默认启用该结果格式。 no
作者: Stephan Gambke
分类: misc
目录

此结果格式用于将查询结果显示为可切换型视图(switchable views),并提供客户端筛选功能(基于JavaScript)。

此结果格式计划最终取代exhibit格式。当前,仅提供有列表视图list。目前,还不能在不同的视图之间切换。 另外,当前只有取值筛选器value可用。

解析器函数#ask调用的语法如下(这只是一个语法示例。对于当前可用的功能特性,请参见各个类的文档):

{{#ask:[[SomeCondition]]

|? SomePrintout |+filter=value, someFutureFilter |+value filter switches=and or, disable, select all, select none |+someFutureFilter filter option=someOptionValue
|? SomeOtherPrintout |+filter=value, someOtherFutureFilter |+someOtherFutureFilter filter option=someOptionValue

|format=filtered
|views=list, someFutureView, someOtherFutureView

|list view type=list
|list view template=ListItem

|someFutureView view option=someOptionValue

|someOtherFutureView view option=someOptionValue

}}

筛选器[edit]

取值[edit]

  • +value filter switches=and or

Display and AND/OR switch. When OR is checked, clicking >1 filter value will show results containing value1 OR value2 etc. If AND is selected clicking >1 filter value will show results containing value1 AND value2 etc.

  • +value filter collapsible=collapsed,uncollapsed

Allows the filter to be collapsed. You can specify whether to default to collapsed or uncollapsed

  • +value filter height=xxxpx

Allows you to specify the height of each filter. If the number of values exceeds the specified height, you then get a scrollbar. This is especially useful for filters with large sets of values.

  • +filter=distance

Provides a distance slider for the result set based upon a geographic coordinate type property. Additional parameters: |+distance filter origin= e.g. start point or lat/long geographic coordinate |+distance filter unit= e.g. km |+distance filter initial value=x (does not need unit) e.g 100

It should be noted that if Google geocoding is used, this funtionality will result in a lot of API calls. Google has set a limit for the number of free geocodes per day of 2500. It is best to work using lat/long as this currently has no limit.

视图[edit]

列表[edit]

  • list view template=<template>

Allows you to specify a template to format the results. This is the same as format=template in standard SMW queries See here for details.

示例查询[edit]

{{#ask:
[[Category:People]]
[[Name::+]]
|?Job Title|+filter=value|+value filter height=150px|+value filter collapsible=collapsed
|?Biog
|?City|+filter=value|+value filter height=200px|+value filter collapsible=uncollapsed
|?Country|+filter=value |+value filter switches=and or|+value filter collapsible=uncollapsed
|format=filtered
|views=list
|list view type=list
}}

This will show a result set with Job Title, City and Country properties set as filters. Job Title filter will start collapsed and will have a scrollbar. City will start uncollapsed and will have a scrollbar. Country will have the AND/OR selector switched on and no scrollbar.

示例距离查询[edit]

{{#ask:
[[Category:People]]
[[Name::+]]
|?Job Title|+filter=value|+value filter height=150px|+value filter collapsible=collapsed
|?Biog
|?City|+filter=value|+value filter height=200px|+value filter collapsible=uncollapsed
|?Coordinates=Distance|+filter=distance|+distance filter origin=London, UK
|+distance filter unit=miles
|+distance filter initial value=5
|format=filtered
|views=list
|list view type=list
}}

This will show a result set with Job Title, City and Country properties set as filters. There will be a distance slider visible that allows you to filter the results based on the distance from London, UK. This assumes each page has a geographic coordinate property set for each person.

示例CSS[edit]

可为筛选器设定皮肤。 默认CSS包含在此扩展的皮肤文件夹当中。 默认CSS将在下方带有结果集的页面之中,采取水平横跨的方式呈现筛选器。

如下CSS示例在呈现时将把筛选器堆放在左侧,而将结果集放在右侧:

.filtered-filters .filtered-value { 
        overflow: visible;
        border: 1px solid #aaa;
        padding: 2px;
        margin: 0.5em;
        margin-bottom:1em;
        width:200px;
}

如下是关于折叠控件的CSS示例:

.filtered-filters .filtered-value
.filtered-value-show
{
position: relative;
top: -1em;
right: 0;
float: left;
width: 1.5em;
padding: 0 0.1em;
margin: 0;
cursor: pointer;
text-align: center;
font-size: 90%;
}
.filtered-filters .filtered-value
.filtered-value-hide
{
position: relative;
top: -1em;
right: 0;
float: left;
width: 1.5em;
padding: 0 0.1em;
margin: 0;
background-color: #EAF5E9;
cursor: pointer;
text-align: center;
font-size: 90%;
}

滚动条所需的CSS示例:

.filtered-filters .filtered-value .filtered-value-scrollable {
	overflow: auto;
}

启用[edit]

默认情况下,维基站点上并不启用此结果格式。 要启用此格式,必须在文件当中,在包含Semantic Result Formats(语义结果格式) 扩展的下方添加如下一行:

$srfgFormats[] = 'filtered';

赞助方[edit]

此扩展由Prescient Software赞助。



本文档页面适用于SMW从1.7.1版到最新版本的所有版本。
     

Help:Filtered format zh-hans 1.7.1