タグ付けされた製品を表示するオプション付きのリンクとしてタグを作成する必要がある場合は、../search.aspx?tag=tagname という名前の新しいページを作成し、そのタグにある製品を検索できます。コードは次のとおりです。 :
@inherits umbraco.MacroEngines.DynamicNodeContext
@using System.Text
@using umbraco.MacroEngines
@using umbraco.cms.businesslogic.Tags
@{
string searchFor = Request["tags"];
if(string.IsNullOrEmpty(searchFor))
{
@* No tags were specified *@
<p>Please specify a tag to search for</p>
return;
}
// this is to search from the tags added and then get all the nodes
var matchingNodes = Tag.GetNodesWithTags(searchFor).ToList();
string tagsText = searchFor.Split(',').Count() > 1 ? "tags" : "tag";
if (matchingNodes.Count < 1)
{
@* No results were found for the specified tags *@
<p>No tagged items were found that matched the @tagsText: @searchFor</p>
return;
}
@* Some results were found for the specified tags *@
<p><strong>@matchingNodes.Count</strong> products were found that matched the @tagsText: "@searchFor"</p>
<ul>
// go through the code and create URL for that product
@foreach (var node in matchingNodes)
{
dynamic dn = new DynamicNode(node.Id);
<li><a href="@dn.Url">@dn.Name</a></li>
}
</ul>
}
私がチェックしたので、この記事を参照できます ここをクリックすると、半分下にこのコードが表示されます
さらに説明が必要な場合はお知らせください。コードのブリーフィングを取得できるように、これにコメントしました。