Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Corlate.Feature.Configurations.Models
- {
- using Corlate.Foundation.Common.Utilities;
- using Sitecore.Data;
- using Sitecore.Data.Items;
- using System;
- using System.Collections.Generic;
- using System.Text;
- /// <summary>
- /// Defines the <see cref="PageSettings" />
- /// </summary>
- public class PageSettings : CustomItem
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="PageSettings"/> class.
- /// </summary>
- /// <param name="innerItem">The <see cref="Item"/></param>
- public PageSettings(Item innerItem) : base(innerItem)
- {
- }
- /// <summary>
- /// Gets the ThemeLibrariesInsideHeadTag
- /// </summary>
- public string ThemeLibrariesInsideHeadTag
- {
- get
- {
- return GetThemeLibraryReferences(References.Templates.PageSettings.Fields.ThemeLibrariesInsideHeadTag);
- }
- }
- /// <summary>
- /// Gets the ThemeLibrariesInsideBodyTag
- /// </summary>
- public string ThemeLibrariesInsideBodyTag
- {
- get
- {
- return GetThemeLibraryReferences(References.Templates.PageSettings.Fields.ThemeLibrariesInsideBodyTag);
- }
- }
- /// <summary>
- /// gets the html markup of references for all the selected theme libraries
- /// </summary>
- /// <param name="multilistFieldID"></param>
- /// <returns></returns>
- public string GetThemeLibraryReferences(ID multilistFieldID)
- {
- StringBuilder sbReferences = new StringBuilder(string.Empty);
- try
- {
- IList<Item> selectedItems = SitecoreUtility.GetSelectedItemsInMultilistField(InnerItem, multilistFieldID);
- ThemeLibrary themeLibrary = null;
- if (selectedItems != null && selectedItems.Count > 0)
- {
- foreach (Item item in selectedItems)
- {
- themeLibrary = new ThemeLibrary(item);
- if (themeLibrary != null)
- {
- if (themeLibrary.IsStylesheet)
- {
- sbReferences.AppendLine("<link href=\"" + themeLibrary.FilePath + "\" rel=\"stylesheet\" />");
- }
- else
- {
- sbReferences.AppendLine("<script src=\"" + themeLibrary.FilePath + "\"></script>");
- }
- }
- }
- }
- }
- catch (Exception ex)
- {
- sbReferences = new StringBuilder(string.Empty);
- }
- return Convert.ToString(sbReferences);
- }
- }
- }
Add Comment
Please, Sign In to add comment