/// <summary> /// 首页 /// </summary> /// <returns></returns> public ActionResult Index() { WebLanguage lang = XFrontContext.Current.Language; string viewName = string.Format("Index_{0}", lang.ToString()); if (lang == WebLanguage.zh_cn) { //显示启用的以及未删除的 ViewBag.ProductService = CategoryService.ListByParentId(4).Where(p => (p.IsEnabled == true && p.IsDeleted == false)).ToList(); ViewBag.CompanyNews = ArticleService.ListWithoutPageV2("新闻中心/公司新闻", 7, lang); ViewBag.IndustryNews = ArticleService.ListWithoutPageV2("新闻中心/行业新闻", 7, lang); ViewBag.FocusImageList = ArticleService.ListWithoutPageV2("首页设置/焦点图片", 4, lang); ViewBag.Business = ArticleService.ListWithoutPageV2("企业业绩", 7, lang); ViewBag.NoticeList = NoticeService.List(); } if (lang == WebLanguage.en) { ViewBag.ProductService = CategoryService.ListByParentId(110).Where(p => (p.IsEnabled == true && p.IsDeleted == false)).ToList(); } return(View(viewName)); }
public ActionResult RenderSubNavForChannelPage(int catId, string customTitle = "", WebLanguage language = WebLanguage.zh_cn) { /* * <span class="fgray">您所在的位置:</span><a href="#">首页</a> > <a href="http://www.mtd.com.cn/about.htm"> * 关于机科</a> > 公司简介 */ StringBuilder sbNav = new StringBuilder(string.Format("<span class=\"fgray\">{2}:</span><a href=\"/{1}\">{0}</a>", LanguageResourceHelper.GetString("channel-sub-nav-home-text", language), (language == WebLanguage.zh_cn ? string.Empty : language.ToString()), LanguageResourceHelper.GetString("current-text", language)) ); if (catId > 0) { //可以显示未启用的分类,但是不能显示已删除的分类 var upList = CategoryService.ListUpById(catId, language).Where(p => p.IsDeleted == false); foreach (var item in upList) { sbNav.AppendFormat(" > <a href=\"{1}\" title=\"{0}\">{0}</a>", item.Name, item.Url); } } if (!string.IsNullOrEmpty(customTitle)) { sbNav.AppendFormat(" > {0}", customTitle); } return(Content(sbNav.ToString())); }
public static void LoadExtensionInfo(ArticleInfo model, WebLanguage language = WebLanguage.zh_cn) { // if (!string.IsNullOrEmpty(model.LinkUrl)) { model.Url = model.LinkUrl; } else { model.Url = string.Format("{2}/{0}/{1}.html", model.CreateDateTime.ToString("yyyy-MM-dd"), model.Timespan, language == WebLanguage.zh_cn ? string.Empty : "/" + language.ToString()); } }
public static string BuildLink(CategoryInfo model, string linkText = "", object htmlAttributes = null, WebLanguage language = WebLanguage.zh_cn) { var dic = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes); StringBuilder sbTag = new StringBuilder("<a"); sbTag.AppendFormat(" id=\"{0}\"", model.Id); sbTag.AppendFormat(" title=\"{0}\"", model.Name); foreach (var p in dic) { sbTag.AppendFormat(" {0}=\"{1}\"", p.Key, p.Value); } if (string.IsNullOrEmpty(linkText)) { linkText = model.Name; } if (!string.IsNullOrEmpty(model.LinkUrl)) { //不用新打开窗口 target=\"_blank\" sbTag.AppendFormat(" href=\"{0}\"", model.LinkUrl); } else { //TODO //这个地方还得做别名Url //目前是没做别名处理 sbTag.AppendFormat(" href=\"{1}/channel/{0}.html\"", model.Alias == string.Empty ? model.Id.ToString() : model.Alias, language == WebLanguage.zh_cn ? string.Empty : "/" + language.ToString()); } sbTag.AppendFormat(">{0}</a>", linkText); return(sbTag.ToString()); }
/// <summary> /// 添加扩展信息,主要生成文章URL /// </summary> /// <param name="model"></param> /// <param name="language"></param> private static void LoadExtensionInfo(ArticleInfo model, WebLanguage language = WebLanguage.zh_cn) { if (!string.IsNullOrEmpty(model.LinkUrl)) { model.Url = model.LinkUrl; } else { model.Url = string.Format("{2}/{0}/{1}.html", "n", model.GUID.ToString().ToLower(), language == WebLanguage.zh_cn ? string.Empty : "/" + language.ToString()); } }
public ActionResult RenderSubNavForChannelPage(int siteId, int catId, string customTitle, WebLanguage language = WebLanguage.zh_cn) { StringBuilder sbNav = new StringBuilder(string.Format("<a href=\"/{1}\">{0}</a>", LanguageResourceHelper.GetString("channel-sub-nav-home-text", language), (language == WebLanguage.zh_cn ? string.Empty : language.ToString()) )); if (catId > 0) { var upList = CategoryService.ListUpById(siteId, catId); foreach (var item in upList) { sbNav.AppendFormat(" > {0}", CategoryLinkUrlHelper.BuildLink(item, language)); } } if (!string.IsNullOrEmpty(customTitle)) { sbNav.AppendFormat(" > {0}", customTitle); } return(Content(sbNav.ToString())); }