Пример #1
0
 private string GetProcessedString(string type)
 {
     if (!string.IsNullOrEmpty(CategoryName))
     {
         return(CategoryName.Replace("{type}", type));
     }
     return(type);
 }
Пример #2
0
        protected override string ViewLookUp(string baseName, string defaultViewName)
        {
            Category category = new CategoryController().GetCachedCategory(CategoryID, false);

            if (ViewExists(CategoryName + "." + PostName + baseName))
            {
                return(CategoryName + "." + PostName + baseName);
            }
            else if (ViewExists(CategoryName.Replace("/", ".") + ".post" + baseName))
            {
                return(CategoryName.Replace("/", ".") + ".post" + baseName);
            }
            else if (ViewExists(CategoryName + ".post" + baseName))
            {
                return(CategoryName + ".post" + baseName);
            }
            else if (defaultViewName == "post.view" && ViewExists(PostName + ".view"))
            {
                return(PostName + ".view");
            }
            else if (ViewExists(PostName + baseName))
            {
                return(PostName + baseName);
            }

            // Subcategories
            if (category.ParentId > 0)
            {
                // parent-name.child-name.view
                if (ViewExists(category.LinkName.Replace("/", ".") + ".post" + baseName))
                {
                    return(category.LinkName.Replace("/", ".") + ".post" + baseName);
                }

                // childcategory.parent-name.post.view
                if (ViewExists("childcategory." + category.Parent.LinkName + ".post" + baseName))
                {
                    return("childcategory." + category.Parent.LinkName + ".post" + baseName);
                }

                if (ViewExists(category.LinkName.Replace("/", ".") + baseName))
                {
                    return(category.LinkName.Replace("/", ".") + baseName);
                }

                if (ViewExists(category.Parent.LinkName + ".post" + baseName))
                {
                    return(category.Parent.LinkName + ".post" + baseName);
                }

                if (ViewExists(category.Parent.LinkName + baseName))
                {
                    return(category.Parent.LinkName + baseName);
                }
            }
            // return CategoryName.layout.view for child posts, but not CategoryName.view
            else if (ViewExists(CategoryName + baseName) && baseName != ".view")
            {
                return(CategoryName + baseName);
            }

            else if (CategoryID == CategoryController.UnCategorizedId && ViewExists("page" + baseName))
            {
                return("page" + baseName);
            }

            else if (ViewExists("post" + baseName))
            {
                return("post" + baseName);
            }

            else if (ViewExists(defaultViewName))
            {
                return(defaultViewName);
            }

            return(base.ViewLookUp(baseName, defaultViewName));
        }