当前位置: 首页>>代码示例>>C#>>正文


C# UmbracoHelper.TypedContentAtRoot方法代码示例

本文整理汇总了C#中UmbracoHelper.TypedContentAtRoot方法的典型用法代码示例。如果您正苦于以下问题:C# UmbracoHelper.TypedContentAtRoot方法的具体用法?C# UmbracoHelper.TypedContentAtRoot怎么用?C# UmbracoHelper.TypedContentAtRoot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UmbracoHelper的用法示例。


在下文中一共展示了UmbracoHelper.TypedContentAtRoot方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetListOfCommentsForPage

        public List<CommentViewModel> GetListOfCommentsForPage()
        {
            UmbracoHelper helper = new UmbracoHelper(this.UmbracoContext);

             //           IPublishedContent content = helper.TypedContent(PageId);

            IPublishedContent content = helper.TypedContentAtRoot().FirstOrDefault();

            List<CommentViewModel> ListOfComments = new List<CommentViewModel>();

            var ListOfCommentsContent = content.DescendantsOrSelf("Comment");

            foreach (var item in ListOfCommentsContent)
            {
                if (item.ContentType.Alias == "Comment")
                {
                    ListOfComments.Add(new CommentViewModel
                    {
                        Name = item.GetPropertyValue("name").ToString(),
                        Email = item.GetPropertyValue("email").ToString(),
                        Comment = item.GetPropertyValue("comment").ToString(),
                        DateAndTime = item.GetPropertyValue("dateAndTime").ToString()
                    });
                }

            }

            return ListOfComments;
        }
开发者ID:ruijosenunes,项目名称:24dentistasdelisboa,代码行数:29,代码来源:GetListOfCommentsApiController.cs

示例2: Crawl

        /// <summary>
        /// The crawl.
        /// </summary>
        /// <param name="site">
        /// The site.
        /// </param>
        /// <param name="doc">
        /// The doc.
        /// </param>
        public void Crawl(UmbracoContext site, XmlDocument doc)
        {
            /*
             *  We're going to crawl the site layer-by-layer which will put the upper levels
             *  of the site nearer the top of the sitemap.xml document as opposed to crawling
             *  the tree by parent/child relationships, which will go deep on each branch before
             *  crawling the entire site.
             */

            var helper = new UmbracoHelper(UmbracoContext.Current);
            var siteRoot = helper.TypedContentAtRoot().First();
            var node = SitemapGenerator.CreateNode(siteRoot, site);
            if (node.IsPage && node.IsListedInNavigation && node.ShouldIndex)
            {
                SitemapGenerator.AppendUrlElement(doc, node);
            }

            var items = siteRoot.Descendants();
            if (items != null)
            {
                foreach (var item in items)
                {
                    node = SitemapGenerator.CreateNode(item, site);

                    if (node.IsPage && node.IsListedInNavigation && node.ShouldIndex)
                    {
                        SitemapGenerator.AppendUrlElement(doc, node);
                    }
                }
            }
        }
开发者ID:MattSchroer,项目名称:constellation.umbraco.seo,代码行数:40,代码来源:DefaultCrawler.cs

示例3: can_retrieve_content_via_UmbracoHelper

 public void can_retrieve_content_via_UmbracoHelper()
 {
     var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
     var content = umbracoHelper.TypedContentAtRoot();
     Assert.NotEmpty(content);
     var home = content.FirstOrDefault(x => x.ContentType.Alias == "HomePage");
     Assert.NotNull(home);
 }
开发者ID:danmalcolm,项目名称:Umbraco4Devs,代码行数:8,代码来源:FirstSimpleTest.cs

示例4: SiteNavigation

        public SiteNavigation()
        {
            UmbracoHelper umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
            _publishedContent = umbracoHelper.TypedContentAtRoot().FirstOrDefault();

            // Check Current Page Id, if null (non umbraco page) default current page to root nome page.
            _currentPage = UmbracoContext.Current.PageId != null ? umbracoHelper.AssignedContentItem : _publishedContent;

            PopulateTopNavigation();
        }
开发者ID:ianbara,项目名称:ISB,代码行数:10,代码来源:SiteNavigation.cs

示例5: GetEmailRecipients

        /// <summary>
        /// Gets email recipients from root node by fieldName
        /// NOTE: if current node from umbraco context is not available - gets first homepage with urlname "home"
        /// TODO: get current culture homepage
        /// </summary>
        /// <param name="fieldName"></param>
        /// <returns></returns>
        public static IEnumerable<umbraco.BusinessLogic.User> GetEmailRecipients(string fieldName)
        {
            IEnumerable<umbraco.BusinessLogic.User> result = new List<umbraco.BusinessLogic.User>();

            var UmbracoHelper = new UmbracoHelper(UmbracoContext.Current);

            IPublishedContent rootNode = null;

            try
            {
                rootNode = UmbracoHelper.AssignedContentItem;
            }
            catch (InvalidOperationException exc)
            {
                //current node not available
                rootNode = UmbracoHelper.TypedContentAtRoot().FirstOrDefault(x => x.DocumentTypeAlias == "Site_Homepage");
            }

            result = rootNode.GetSelectedUsers(fieldName);

            return result;
        }
开发者ID:pawelgur,项目名称:UmbracoExtensions,代码行数:29,代码来源:MailHelper.cs

