Copied to clipboard

Flag this post as spam?

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


  • Robert J. Bullock 386 posts 405 karma points
    May 16, 2013 @ 19:58
    Robert J. Bullock
    1

    Umbraco.Web.Models.RenderModel' does not contain a definition for 'NodeTypeAlias'

    Getting this error with my partial view:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage
    @using umbraco.MacroEngines
    
    @helper setHeadings(string sectionHeading,string pageHeading,string contentTitle){  }
    
    @functions{
        public string getSectionIcon(dynamic node){
            string prefix = "";
            dynamic rootNode = Model.AncestorOrSelf();
            if(rootNode.HasValue("mainMenu")){
            foreach(var item in rootNode.mainMenu){
                var id = item.link.ToString();
                if(id == node.Id.ToString()){
                        prefix = item.prefix.ToString() + " ";
                    }
                }
            }
            return prefix;
        }
    }
    
    @helper eventHeadings(){
            @setHeadings("Event Section","Event Heading","Event Title")
    }
    
    @helper newsHeadings(){
            @setHeadings("News Section","News Heading","News Title")
    }
    
    @helper primaryCareHeadings(){
            @setHeadings("Primary Care","PC Heading","PC Title")
    }
    
    @helper defaultHeadings(){
        int level = Model.Level;
        string sectionHeading = "";
        string pageHeading = "";
        string contentTitle = "";
        string parentLink;
        dynamic parent;
    
        if(Model.Level <= 2){
            //Level 1
            sectionHeading = getSectionIcon(Model) + Model.Title;
        }
        else {
            //Level 2+
            dynamic sectionNode = Model.AncestorOrSelf(2);
            sectionHeading = getSectionIcon(sectionNode) + " " + sectionNode.Title;
            //sectionHeading = sectionNode.Title;
        }
    
        //Just show title for pages at level 2
        if(level < 4) {
            //Level 1-3
            pageHeading = Model.HasValue("subheading") ? Model.Subheading : Model.Title;        
        }
        else {
            //Level 4+
            parent = Model.Parent;
            //Show link to parent and then page title...
            pageHeading = parent.Title;
            contentTitle = Model.Title;
        }
    
        @setHeadings(sectionHeading,pageHeading,contentTitle)
    }
    
    @{ 
        string nodeType = Model.NodeTypeAlias;
    
        switch (nodeType)
        {
            case "event": 
                @eventHeadings()
                break;
            case "news": 
                @newsHeadings()
                break;
            case "primaryCare": 
                @primaryCareHeadings()
                break;
            default:
                @defaultHeadings()
                break;   
        }
    
    }
    
    
  • gary 385 posts 916 karma points
    May 17, 2013 @ 01:39
    gary
    0

    hi Robert

     

    as i understand it, @Model will return static, as you call dynamic you may need to exchange your @Model for @CurrentPage to return the dynamic. I think this is what is causing your error although the error does not seem to point to it, if you get my.meaning.

     

    hope it helps

    gary

  • BJ Patel 84 posts 210 karma points
    Jul 08, 2017 @ 06:02
    BJ Patel
    0

    Hi Robert,

    Did you find the solution for your problem,

    If so can you please post the solution.

    Thanks BJ

Please Sign in or register to post replies

Write your reply to:

Draft