Skip to content

Instantly share code, notes, and snippets.

@biapar
Forked from amogram/UmbracoTags.cshtml
Created May 9, 2018 12:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save biapar/50c6364e30c512ddfd9dd67d108dee3c to your computer and use it in GitHub Desktop.
Save biapar/50c6364e30c512ddfd9dd67d108dee3c to your computer and use it in GitHub Desktop.
Using Umbraco Tags in a view
@if (@Model.Content.GetPropertyValue("tags") != null)
{
var tags = Model.Content.GetPropertyValue("tags").TryConvertTo<string>();
string[] tagArray = { };
if (tags.Success)
{
tagArray = tags.Result.Split(',');
}
if (tagArray.Any())
{
var count = 1;
@Html.Raw("<h3>Tags</h3>");
@Html.Raw("<p>");
foreach (var tag in tagArray)
{
<a href="../../posts?search=@tag" class="btn btn-blue">@tag</a>
@*if (count != tagArray.Length)
{
@Html.Raw(",");
}*@
count++;
}
@Html.Raw("</p>");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment