-
Notifications
You must be signed in to change notification settings - Fork 21
{exp:stash:get_list}
Retrieve a list and apply a custom order, sort, limit and offset. Lists can be paginated, split by fractions, or filtered by regular expressions.
{exp:stash:get_list name="product_entries" orderby="item_title" sort="asc" limit="10"}
<h2 class="{switch="one|two|three"}">{item_title}</h2>
<p>{item_teaser}</p>
<p>This is item {count} of {total_results} rows curently being displayed.</p>
<p>This is item {absolute_count} of {absolute_results} rows saved in this list</p>
{/exp:stash:get_list}
Accepts the same parameters as {exp:stash:get}, and the following:
The name of the column to order the list by, e.g. orderby="title"
Shuffle the list.
Shuffle one or more named columns of the list, e.g. orderby="random:title,image"
The sort order, either ascending (asc) or descending (desc) (optional, default is "asc").
The data type of the column you are ordering by, either 'string' or 'integer' (optional, default is "string").
Offset from 0. Pass a fraction, e.g. 1/3 to offset from a fraction of the absolute count
(default is 0).
Limit the number of rows returned. Pass a fraction, e.g. 1/3 to limit to a fraction of the absolute count. (optional).
Match a column in the list against a regular expression. Only rows in the list that match will be returned.
Column to match against. If against is not specified or is not a valid list column, match="#regex#" will be applied to the whole string return by get_list.
Remove duplicate list rows (optional, default is 'no')
When in the parse order of your EE template do you want the variable to be retrieved (default is 'inline')
Retrieve the variable in the natural parse order of the template (like a standard EE tag)
Retrieve the variable at the end of template parsing after other tags and variables have been parsed
Determines the order in which the variable is retrieved when using process="end". Lower numbers are parsed first (default="1")
This parameter is for use with list pagination and determines where the pagination code will appear.
The navigation text and links will appear above your list.
The navigation text and links will appear below your list.
The navigation text and links will appear both above and below your list.
Override the normal paginati on link locations and point instead to the explicitly stated uri. This parameter is essential when using query string style pagination with pagination_param=""
A parameter containing the page offset value. If set to a value, query-string style pagination links are created (e.g, ?page=P10) instead of the default segment style links (/P10); this can be useful when working with Structure / Page module uris.
Prefix for common iteration variables such as {count}, {total:results}, {switch} and {if no_results}. Useful when outputting a list inside another tag.
-
{count}- The "count" out of the row being displayed. If five rows are being displayed, then for the fourth row the {count} variable would have a value of "4". -
{total_results}- the total number of rows in the list currently being displayed -
{absolute_count}- The absolute "count" of the current row being displayed by the tag, regardless of limit / offset. -
{absolute_results}- the absolute total number of rows in the list, regardless of limit / offset. -
{switch="one|two|three"}- this variable permits you to rotate through any number of values as the list rows are displayed. The first row will use "one", the second will use "two", the third "option_three", the fourth "option_one", and so on.
Pagination variables use the same syntax as Channel Entry pagination.
The {paginate}{/paginate} tag pair can optionally be prefixed, if using prefix=""
{exp:stash:get_list
name="recent_discussion_topics"
parse_tags="yes"
parse_conditionals="yes"
process="end"
prefix="my_prefix"
paginate="bottom"
}
{if my_prefix:count == 1}
<table class="data" cellpadding="0" cellspacing="0">
<thead>
<tr>
<th class="left first">Title</th>
<th>Last post</th>
<th>Date</th>
</tr>
</thead>
<tbody>
{/if}
<tr class="{my_prefix:switch='|rowAlt'}">
<td class="left first"><a href="{topic_url}"><strong>{topic_title}</strong></a></td>
<td><a href="{last_author_url}">{last_author_name}</a></td>
<td>{last_post_date}</td>
</tr>
{if my_prefix:count == my_prefix:total_results}
</tbody>
</table>
<p><a href="/forum/viewforum/{stash:forum}">View all topics in this forum »</a></p>
{/if}
{if my_prefix:no_results}
<p>No forum topics yet. <a href="/forum/newtopic/{stash:forum}">Start a discussion »</a></p>
{/if}
{my_prefix:paginate}
{pagination_links}
<ul>
{first_page}
<li><a href="{pagination_url}" class="page-first">First Page</a></li>
{/first_page}
{previous_page}
<li><a href="{pagination_url}" class="page-previous">Previous Page</a></li>
{/previous_page}
{page}
<li><a href="{pagination_url}" class="page-{pagination_page_number} {if current_page}active{/if}">{pagination_page_number}</a></li>
{/page}
{next_page}
<li><a href="{pagination_url}" class="page-next">Next Page</a></li>
{/next_page}
{last_page}
<li><a href="{pagination_url}" class="page-last">Last Page</a></li>
{/last_page}
</ul>
{/pagination_links}
{/my_prefix:paginate}
{/exp:stash:get_list}
{!-- split into three --}
<ul class="col-a">
{exp:stash:get_list name="my_list" orderby="title" sort="asc" limit="1/3"}
<li><a href="#" data-marker="{url_title}">{title}</a></li>
{/exp:stash:get_list}
</ul>
<ul class="col-b">
{exp:stash:get_list name="my_list" orderby="title" sort="asc" offset="1/3" limit="1/3"}
<li><a href="#" data-marker="{url_title}">{title}</a></li>
{/exp:stash:get_list}
</ul>
<ul class="modal-c">
{exp:stash:get_list name="my_list" orderby="title" sort="asc" offset="2/3"}
<li><a href="#" data-marker="{url_title}">{title}</a></li>
{/exp:stash:get_list}
</ul>
{!-- split into two --}
<ul class="col-a">
{exp:stash:get_list name="my_list" orderby="title" sort="asc" limit="1/2"}
<li><a href="#" data-marker="{url_title}">{title}</a></li>
{/exp:stash:get_list}
</ul>
<ul class="col-b">
{exp:stash:get_list name="my_list" orderby="title" sort="asc" offset="1/2"}
<li><a href="#" data-marker="{url_title}">{title}</a></li>
{/exp:stash:get_list}
</ul>
Getting started
Using Stash
Using Mustash
- Mustash
- Installing Mustash
- Managing variables
- Managing bundles
- Cache-breaking rules
- Mustash plugins
- Mustash Varnish plugin
- Mustash plugin development
- Mustash API
Template design patterns
Tag reference
- {exp:stash:set}
- {exp:stash:get}
- {exp:stash:block}
- {exp:stash:set_value}
- {exp:stash:append}
- {exp:stash:append_value}
- {exp:stash:prepend}
- {exp:stash:prepend_value}
- {exp:stash:copy}
- {exp:stash:context}
- {exp:stash:is_empty}
- {exp:stash:not_empty}
- {exp:stash:set_list}
- {exp:stash:get_list}
- {exp:stash:append_list}
- {exp:stash:prepend_list}
- {exp:stash:split_list}
- {exp:stash:join_lists}
- {exp:stash:list_count}
- {exp:stash:unset}
- {exp:stash:flush_cache}
- {exp:stash:bundle}
- {stash:embed}
- {exp:stash:extend}
- {exp:stash:parse}
- {exp:stash:cache}
- {exp:stash:static}
- {exp:stash:finish}
- {exp:stash:not_found}
- Short tag syntax
- Using Stash methods in your own add-ons