USA - Californien - 17 mile drive - Monterey - Visit California (14).jpg

Cookiepolitik

 anchor

@inherits Umbraco.Web.Mvc.UmbracoTemplatePage @using Archetype.Models @{ Layout = "Master.cshtml"; List<KeyValuePair<string,string>> faqs = GetFAQsModel(); } @if(faqs != null && faqs.Count > 0) {

See our FAQs

@foreach(KeyValuePair<string,string> faq in faqs) {

@faq.Key

@Html.Raw(faq.Value)
}

} @* To get this to work, you need to define it in the master template under the last script tag like this: @RenderSection("ScriptsBottom", false) *@ @section ScriptsBottom{

} @* I've used a function in the template here so it is easier to take it out and put it into a separate helper class *@ @functions { public List<KeyValuePair<string, string>> GetFAQsModel() { List<KeyValuePair<string, string>> model = null; if(Model.Content.HasProperty("fAQList")) { model = new List<KeyValuePair<string, string>>(); ArchetypeModel faqList = Model.Content.GetPropertyValue("fAQList"); foreach(ArchetypeFieldsetModel faq in faqList) { string question = faq.GetValue("question"); string answer = faq.GetValue("answer"); model.Add(new KeyValuePair<string, string>(question, answer)); } } return model; } }

Læs mere