Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Graham Thomson 56 posts 136 karma points
    Jan 05, 2017 @ 17:13
    Graham Thomson
    0

    Outputting tabbed content

    Hi

    I am trying to render out some some tabbed content.

        @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
         //This retrieves the value from property. Nested content is always an IEnumerable of IPublishedContent (from my experience)
         var tabs = Model.Content.GetPropertyValue<IEnumerable<IPublishedContent>>("tabs");
    
    }
    <ul class="tab">
        <li><a href="javascript:void(0)" class="tablinks" onclick="openCity(event, 'London')">London</a></li>
    </ul>
    
    @foreach(var panel in tabs )
    {
        //Next we loop through each panel in the accordion
            <div id="@panel.GetPropertyValue("title")" class="tabcontent">
      <h3>@panel.GetPropertyValue("title")</h3>
       <p>@panel.GetPropertyValue("content")</p>
                </div>
            }
    

    Would I use a separate foreach loop to render each of the

  • tags that build the tabs? And also, would this be a case of replacing London with @panel.GetPropertyValue("title") both for the value and the ID?

    I was trying it earlier but only resulted in crashing my Visual Studio!

    Thanks Graham

Copy Link
Please Sign in or register to post replies

Write your reply to:

Draft