Copied to clipboard

Flag this post as spam?

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


  • Bas Schouten 135 posts 233 karma points
    Mar 07, 2016 @ 16:18
    Bas Schouten
    0

    Custom properties on MultinodeTreePicker

    I'm using the MultinodeTreePicker to select related content. Is it possible to display custom properties?

    My code:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    if(@CurrentPage.HasValue("trainingen")) 
    {
    foreach (var item in @CurrentPage.trainingen.ToString().Split(',')) 
    {
    var page = Umbraco.TypedContent(item);
    if(page != null){
            <div> 
            <a href="@page.Url">
             @page.Name
             </a>
            </div>   
            }
        }
    }
    

    When I use @page.CustomPropertie the error says "'Umbraco.Web.Models.PublishedContentWithKeyBase' does not contain a definition for 'CustomPropertie'".

    What is the best way to do this?

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Mar 07, 2016 @ 16:20
    Jeavon Leopold
    0

    Try this:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    if(CurrentPage.HasValue("trainingen")) 
    {
    foreach (var item in CurrentPage.trainingen.ToString().Split(',')) 
    {
    var page = Umbraco.Content(item);
    if(page != null){
            <div> 
            <a href="@page.Url">
             @page.Name
             </a>
            </div>   
            }
        }
    }
    
  • Bas Schouten 135 posts 233 karma points
    Mar 07, 2016 @ 16:26
    Bas Schouten
    0

    Hi Jeavon,

    Thaks for your reply. The error now says:

    Compiler Error Message: CS0117: 'umbraco.page' does not contain a definition for 'Url'

    Bas

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Mar 07, 2016 @ 16:28
    Jeavon Leopold
    100

    Ah, need a Razor block:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        if (CurrentPage.HasValue("trainingen"))
        {
            foreach (var item in CurrentPage.trainingen.ToString().Split(','))
            {
                var page = Umbraco.Content(item);
                if (page != null)
                {
                    <div>
                        <a href="@page.Url">
                            @page.Name
                        </a>
                    </div>
                }
            }
        }
    }
    
  • Bas Schouten 135 posts 233 karma points
    Mar 07, 2016 @ 17:48
    Bas Schouten
    0

    Great! This is working!

Please Sign in or register to post replies

Write your reply to:

Draft