コード例 #1
0
ファイル: PostService.cs プロジェクト: vipervf1/uBlogsy
        /// <summary>
        /// Ensures that the node name is the same as the post title
        /// </summary>
        /// <param name="doc"></param>
        /// <returns></returns>
        public IContent EnsureCorrectPostNodeName(IContent doc)
        {
            var useTitleAsNodeName = IContentHelper.GetValueFromAncestor(doc, "uBlogsyLanding", "uBlogsyGeneralUseTitleAsNodeName");

            if (useTitleAsNodeName == "1")
            {
                var title = doc.GetValue <string>("uBlogsyContentTitle");
                if (!string.IsNullOrEmpty(title) && doc.Name != title)
                {
                    // ensure node name is same as title
                    doc.Name = title;
                    ApplicationContext.Current.Services.ContentService.Save(doc, 0, false);
                }
            }

            return(doc);
        }