article custom
From Textbook
<txp:article_custom />
The article_custom tag is a single or a container tag that provides a variety of custom options for sorting, selecting, and displaying articles (the tag will be replaced with one or more articles).
If used as a container, it must be specified as an opening and closing pair of tags, like this:
<txp:article_custom> ...contained statements... </txp:article_custom>
This is equivalent to putting the contained statements into a form named "my_form" and using <txp:article_custom form="my_form" />.
Unlike the article tag, article_custom will always return an article list and is not context-sensitive. This means while the article tag can only see posts within the currently viewed section/category/author and so forth, article_custom can see all posts from all sections, categories and authors unless you restrict it via attributes (see below), thus context-sensitive navigation tags, such as older and newer, will not work.
A comparison of how article and article_custom differ.
Related Info: Customizing txp:recent_articles.
Contents |
Attributes
Tag will accept the following attributes (case-sensitive):
- id="article ID"
- Display the specific article or list of articles (each ID separated by a comma).
- IMPORTANT: When a list is supplied, this does not imply a sort order.
- Default: unset.
- customfieldname="value"
- Restrict to articles with specified value for specified custom field name. Replace "customfieldname" with the name of the custom field.
- Default: unset.
- section="section name"
- Restrict to articles from specified section(s).
- Value: (comma separated list of) section name(s).
- Default: unset, retrieves from all sections.
- category="category name"
- Restrict to articles from specified category/ies. Note: the category names may be different to the Title you typed when you created the category, as the names are sanitized for URL use. Check the Categories tab to ensure you are using the correct names.
- Value: (comma separated list of) category name(s).
- Default: unset, retrieves from all categories.
- keywords="keyword(s)"
- Restrict to articles with specified keyword(s).
- Default: unset.
- excerpted="y"
- Restrict to articles with/without an excerpt.
- Value:
y(yes, return only those containing an excerpt). - Default: unset (no, return all).
- status="status"
- Restrict to articles with the specified status.
- Values:
liveorsticky. - Default:
live. - time="time"
- Restrict to articles posted within specified timeframe.
- Values:
past,future, orany(bothpastandfuture). - Default:
past. - month="yyyy"/"yyyy-mm"/"yyyy-mm-dd"
- Restrict to articles posted within the specified year/month/day.
- Default: unset.
- author="author name"
- Restrict to articles by specified author(s).
- Value: (comma separated list of) author name(s).
- Default: unset, retrieves from all authors.
- sort="sort value(s)"
- How to sort resulting list.
- Values:
ID(article id#)AuthorID(author)LastMod(date last modified)LastModID(author of last modification)Posted(date posted)Expires(expiry date)TitleCategory1Category2comments_countStatusSectionKeywordsImage(article image id#)url_titlecustom_1throughcustom_10
(From 4.2.0 on:custom_n)rand()(random).- Each field in the "textpattern"-table can be used as a sort key.
- Default:
Posted desc. - offset="integer"
- The number of articles to skip.
- Default:
0. - limit="integer"
- The number of articles to display.
- Default:
10. - allowoverride="boolean"
- Whether to use override forms for the generated article list.
- Values:
0(no) or1(yes). - Default:
0. - form="form name"
- Use specified form.
- Default:
default. - wraptag="tag text"
- The (X)HTML tag, without brackets, to wrap around the article list.
- Default: unset.
- class="class name"
- The (X)HTML class name to apply to the wraptag.
- Default: unset.
- break="tag text"
- The (X)HTML tag (without brackets) or string to separate list items.
- Default: unset.
Examples
Example 1: List articles published in specified month
<txp:article_custom form="month_list" sort="Section asc" month="2004-10" />
Example 2: Select by keyword
<txp:article_custom sort="Posted desc" keywords="One" />
Example 3: Select by author
<txp:article_custom form="author_list" author="Parkling" />
the author_list article form might go thus.
<p><txp:permlink><txp:title /></txp:permlink></p>
Other tags used: permlink, title
Example 3a: Container tag
The following is exactly equivalent to Example 3:
<txp:article_custom author="Parkling"> <p><txp:permlink><txp:title /></txp:permlink></p> </txp:article_custom>
Example 4: Combined with custom fields
This code will display articles that have a custom field named "colour" with a value "red":
<txp:article_custom colour="red" />
Example 5: Article sorting
<txp:article_custom sort="AuthorID asc, Posted asc" />
- What this does...
- uses the
sortattribute to define values by which to order article output. In this case two values are declared. AuthorID asc first orders articles alphabetically by author names, then Posted desc orders them by date published ("desc" meaning newest to oldest). - Why you might do it...
- Sorting is a powerful way to group articles (e.g., by author), and/or give priority to articles most recently published (typically better for your web site visitors).
Genealogy
Version 4.0.7
- Can be used as a container tag.
-
idcan take a comma-separated list of IDs. -
wraptagandbreakattributes added.
Version 4.0.6
- support added for comma separated lists for section, category and author attributes
Version 4.0.4
- listform deprecated (it never made a difference to article_custom anyway)
- sort added (replaces sortby and sortdir)
- sortby and sortdir deprecated




