TXP:article
概述
<txp:article />
最基础的文章标签(article)即可充当单个标签,也可用于容器标签,可以根据设置属性用于输出一篇或多篇文章。
没有特别为标签指定属性时,将使用默认属性值。
此标签也可充当容器标签使用,须注意的是当作为容器标签打开的同时需要使用结尾关闭,如下所示:
<txp:article>
...contained statements...
</txp:article>
This is equivalent to putting the contained statements into a form named “my_form” and using <txp:article form="my_form" />
.
The tag is context-sensitive, which means it will grab articles from the currently viewed section/category/author, etc.
When used on the front page, article’s context will include articles from all Sections set to display “On front page”.
See this comparison of how article and article_custom differ.
标签属性
该标签允许使用以下属性 (区分大小写):
属性 | 值 | 描述 |
---|---|---|
customfieldname | value | Restrict to articles with specified value for specified custom field name. Replace “customfieldname” with the name of the custom field. |
keywords | keyword(s) | Restrict to articles with specified keyword(s). |
status | status | Restrict to articles with the specified status. Values: live or sticky Default: live. |
time | time | Restrict to articles posted within specified timeframe. Values: past, future, or any (both past and future). Default: past. |
sort | sort value(s) | How to sort resulting list. Values: ID (article id#)、AuthorID (author name)、LastMod (date last modified)、LastModID (author name of last modification)、Posted (date posted)、Expires (expiry date)、Title、Category1、Category2、comments_count、Status、Section、Keywords、Image (article image id#)、url_title、custom_1 through custom_10(From 4.2.0 on: custom_n)、rand() (random). Each field in the textpattern database table can be used as a sort key. When viewing a search results list,score (how well the search terms match the article)is available as an additional value. Default: Posted desc (score desc for search results) |
offset | integer | The number of articles to skip. Default: 0. |
limit | integer | The number of articles to display. Default: 10. |
pageby | integer | The number of articles to jump forward or back when an older or newer link is clicked. Allows you to call the article tag several times on a page without messing up older/newer links. Default: value matches the value assigned to limit. |
pgonly | boolean | Do the article count, but do no display anything. Used when you want to show a search result count, or article navigation tags before the list of articles. Just Make sure that, other than pgonly, both article tags are identical (form-related attributes are the exception, they do not need to be assigned). Default: 0 (no). |
allowoverride | boolean | Whether to use override forms for the generated article list. Default: 1 (yes). |
searchsticky | boolean | When outputting search results, include articles with status “sticky”. Default: 0 (no). |
form | form name | Use specified form. Default: default. |
listform | form name | Use specified form when page is displaying an article list. |
searchform | form name | The form to be used for your customized search results output. Default: search_results. |
样式属性
These attributes, which affect presentation, are shared by many tags. Note that default values can vary among tags.
label=“text”
Label prepended to item.
Default: unset (but see label cross-reference for exceptions).
labeltag=“tag”
(X)HTML tag (without brackets) to wrap around label.
Default: unset.
break=“tag text”
(X)HTML tag (without brackets) or string to separate list items.
Default: br (but see break cross-reference for exceptions).
wraptag=“tag”
(X)HTML tag (without brackets) to wrap around the list.
Default: unset (but see wraptag cross-reference for exceptions).
class=“class name”
(X)HTML class attribute to apply to the wraptag.
Default: tag name or unset (see class cross-reference)