/// <summary> /// Returns the full template dataset. Results are cached when not in design mode and not cached when in design mode. /// Use this method for all runtime calls. /// </summary> /// <returns></returns> public static TemplateDto GetTemplateDto() { bool useCache = !CMSContext.Current.IsDesignMode; // do not use template caching in design mode string cacheKey = CmsCache.CreateCacheKey("templates"); // check cache first object cachedObject = null; if (useCache) { cachedObject = CmsCache.Get(cacheKey); } if (cachedObject != null) { return((TemplateDto)cachedObject); } // TODO: add caching TemplateAdmin admin = new TemplateAdmin(); admin.Load(); // Insert to the cache collection if (useCache) { CmsCache.Insert(cacheKey, admin.CurrentDto, CmsConfiguration.Instance.Cache.TemplateTimeout); } return(admin.CurrentDto); }
/// <summary> /// Gets the template dto. /// </summary> /// <param name="templateId">The template id.</param> /// <returns></returns> public static TemplateDto GetTemplateDto(int templateId) { // TODO: add caching TemplateAdmin admin = new TemplateAdmin(); admin.Load(templateId); return(admin.CurrentDto); }