/// <summary>
        /// Sets the placeholder names and values and the layout used for a particular section.
        /// </summary>
        /// <param name="placeholders">The Umbraco fields</param>
        /// <param name="sectionPlaceholder">The section placeholder.</param>
        /// <param name="subtitlePlaceholder">The subtitle placeholder.</param>
        /// <param name="contentPlaceholder">The content placeholder.</param>
        /// <param name="imagePlaceholder1">The 1st image placeholder.</param>
        /// <param name="imagePlaceholder2">The 2nd image placeholder.</param>
        /// <param name="imagePlaceholder3">The 3rd image placeholder.</param>
        /// <param name="captionPlaceholder1">The 1st caption placeholder.</param>
        /// <param name="captionPlaceholder2">The 2nd caption placeholder.</param>
        /// <param name="captionPlaceholder3">The 3rd caption placeholder.</param>
        /// <param name="altAsCaptionPlaceholder1">The 1st alt as caption placeholder.</param>
        /// <param name="altAsCaptionPlaceholder2">The 2nd alt as caption placeholder.</param>
        /// <param name="altAsCaptionPlaceholder3">The 3rd alt as caption placeholder.</param>
        /// <param name="defaultLayout">The default layout.</param>
        private void SetupSections(PlaceholderCollection placeholders, string sectionPlaceholder, string subtitlePlaceholder, string contentPlaceholder, string imagePlaceholder1, string imagePlaceholder2, string imagePlaceholder3, string captionPlaceholder1, string captionPlaceholder2, string captionPlaceholder3, string altAsCaptionPlaceholder1, string altAsCaptionPlaceholder2, string altAsCaptionPlaceholder3, string defaultLayout)
        {
            // Load the usercontrol appropriate to the chosen layout, and pass in all the names of the placeholders it should use
            string selectedLayout = SectionLayoutManager.GetSelectedSectionLayout(placeholders, sectionPlaceholder, defaultLayout);

            try
            {
                Control      selectedControl = this.LoadControl(SectionLayoutManager.UserControlPath("Escc.EastSussexGovUK.Umbraco/TopicSectionLayouts", selectedLayout));
                TopicSection sectionControl  = selectedControl as TopicSection;

                if (sectionControl != null)
                {
                    sectionControl.PlaceholderToBindSection        = sectionPlaceholder;
                    sectionControl.PlaceholderToBindSubtitle       = subtitlePlaceholder;
                    sectionControl.PlaceholderToBindContent        = contentPlaceholder;
                    sectionControl.PlaceholderToBindImage01        = imagePlaceholder1;
                    sectionControl.PlaceholderToBindImage02        = imagePlaceholder2;
                    sectionControl.PlaceholderToBindImage03        = imagePlaceholder3;
                    sectionControl.PlaceholderToBindCaption01      = captionPlaceholder1;
                    sectionControl.PlaceholderToBindCaption02      = captionPlaceholder2;
                    sectionControl.PlaceholderToBindCaption03      = captionPlaceholder3;
                    sectionControl.PlaceholderToBindAltAsCaption01 = altAsCaptionPlaceholder1;
                    sectionControl.PlaceholderToBindAltAsCaption02 = altAsCaptionPlaceholder2;
                    sectionControl.PlaceholderToBindAltAsCaption03 = altAsCaptionPlaceholder3;
                }
                // Add the section to the page
                this.sections.Controls.Add(selectedControl);
            }
            catch (ArgumentException exception)
            {
                // Expected if an obsolete section has been removed from config, but is still referenced by the page
                exception.ToExceptionless().Submit();
            }
        }
Exemple #2
0
 public static async Task<TopicSection> FromModelAsync(ApplicationDbContext context, TopicModel topicModel)
 {
     TopicSection section = new TopicSection();
     section.TopicTitle = topicModel.TopicTitle;
     section.TopicId = topicModel.TopicId;
     section.TopicDescription = topicModel.Description;
     ArticleModel[] newArticles =
         context.Articles.Where(f => !f.IsDraft && f.ThemeId.Equals(topicModel.TopicId))
             .OrderBy(f => f.CreationTime)
             .Take(3)
             .ToArray();
     section.NewModels = newArticles;
     List<ArticleModel> flamedArticles = new List<ArticleModel>();
     var flamedArticlesQuery = context.CurrentRanking.Where(f => f.TopicId.Equals(topicModel.TopicId))
         .OrderBy(f => f.PVCoefficient).Take(3).ToList();
     foreach (var currentRankingModel in flamedArticlesQuery)
     {
         flamedArticles.Add(await context.Articles.FindAsync(currentRankingModel.ArticleId));
     }
     section.FlamedModels = flamedArticles.ToArray();
     return section;
 }
Exemple #3
0
 public static string GetLink(TopicSection section)
 {
     return(string.Concat("/docs/", section.Id));
 }