Copied to clipboard

Flag this post as spam?

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


  • Rylan 67 posts 251 karma points
    Dec 04, 2018 @ 23:28
    Rylan
    0

    Nested Content with TeraType

    Hey Everyone,

    I've installed the Terratype package using the Umbraco Backoffice. I created a Document Type Called "Map Item"

    Here I have listed:

    • Title
    • Location
    • Description
    • Map

    On the page I want to display the map, I created a "Map List (alias: mapList)" using Nested Content which where my client can easily add new map pins.

    I'm trying to render the content but am having an error.

    enter image description here

    My code is as follows:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @using Terratype;
    @{
        Layout = "BasePage.cshtml";
    }
    <section>
        @foreach (var record in Model.Content.mapList)
        {
            var name = record.GetValue<string>("title");
            var map = record.GetValue<Terratype.Models.Model>("location");
            @Html.Terratype(new Options { MapSetId = 1 }, map,
            @<text>
             @name is at @map.Position
             </text>
            )
        }
    </section>
    

    Each of these locations is going to be a project, which will require a popup with name, image, and description with a possible read more button.

    If it's better to not go as nested content, how would I go the route of a foreach loop to pull in these "pages" dynamically to populate the map.

    Thanks for your time.

  • Alex Skrypnyk 6131 posts 23950 karma points MVP 7x admin c-trib
    Dec 05, 2018 @ 21:00
    Alex Skrypnyk
    0

    Hi Rylan

    Try this code:

     @foreach (var record in Model.Content.GetPropertyValue<IEnumerable<IPublishedContent>>("mapList"))
    

    Alex

  • Rylan 67 posts 251 karma points
    Dec 06, 2018 @ 16:22
    Rylan
    0

    Still not working :(

    enter image description here

  • louisjrdev 107 posts 344 karma points c-trib
    Dec 07, 2018 @ 08:27
    louisjrdev
    0

    The code you have is not exactly as per Alex's example please ensure this is the same:

     @foreach (var record in Model.Content.GetPropertyValue<IEnumerable<IPublishedContent>>("mapList"))
    
  • Rylan 67 posts 251 karma points
    Dec 10, 2018 @ 04:05
    Rylan
    0

    Sorry must have posted the wrong screenshot.

    enter image description here

  • louisjrdev 107 posts 344 karma points c-trib
    Dec 10, 2018 @ 08:12
    louisjrdev
    0

    Change all of your .GetValue to .GetPropertyValue

  • Rylan 67 posts 251 karma points
    Dec 10, 2018 @ 15:58
    Rylan
    0

    I've done that now and still an error. Sorry, I'm more of a designer / front end developer!

    enter image description here

    Here is my document type:

    enter image description here

    I double checked and the alias is "mapList".

Please Sign in or register to post replies

Write your reply to:

Draft