mrnebbi/craft-query-strings
Composer 安装命令:
composer require mrnebbi/craft-query-strings
包简介
Add your query strings back into your Craft CMS pagination. Pull an array of all query strings, including duplicate keys
README 文档
README
A Craft CMS plugin to provide twig filters and functions to help with query string management. This is especially helpful for adding query strings back to pagination.
preserveQueryStrings
The Preserve Query String filter allows you to add |preserveQueryStrings to any URL output in twig, and it will keep the query strings as they should appear in the URL.
E.g.
{% if pageInfo.prevUrl %}<a href="{{ pageInfo.prevUrl|preserveQueryStrings }}">Previous Page</a>{% endif %}
{% if pageInfo.nextUrl %}<a href="{{ pageInfo.nextUrl|preserveQueryStrings }}">Next Page</a>{% endif %}
getQueryStrings
Pull an array of query strings from Craft. This gets around the problem of duplicated query string keys being lost, turning them into an array you can loop through.
An array will be returned with objects. Use .key and .value.
Return all URL queries
{% for query in getQueryStrings() %}
{{ query.key }} - {{ query.value }}
{% endfor %}
Return only URL queries that match a key
{% for query in getQueryStrings('lookForKey') %}
{{ query.key }} - {{ query.value }}
{% endfor %}
getQueryFormFields
Sometimes you want to use query fields in a form, to preserve these values you can use the following in your templates.
{{ getQueryFormFields() }}
which is shorthand/equivalent to:
{% for query in getQueryStrings() %}
<input type="hidden" name="{{ query.key }}" value="{{ query.value }}">
{% endfor %}
统计信息
- 总下载量: 11
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2018-09-14
