Not having much success with rendering tags in my template.
The (very simple) template looks something like this:
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
Layout = "MasterTemplate.cshtml";
}
@{
var topics = Model.Content.GetPropertyValue<string>("pageTopics");
<p>This is a page about @topics</p>
}
@if(Model.Content.GetPropertyValue<IEnumerable<string>>("pageTopics") !=null){
<ul>
@foreach(var tag in Model.Content.GetPropertyValue<IEnumerable<string>>("pageTopics")){
<li>@tag</li>
}
</ul>
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
Layout = "MasterTemplate.cshtml";
var topics = Model.Content.GetPropertyValue<string[]>("pageTopics");
}
<p>This is a page about @string.Join(", ", topics)</p>
If you insist on the tags being uppercase, i would to the following:
var topics = Model.Content.GetPropertyValue<string[]>("pageTopics").Select(x=> x.ToUpperInvariant());
tags don't render
Not having much success with rendering tags in my template.
The (very simple) template looks something like this:
I hope to render something like
This page is about TESTING, UMBRACO, CLOUD, TAGS
But all I get is
This page is about System.String[]
What am I missing?
Hi Jesper,
Can you please give this a go.
Also make sure that your property is called pageTopics and the property is on the page that you are render in the browser.
Hope this helps,
/Dennis
Hi Dennis
When I insert this code, preview (Umbraco Canvas Designer) displays Server Error in '/' Application. Runtime Error and some more text in yellow boxes.
I have triple (actually more) checked. The property name is pageTopics, and my test page contains tags.
Tags are stored as JSON, not CSV.
I am running Umbraco Cloud.
Can you try:
}
Hi Jesper,
Here is how you should do it:
If you insist on the tags being uppercase, i would to the following:
Hi all
Suggestions from Louis and Rasmus both worked. You just resqued my whole week. Thanks.
Jesper
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.