Copied to clipboard

Flag this post as spam?

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


  • Mark Seymour 1 post 50 karma points
    Jul 31, 2014 @ 17:17
    Mark Seymour
    0

    Nested Content Pickers

    Hi. I'm brand new to both Umbraco and Razor. All help is appreciated.

    I have a content item (C1) with a content-picker. The content in this content-picker (C2) in turn also has several content-pickers, as well as textString title properties relating to each of the 2nd-level content-pickers. I am getting compilation errors when I try and access the properties of the content in the various content pickers. I hope if, with help, I am able to fix for C2 I can then apply the same principle to the content-pickers below.

    Here is my code snippet:

    @{
    if (Model.Content.HasValue("overlayContent"))
    {
        var overlayContent = Umbraco.TypedContent(Model.Content.GetPropertyValue<int>("overlayContent"));
    
        <div class="modal modal-blue modal-carousel fade" id="modalCarousel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel0" aria-hidden="true">
            <div class="modal-dialog modal-lg modal-width-1160">
                <div class="modal-content">
                    <div class="modal-body">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <!-- start: carousel -->
                        <div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
                            <div class="carousel-indicators-outer">
                                <ol class="carousel-indicators">
                                    if(overlayContent.HasValue("section1Title") && overlayContent.HasValue("section1Content")) {
                                    <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
                                    }
                                    if(overlayContent.HasValue("section2Title") && overlayContent.HasValue("section2Content")) {
                                    <li data-target="#carousel-example-generic" data-slide-to="1"></li>
                                    }
                                    if(overlayContent.HasValue("section3Title") && overlayContent.HasValue("section3Content")) {
                                    <li data-target="#carousel-example-generic" data-slide-to="2"></li>
                                    }
                                </ol>
                            </div>
                            <div class="carousel-inner">
                                if(overlayContent.HasValue("section1Title") && overlayContent.HasValue("section1Content")) {
                                    var section1Content = Umbraco.TypedContent(overlayContent.GetPropertyValue<int>("section1Content"));
                                    <div class="item active">
                                        <div class="item-inner">
                                            <div class="text">
                                                <h4 class="modal-title">@(overlayContent.GetProperty<string>("section1Title"))</h4>
                                                @(section1Content.GetProperty<string>("bodyText"))
                                            </div>
                                            <div class="image">
                                                <img src="/assets/images/overview1.png" alt="Overview" class="no-transition" />
                                            </div>
                                        </div>
                                    </div>
                                }
                            <a class="left carousel-control" href="#carousel-example-generic" data-slide="prev"><span class="icon-46 icon-arrow-left"></span></a>
                            <a class="right carousel-control" href="#carousel-example-generic" data-slide="next"><span class="icon-46 icon-arrow-right"></span></a>
                        </div>
                        <!-- end: carousel -->
                    </div>
                </div>
            </div>
        </div>
    }
    

    }

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Aug 05, 2014 @ 18:34
    Jeavon Leopold
    0

    Hi Mark,

    Welcome to Our!

    I think you just have a few syntax issues which I have fixed below:

    @{
    if (Model.Content.HasValue("overlayContent"))
    {
        var overlayContent = Umbraco.TypedContent(Model.Content.GetPropertyValue<int>("overlayContent"));
    
        <div class="modal modal-blue modal-carousel fade" id="modalCarousel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel0" aria-hidden="true">
            <div class="modal-dialog modal-lg modal-width-1160">
                <div class="modal-content">
                    <div class="modal-body">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <!-- start: carousel -->
                        <div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
                            <div class="carousel-indicators-outer">
                                <ol class="carousel-indicators">
                                    @if(overlayContent.HasValue("section1Title") && overlayContent.HasValue("section1Content")) {
                                    <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
                                    }
                                    @if(overlayContent.HasValue("section2Title") && overlayContent.HasValue("section2Content")) {
                                    <li data-target="#carousel-example-generic" data-slide-to="1"></li>
                                    }
                                    @if(overlayContent.HasValue("section3Title") && overlayContent.HasValue("section3Content")) {
                                    <li data-target="#carousel-example-generic" data-slide-to="2"></li>
                                    }
                                </ol>
                            </div>
                            <div class="carousel-inner">
                                @if(overlayContent.HasValue("section1Title") && overlayContent.HasValue("section1Content")) {
                                var section1Content = Umbraco.TypedContent(overlayContent.GetPropertyValue<int>("section1Content"));
                                    <div class="item active">
                                        <div class="item-inner">
                                            <div class="text">
                                                <h4 class="modal-title">@(overlayContent.GetPropertyValue<string>("section1Title"))</h4>
                                                @(section1Content.GetPropertyValue<string>("bodyText"))
                                            </div>
                                            <div class="image">
                                                <img src="/assets/images/overview1.png" alt="Overview" class="no-transition" />
                                            </div>
                                        </div>
                                    </div>
                                    }
                                    <a class="left carousel-control" href="#carousel-example-generic" data-slide="prev"><span class="icon-46 icon-arrow-left"></span></a>
                                    <a class="right carousel-control" href="#carousel-example-generic" data-slide="next"><span class="icon-46 icon-arrow-right"></span></a>
                            </div>
                            <!-- end: carousel -->
                        </div>
                    </div>
                </div>
            </div>
        </div>
      }
    

    Jeavon

Please Sign in or register to post replies

Write your reply to:

Draft