我需要获取所有条目的年份列表,以便在下拉列表中使用.基本上我需要按年份分组输入日期并在列表中输出分组年份.
像这样的东西:https://dzwonsemrish7.cloudfront.net/items/2G161x0v1U0d2U0k133a/2012-10-23_19-50-41.jpeg?v = 9c5b44e8
Ann*_*irl 12
这个EE1或EE2插件可以满足您的需求:http://devot-ee.com/add-ons/yearlist
{exp:yearlist channel="yourchannel"}
<a href="{path=archive}/{year}">{year}</a>
{/exp:yearlist}
Run Code Online (Sandbox Code Playgroud)
然后在您的模板中使用year =""参数限制条目:
{exp:channel:entries channel="news" year="{segment_2}"}
<h1>{title}</h1>
{body}
{/exp:channel:entries}
Run Code Online (Sandbox Code Playgroud)
使用这个附加组件http://devot-ee.com/add-ons/yearlist你可以这样做:
像下面这样设置您的下拉菜单:
<form name="yourform" action="">
<select id="yourselect" name="yourselect">
{exp:yearlist channel="yourchannel"}
<option value="{path=archive}/{year}">{year}</option>
{/exp:yearlist}
</select>
</form>
Run Code Online (Sandbox Code Playgroud)
在您的目标网页上,您可以执行以下操作,根据年份显示您的参赛作品:
{exp:channel:entries channel="news" year="{segment_2}"}
<h1>{title}</h1>
{body}
{/exp:channel:entries}
Run Code Online (Sandbox Code Playgroud)
并使用一些jQuery重定向到您的年份页面:
<script type="text/javascript">
$('#yourselect').change(function() {
window.location = $(this).val();
});
</script>
Run Code Online (Sandbox Code Playgroud)
如果你想通过javascript代替jQuery checkout 这篇文章
| 归档时间: |
|
| 查看次数: |
1150 次 |
| 最近记录: |