Copied to clipboard

Flag this post as spam?

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


  • Richard Galt 50 posts 186 karma points
    Aug 14, 2014 @ 16:27
    Richard Galt
    0

    Archetype / Core Property Value Converters help

    Hi guys,

    I'm trying to create a side nav menu with a heading and then multiple relatedlinks beneath, by using the Archetype project I can then replicate this code multiple times in a template. I'm having an issue where I can get the heading displayed from my Archetype but not the link or link caption as it's contained in a string.

    I've been advised to use the core property value converters but seem to be getting no where.

    This is my source code:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @using Archetype.Models;
    @using Archetype.Extensions;
    
    @foreach (var fieldset in Model.Content.GetPropertyValue<ArchetypeModel>("MultipleRelatedLinks"))
        {
                <div class="related-items">
                    <div class="page-header">
                        <h2>@Html.Raw(fieldset.GetValue("relatedcontentname"))</h2>
    
                    </div>
                    <ul class="nav nav-list">
                            <li>
                        <a href="@Html.Raw(fieldset.GetValue("link"))">@Html.Raw(fieldset.GetValue("caption"))</a>
                            </li>
                    </ul>
                </div>
        }
    

    This is the way the Archetype is set-up: enter image description here

    Any help would be much appreciated.

    Thanks

    Rich

  • Jeavon Leopold 3000 posts 13161 karma points MVP 6x admin c-trib
    Aug 14, 2014 @ 16:36
    Jeavon Leopold
    0

    Hi Rich,

    With both of those packages you should be able to do this:

      @foreach (var fieldset in Model.Content.GetPropertyValue<ArchetypeModel>("MultipleRelatedLinks"))
      {
        <div class="related-items">
            <div class="page-header">
                <h2>@Html.Raw(fieldset.GetValue("relatedcontentname"))</h2>
            </div>        
            @{
                var relatedContentLinks = fieldset.GetValue<RelatedLinks>("relatedcontentlinks");
    
                if (relatedContentLinks.Any())
                {
                <ul class="nav nav-list">
                    @foreach (var item in relatedContentLinks)
                    {
                        var linkTarget = (item.NewWindow) ? "_blank" : null;
                        <li><a href="@item.Link" target="@linkTarget">@item.Caption</a></li>
                    }
                </ul>
                }
            }
        </div>
      }  
    

    Jeavon

  • Jeavon Leopold 3000 posts 13161 karma points MVP 6x admin c-trib
    Aug 14, 2014 @ 16:39
    Jeavon Leopold
    101

    Edited the above a little to use sensible variable names :-)

  • Richard Galt 50 posts 186 karma points
    Aug 14, 2014 @ 16:41
    Richard Galt
    0

    Cheers Jeavon,

    A legend as usual :)

  • Jeavon Leopold 3000 posts 13161 karma points MVP 6x admin c-trib
    Aug 14, 2014 @ 16:48
    Jeavon Leopold
    0

    You're very welcome! I just read your other post, looks like you ended up with the v1 documentation for the value converters which is for Umbraco v6. v2 documentation for Umbraco v7 is all here

    I hope that using the value converters makes sense to you? You will need to update all existing Razor for any of the editors that are now being converted by the package.

    Post me any questions on the value converter forum here

  • Richard Galt 50 posts 186 karma points
    Aug 14, 2014 @ 16:51
    Richard Galt
    0

    Thank you for that, it's all very new to me. After I installed the value converters a few scripts broke but some how I managed to fix them!

    Thanks again for all the help :)

  • Jeavon Leopold 3000 posts 13161 karma points MVP 6x admin c-trib
    Aug 14, 2014 @ 16:53
    Jeavon Leopold
    0

    Cool, hopefully they became simpler :-)

Please Sign in or register to post replies

Write your reply to:

Draft