public static PageHeaderModel HeaderModel(this IHtmlHelper helper) { PageHeaderModel model = helper.GetViewData <PageHeaderModel>(); if (model == null) { model = new PageHeaderModel { Title = helper.GetPageTitle(), AddButton = null, }; if (helper.GetViewParams().ListUrl != null) { string id = RazorUtils.UrlToPageId(helper.GetViewParams().ListUrl); model.ListBreadCrumb = new BreadCrumbModel { Title = helper.Page(id), Link = helper.GetViewParams().ListUrl }; } string addUrl = helper.GetViewParams().AddUrl; if (addUrl != null) { model.AddButton = helper.AddButton(addUrl); model.EmbeddedAddButton = helper.AddButton(addUrl, "buttonGra-sm"); model.IsListPage = true; } helper.SetViewData(model); } return(model); }
public ViewViewComponentResult Invoke(string linkUp, string linkPage) { var model = new PageHeaderModel { linkUp = linkUp, linkPage = linkPage }; return(View(model)); }
/// <summary> /// Get the default menu items and other settings /// </summary> /// <returns></returns> public ActionResult Index() { //get the current context var contextItem = RenderingContext.Current.ContextItem; //get the master database to use to get items from var database = contextItem.Database; //create a new model var model = new PageHeaderModel(); //get the project settings id from the config, to use to get the logo image from var projectSettingsPageId = _standardHelpers.GetItemIdFromConfig("ProjectSettingsPageID", contextItem); if (projectSettingsPageId != ID.Null) { var projectSettingsPage = database.GetItem(projectSettingsPageId); if (projectSettingsPage != null) { //get the project settings template id from the config var projectSettingsTemplateId = _standardHelpers.GetTemplateIdFromConfig("ProjectSettingsTemplateID", contextItem); //check if the project settings page uses that template var isProjectSettingsTemplate = projectSettingsPage.TemplateID == projectSettingsTemplateId; if (isProjectSettingsTemplate) { model.LogoImage = new HtmlString(FieldRenderer.Render(projectSettingsPage, "Project_Logo", "mw=400")); } } } // get the homepage id set in the config to use to get the menu items var homePageId = _standardHelpers.GetItemIdFromConfig("HomePageID", contextItem); if (homePageId != ID.Null) { //get the home item from the config id var homePage = database.GetItem(homePageId); //check if the home item in not null if (homePage != null) { //check if the homepage's template is the same as the one set in our config var homeTemplateId = _standardHelpers.GetTemplateIdFromConfig("HomeTemplateID", contextItem); var isHomePageTemplate = homePage.TemplateID == homeTemplateId; //if the homepage template matches then we can now use it to get the navigation items if (isHomePageTemplate) { //add the verified home page to the model model.HomePageUrl = LinkManager.GetItemUrl(homePage); //get the home page item and add it to the menu items from the verified home page model.MenuItems.Add(_navigationHelpers.CreateSiteMenuModel(homePage, false)); //get the home page children and add them to the menu items if (homePage.HasChildren) { foreach (Item childPage in homePage.Children) { //get the child page items from the verified home page model.MenuItems.Add(_navigationHelpers.CreateSiteMenuModel(childPage, true)); } } } } } //get the site's languages for the dropdown language selector model.CurrentLanguage = _languageHelpers.GetActiveLanguageModel(); model.Languages = _languageHelpers.GetAllLanguages(); return(View(model)); }
public static IHtmlContent BreadCrumbs(this IHtmlHelper helper, PageHeaderModel model) { return(helper.GetComponent("Components/BreadCrumbs", model)); }