我試圖在博客列表上創建某種排序功能。我想輸出前5個項目,然後創建更多按鈕,並列出要從中排序的其他類別。循環前5項,然後創建ul並列出其餘的
我有了這個迄今:
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
var blogitems = Umbraco.Content("1102").Children.Where("Visible");
<ul>
@foreach(var blog in blogitems) {
var tagsplit = blog.blogCats.Split(',');
var usedTags=new List<string>();
foreach(var tag in tagsplit) {
//Output the first 5 items, then create a new <ul> and then list the rest
if(!usedTags.Contains(tag)){
<li>
<a href="/blog/[email protected]">@tag</a>
</li>
}
usedTags.Add(tag);
}
}
</ul>
}
我希望這是有道理的?
到底想要的輸出應該是這個樣子:
<ul>
<li>
<a href="#" class="sort-item">Cat1</a>
</li>
<li>
<a href="#" class="sort-item">Cat2</a>
</li>
<li>
<a href="#" class="sort-item">Cat3</a>
</li>
<li>
<a href="#" class="sort-item">Cat4</a>
</li>
<li>
<a href="#" class="sort-item">Cat5</a>
</li>
<li>
<a href="#" class="sort-item dropdown-toggle" data-toggle="dropdown">More <b class="caret"></b></a>
<ul class="dropdown-menu">
<li>
<a href="portfolio-1-col.html">Cat6</a>
</li>
<li>
<a href="portfolio-2-col.html">Cat7</a>
</li>
<li>
<a href="portfolio-3-col.html">Cat8</a>
</li>
</ul>
</li>
</ul>
'拿(5)'和「跳過(5)」? – MarcinJuraszek 2015-01-21 09:17:20