Issues

Issue #6284 invalid

Moving Blog under another node

Anonymous created an issue

I installed the newest Umbraco version, then installed uBlogsy. I created a generic home page template, allowed it to have "Blog Landing" children and then moved the blog node underneath it.

After doing this, the "Content" node fails to load. I traced it to the CreatePost.ascx file. There is an if statement for:

foreach (var root in roots) { if (root.ContentType.Alias == "uBlogsyLanding") { ddlRoots.Items.Add(new ListItem(root.Text, root.Id.ToString())); } else { .... ddlRoots.Items.Add(new ListItem(landing.Text, landing.Id.ToString())); }

The bold line is what faile. The "landing" object does NOT have a "Text" property. If I comment that line out, the list still builds fine for me, but I'm not sure what scenario this line is needed.

Comments (3)

  1. Kiel Diller

    I am the original poster... after further testing, I am able to re-produce and fix the issue:

    if you use the current code:

    if (root.ContentType.Alias == "uBlogsyLanding")
                    {
                        ddlRoots.Items.Add(new ListItem(root.Text, root.Id.ToString()));
                    }
                    else
                    {
                        // get landings that may be in this root
                        var landings = root.GetDescendants().Cast<Document>().Where(x => x.ContentType.Alias == "uBlogsyLanding");
    
                        foreach (var landing in landings)
                        {
                            // add landing to ddl
                            ddlRoots.Items.Add(new ListItem(landing.Text, landing.Id.ToString()));
                        }
                    }
    

    You will get an error.

    however, if you change it to:

    if (root.ContentType.Alias == "uBlogsyLanding")
                    {
                        ddlRoots.Items.Add(new ListItem(root.Text, root.Id.ToString()));
                    }
                    else
                    {
                        // get landings that may be in this root
                        var landings = root.GetDescendants().Cast<Document>().Where(x => x.ContentType.Alias == "uBlogsyLanding").ToList();
    
                        if(landings != null)
                        {
                            foreach (var landing in landings)
                            {
                                var doc = new Document(landing.Id);                         
                                ddlRoots.Items.Add(new ListItem(doc.Text, doc.Id.ToString()));
                            }
                        }
                    }
    

    Problem solved!

  2. Log in to comment