示例6: btnGeoCode_Click

        protected void btnGeoCode_Click(object sender, EventArgs e)
        {
            IList<string> successList = new List<string>();
            IList<string> failedList = new List<string>();

            try
            {

                int docType = 0;
                if (int.TryParse(docmapper.SelectedDocType, out docType))
                {
                    string docTypeAlias = Services.ContentTypeService.GetAllContentTypes().Where(ct => ct.Id == docType).FirstOrDefault().Alias;

                    UmbracoHelper help = new UmbracoHelper(UmbracoContext);

                    foreach (var node in help.TypedContentAtRoot().First().Descendants(docTypeAlias))
                    {
                        //geocode
                        var address = string.Empty;
                        foreach (var alias in docmapper.SelectedAddressProperties.Split(','))
                        {
                            if (alias != string.Empty)
                                address += node.GetPropertyValue<string>(alias);
                        }

                        var r = GoogleGeoCoder.CallGeoWS(address);

                        if (r.Results.Any())
                        {
                            var cs = Services.ContentService;
                            var content = cs.GetById(node.Id);

                            content.SetValue(docmapper.SelectedLocationProperty, r.Results[0].Geometry.Location.Lat.ToString(Utility.NumberFormatInfo) + "," + r.Results[0].Geometry.Location.Lng.ToString(Utility.NumberFormatInfo) + ",13");
                            cs.SaveAndPublish(content);
                        }
                    }

                    successList.Add("Content geocoding");
                }

            }
            catch (Exception)
            {
                // Append package to failed list
                failedList.Add("Failed to geocode content");
            }

            // Show message
            if (successList.Count > 0)
            {
                //Successfull
                feedback.type = umbraco.uicontrols.Feedback.feedbacktype.success;
                feedback.Text = string.Format("{0} successful", successList.First());
            }
            else
            {
                //Failed
                feedback.type = umbraco.uicontrols.Feedback.feedbacktype.error;
                feedback.Text = failedList.First();
            }
        }
开发者ID:TimGeyssens,项目名称:LocatorRazorStyle,代码行数:61,代码来源:Install.ascx.cs

示例7: GetAtoZPages

 private static SortedDictionary<string, AtoZInfo> GetAtoZPages(UmbracoHelper umbHelper, string[] excludedTypes)
 {
     var root = umbHelper.TypedContentAtRoot().First();
     return GetAtoZPages(umbHelper, excludedTypes, root);
 }
开发者ID:donaldboulton,项目名称:24Days.PJAXDemo,代码行数:5,代码来源:AtoZHelper.cs

示例8: GetAllContentUrls

        /// <summary>
        /// Gets the urls of every content item in the content section and caches the results. Is there a faster way to do this? 
        /// </summary>
        /// <param name="uh"></param>
        /// <returns></returns>
        private IEnumerable<string> GetAllContentUrls(UmbracoHelper uh)
        {
            if(this._contentIdToUrlCache != null && this._contentIdToUrlCache.Any())
            {
                //just return the cache
                return this._contentIdToUrlCache.SelectMany(x => x.Value);
            }

            Dictionary<int, IEnumerable<string>> cache = new Dictionary<int, IEnumerable<string>>();
            List<string> urls = new List<string>();

            //Id like to use UmbracoContext.Current.ContentCache.GetByRoute() somehow but you cant always guarantee that urls
            //will be in  hierarchical order because of rewriteing, etc.

            IEnumerable<IPublishedContent> roots = uh.TypedContentAtRoot();

            foreach(IPublishedContent content in roots)
            {
                IEnumerable<string> contentUrls = UmbracoFlareDomainManager.Instance.GetUrlsForNode(content.Id, false);

                cache.Add(content.Id, contentUrls);
                urls.AddRange(contentUrls);

                foreach(IPublishedContent childContent in content.Descendants())
                {
                    IEnumerable<string> childContentUrls = UmbracoFlareDomainManager.Instance.GetUrlsForNode(childContent.Id, false);

                    cache.Add(childContent.Id, childContentUrls);
                    urls.AddRange(childContentUrls);
                }
            }

            this._contentIdToUrlCache = cache;
            //Add to the cache
            HttpRuntime.Cache.Insert(CACHE_KEY, cache, null, DateTime.Now.AddDays(1), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, null);

            return urls;
        }
开发者ID:scyllagroup,项目名称:UmbracoFlare,代码行数:43,代码来源:UmbracoUrlWildCardManager.cs

示例9: Header

 //[ArchetypeResolver]
 //public KeyMessagePanel KeyMessagePanel { get; set; }
 public Header()
 {
     var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
     _publishedContent = umbracoHelper.TypedContentAtRoot().FirstOrDefault();
 }
开发者ID:ianbara,项目名称:ISB,代码行数:7,代码来源:Header.cs

示例10: GetPublishedIfExists

 /// <summary>
 /// Gets the IPublishedContent instance if it exists, otherwise returns null
 /// </summary>
 /// <returns>the IPublishedContent instance if it exists, otherwise null</returns>
 public override IPublishedContent GetPublishedIfExists()
 {
     var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
     return GetPublishedIfExists(umbracoHelper.TypedContentAtRoot());
 }
开发者ID:DanMannMann,项目名称:UmbracoCodeFirst,代码行数:9,代码来源:RootContentFactory.cs

示例11: SomeMethod

 public string SomeMethod()
 {
     var helper = new UmbracoHelper(UmbracoContext.Current);
     return helper.TypedContentAtRoot().First().Name;
 }
开发者ID:kjac,项目名称:testing-stuff,代码行数:5,代码来源:SomeUmbracoStuff.cs


注:本文中的UmbracoHelper.TypedContentAtRoot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。