コード例 #1
0
ファイル: PageList.cs プロジェクト: moayyaed/YetaWF-Modules
        /// <summary>
        /// Create a page list for the current site.
        /// </summary>
        public async Task <string> CreateAsync()
        {
            StringBuilder sb = new StringBuilder();

            // Designed pages (only)
            List <Guid> pageGuids = await PageDefinition.GetDesignedGuidsAsync();

            List <string> pages = new List <string>();

            foreach (Guid guid in pageGuids)
            {
                PageDefinition page = await PageDefinition.LoadPageDefinitionAsync(guid);

                if (page != null)
                {
                    pages.Add(page.EvaluatedCanonicalUrl);
                }
            }
            pages = pages.OrderBy(s => s).ToList();
            foreach (string page in pages)
            {
                sb.AppendLine(Manager.CurrentSite.MakeFullUrl(page));
            }
            return(sb.ToString());
        }
コード例 #2
0
        /// <summary>
        /// Called by the framework when the component needs to be rendered as HTML.
        /// </summary>
        /// <param name="model">The model being rendered by the component.</param>
        /// <returns>The component rendered as HTML.</returns>
        public async Task <string> RenderAsync(Guid?model)
        {
            HtmlBuilder hb = new HtmlBuilder();

            if (model != null)
            {
                PageDefinition page = await PageDefinition.LoadPageDefinitionAsync((Guid)model);

                if (page == null)
                {
                    hb.Append(__ResStr("notFound", "(Page not found - {0})", model.ToString()));
                }
                else
                {
                    hb.Append(HE(page.Url));
                }
            }
            return(hb.ToString());
        }