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:57
    Robert J. Bullock
    0

    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){ //code }
    
    @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;   
        }
    
    }
    
    
Please Sign in or register to post replies

Write your reply to:

Draft