/// <summary> /// Render News curlybracket /// </summary> /// <param name="parameters"></param> /// <returns></returns> public string Render(string[] parameters) { ParseParams(parameters); var templateManageModel = _templateServices.GetTemplateByName(Template) ?? _templateServices.GetTemplateByName(DefaultTemplate); var model = _newsServices.GetHotNews(Count); return(_templateServices.Parse(templateManageModel.Content, model, null, templateManageModel.CacheName)); }
/// <summary> /// Render curly bracket /// </summary> /// <param name="parameters"></param> /// <returns></returns> public string Render(string[] parameters) { ParseParams(parameters); var model = _rotatingImageGroupServices.GetGroupGallery(GroupId); if (model == null) { return(_localizedResourceServices.T("CurlyBracketsRendering:::RotatingImages:::Messages:::GroupNotFounded:::Group id is invalid. Please check the data again.")); } var template = _templateServices.GetTemplateByName(Template) ?? _templateServices.GetTemplateByName(DefaultTemplate); return(_templateServices.Parse(template.Content, model, null, template.CacheName)); }
/// <summary> /// Render curly bracket /// </summary> /// <param name="parameters"></param> /// <returns></returns> public string Render(string[] parameters) { ParseParams(parameters); var banner = _bannerServices.GetById(BannerId); if (banner == null) { return(_localizedResourceServices.T("CurlyBracketsRendering:::SingleBanner:::Messages:::BannerNotFounded:::Banner id is invalid. Please check the data again.")); } var bannerRenderModel = new BannerCurlyBracket(banner); var template = _templateServices.GetTemplateByName(Template) ?? _templateServices.GetTemplateByName(DefaultTemplate); return(_templateServices.Parse(template.Content, bannerRenderModel, null, template.CacheName)); }
/// <summary> /// Render curly bracket /// </summary> /// <param name="parameters"></param> /// <returns></returns> public string Render(string[] parameters) { ParseParams(parameters); var page = _pageServices.GetById(PageId); if (page == null) { return(_localizedResourceServices.T("CurlyBracketsRendering:::PageContent:::Messages:::GetPageContentIdNotFounded:::Page id is invalid. Please check the data again.")); } var pageRenderModel = new PageRenderModel(page); var template = _templateServices.GetTemplateByName(Template) ?? _templateServices.GetTemplateByName(DefaultTemplate); return(_templateServices.Parse(template.Content, pageRenderModel, null, template.CacheName)); }
/// <summary> /// Render page content by friendly url /// </summary> /// <param name="url"></param> /// <returns></returns> public PageRenderModel RenderContent(string url) { var page = GetPage(url); if (page != null) { WorkContext.ActivePageId = page.Id; var model = new PageRenderModel(page); if (model.IsFileTemplate) { return(model); } var template = _pageTemplateServices.RenderPageTemplate(page.PageTemplateId, model); if (template.IndexOf(Configurations.RenderBody, StringComparison.Ordinal) > -1) { template = template.Replace(Configurations.RenderBody, "@Raw(Model.Content)"); } template = _templateServices.Parse(template, model, null, page.Title); model.Content = _curlyBracketServices.Render(template); return(model); } return(null); }
/// <summary> /// Render dynamic menu /// </summary> /// <param name="parameters"></param> /// <returns></returns> public string Render(string[] parameters) { //Initialize parameter ParseParams(parameters); var templateList = new List <string> { ParentTemplateName, ChildMobileTemplateName, ChildTemplateName }; /* * Check storing menu result in cache * If all the menus are not updated then get the cache result * If not rebuild the data and recache */ CacheMenu cacheMenu; var cacheName = string.Join("_", parameters); var lastCreated = _clientMenuServices.GetAll().Max(t => t.Created); var lastUpdated = _clientMenuServices.GetAll().Max(t => t.Updated) ?? DateTime.MinValue; var dataCacheTime = lastCreated > lastUpdated ? lastCreated : lastUpdated; lastCreated = _templateServices.Fetch(t => templateList.Contains(t.Name)).Max(t => t.Created); lastUpdated = _templateServices.Fetch(t => templateList.Contains(t.Name)).Max(t => t.Updated) ?? DateTime.MinValue; var templateCacheTime = lastCreated > lastUpdated ? lastCreated : lastUpdated; if (HttpContext.Current.Application[cacheName] != null) { cacheMenu = (CacheMenu)HttpContext.Current.Application[cacheName]; if (cacheMenu.DataCacheTime == dataCacheTime && cacheMenu.TemplateCacheTime == templateCacheTime) { return(cacheMenu.Content); } } /* * Get tree data * Recursive to get all the html of dynamic menu */ var items = _clientMenuServices.GetAll() .Where(m => m.IncludeInSiteNavigation && (!m.StartPublishingDate.HasValue || DateTime.Now > m.StartPublishingDate) && (!m.EndPublishingDate.HasValue || DateTime.Now < m.StartPublishingDate)) .Select(m => new ClientMenuModel { Id = m.Id, PageId = m.PageId, Name = m.Name, RecordOrder = m.RecordOrder, Url = m.Page.IsHomePage ? string.Empty : m.Url, ParentId = m.ParentId, }).ToList(); var data = GetTree(items, ParentId, 0); foreach (var dynamicMenu in data) { dynamicMenu.ChildMenusString = RenderMenus(dynamicMenu.ChildMenus, _childTemplate); dynamicMenu.ChildMenusMobileString = RenderMobileMenus(dynamicMenu.ChildMenus, _childMobileTemplate); } /* * Create cache version of this curly bracket and store in Application */ cacheMenu = new CacheMenu { Content = _templateServices.Parse(_parentTemplate.Content, data, null, _parentTemplate.CacheName), DataCacheTime = dataCacheTime, TemplateCacheTime = templateCacheTime }; HttpContext.Current.Application[cacheName] = cacheMenu; return(cacheMenu.Content); }