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
    6 days ago
    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 4847 posts 17440 karma points MVP 2x admin c-trib
    5 days ago
    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
    5 days ago
    Rylan
    0

    Still not working :(

    enter image description here

  • Louis Jackson-Rees 41 posts 167 karma points
    4 days ago
    Louis Jackson-Rees
    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
    1 day ago
    Rylan
    0

    Sorry must have posted the wrong screenshot.

    enter image description here

  • Louis Jackson-Rees 41 posts 167 karma points
    22 hours ago
    Louis Jackson-Rees
    0

    Change all of your .GetValue to .GetPropertyValue

  • Rylan 67 posts 251 karma points
    14 hours ago
    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