Copied to clipboard

Flag this post as spam?

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


  • Paul 24 posts 114 karma points
    May 15, 2015 @ 14:44
    Paul
    0

    Model.Content.HasValue cannot find RJP MultiUrlPicker

    Hi, I am replacing a uComponents multi url picker with the RJP one that I see recommended on here.

    The check variable in my code returns null and I cannot seem to use this package.

     @using RJP.MultiUrlPicker.Models;
     @inherits Umbraco.Web.Macros.PartialViewMacroPage
    
     @{
         var multiUrlPicker = Model.Content.GetPropertyValue<MultiUrls>("mainNavigation");
         var check = (multiUrlPicker != null) ? "not null" : "null";
         <h1>@check</h1>
     }
    

    I have double checked that the alias exists in the CMS on the Doctype that calls this macro, the picker has some content and republished the site. Everything seems fine there.

    I am calling the macro from the global template page on the website, is that what is causing the problem?

     @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
      ......
                    <div class="siteWidth">
                        <a class="menuToggle"></a>
                        @Umbraco.RenderMacro("navigationBar")
                    </div>
      ......
    
  • Paul 24 posts 114 karma points
    May 15, 2015 @ 16:00
    Paul
    0

    This is the reference in my Umbraco.Config showing that it exists:

    <mainNavigation><![CDATA[[
      {
        "id": "1100",
        "name": "Home",
        "url": "/",
        "target": "_top",
        "icon": "home.png"
      },
      {
        "id": "1121",
        "name": "Contact",
        "url": "/contact_us/",
        "target": "_top",
        "icon": "icon-picture"
      }
    ]]]></mainNavigation>
    
  • Paul 24 posts 114 karma points
    May 18, 2015 @ 10:13
    Paul
    100

    This was my solution:

    var v = Umbraco.TypedContent(1151);
    var multiUrlPicker = v.GetPropertyValue<MultiUrls>("mainNavigation");
    

    1151 is a global template page that had been set up on this website (I don't know if that is common to all Umbraco setups, but I assume it is). I need to change it to dynamically get this page's id in the future.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies