public ActionResult SiteMapFooterNav() { var data = new NavViewModel(); data.SectionCode = ""; // irrelevant as not used var sql = new Sql("where ShowInMainNav=1 and parentpageid is null"); sql.AndIsActive <Page>(); var pages = PageList.Load(sql); foreach (var page in pages) { var item = new NavItem { PageID = page.ID, Title = page.GetNavTitle(), Url = page.GetFullUrl(), PageCode = page.PageCode, IsExternalUrl = page.LinkUrlIsExternal }; data.NavItems.Add(item); //item.SubPages = GetChildren(page, null).FindAll(p => p.); foreach (var childPage in page.ChildPages.Active) { if (childPage.ShowInMainNav) { item.SubPages.Add(new NavItem(childPage)); } } } return(View(data)); }
public ActionResult GetSitemapXML() { var sql = new Sql(); var topTenSql = new Sql(); var topTenRegionSql = new Sql(); var xmlPrefix = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; var xml = new HtmlTag("urlset"); xml.Add("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); xml.Add("xsi:schemaLocation", "http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"); xml.Add("xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9"); // get pages topTenSql = new Sql("select top 10 * from Page where 1=1"); topTenSql.AndIsActive <Models.Page>(); var topTenDeals = PageList.Load(topTenSql); // var cats = CategoryList.LoadActive(); // foreach (var cat in cats) { // AddSiteMapXmlLink(cat.GetUrl(), xml); // } // // var attractions = AttractionList.LoadActive(); // foreach (var attraction in attractions) { // AddSiteMapXmlLink(attraction.GetUrl(), xml); // } return(Content(xmlPrefix + xml.ToString(), "text/xml")); }
/* * /// <summary> * /// Render the primary naviation along the top * /// </summary> * /// <param name="sectionCode"></param> * /// <param name="currentPageID"></param> * /// <returns></returns> * public ActionResult MainNav(string sectionCode, int currentPageID) { * var data = new NavViewModel(); * data.SectionCode = sectionCode; * var sql = new Sql("where ShowInMainNav=1 and ParentPageID is null"); * sql.AndIsActive<Page>(); * sql.Paging(6); // get first 6 only * data.NavItems = PageList.Load(sql); * data.CurrentPageID = currentPageID; * return View(data); * } * * /// <summary> * /// Render the small nav in the corner at the very top * /// </summary> * /// <param name="sectionCode"></param> * /// <param name="currentPageID"></param> * /// <returns></returns> * public ActionResult SecondaryNav(string sectionCode, int currentPageID) { * var data = new NavViewModel(); * data.SectionCode = sectionCode; * data.CurrentPageID = currentPageID; * var sql = new Sql("where ShowInSecondaryNav=1"); * sql.AndIsActive<Page>(); * data.Pages = PageList.Load(sql); * return View(data); * } * * /* not used * /// <summary> * /// Render subnav (single level only) * /// </summary> * /// <param name="sectionCode"></param> * /// <param name="currentPageID"></param> * /// <returns></returns> * public ActionResult SubNavSingleLevel(string sectionCode, int currentPageID) { * var data = new NavViewModel(); * data.SectionCode = sectionCode; * data.CurrentPageID = currentPageID; * var currentTopPage = Models.Page.LoadByPageCode(sectionCode); * if (currentTopPage != null) { * data.Pages = currentTopPage.ChildPages.Active; * } * return View(data); * } */ // public ActionResult FooterNav(string sectionCode, int currentPageID) { public ActionResult FooterNav() { var data = new NavViewModel(); data.SectionCode = ""; // irrelevant as not used var sql = new Sql("where ShowInFooterNav=1"); sql.AndIsActive <Page>(); var pages = PageList.Load(sql); foreach (var page in pages) { if (true) { var item = new NavItem(page); data.NavItems.Add(item); } else { //all footers var item = new NavItem { PageID = page.ID, Title = page.GetNavTitle(), Url = page.GetFullUrl(), PageCode = page.PageCode, IsExternalUrl = page.LinkUrlIsExternal }; //item.SubPages = GetChildren(page, null).FindAll(p => p.); foreach (var childPage in page.ChildPages.Active) { if (childPage.ShowInFooterNav) { item.SubPages.Add(new NavItem(childPage)); if (childPage.ChildPages != null) { foreach (var subChildPage in childPage.ChildPages.Active) { if (subChildPage.ShowInFooterNav) { item.SubPages.Add(new NavItem(subChildPage)); } } } } } data.NavItems.Add(item); } } return(View("FooterNav", data)); }
// // GET: /Navigation/ /// <summary> /// Render primary navigation, including top level items and optionally also with first level of children underneath. /// This can be used for top navigation with dropdown menus. /// </summary> public ActionResult MainNav(string sectionCode, Page currentPage, bool includeChildren) { var data = new NavViewModel(); sectionCode = sectionCode + ""; data.SectionCode = sectionCode; var sql = new Sql("where ShowInMainNav=1 and ParentPageID is null"); sql.AndIsActive <Page>(); //var pages = PageList.Load(sql); var pages = PageCache.MainNav; foreach (var page in pages) { var item = new NavItem(page); if (page.ID == currentPage.SectionPageID) { item.IsSelected = true; //} else if (page.PageCode.IsNotBlank() && page.PageCode.ToLower()==sectionCode.ToLower()) { // item.IsSelected = true; } if (page.LinkUrlIsExternal) { item.IsExternalUrl = true; } if (includeChildren) { item.SubPages = GetChildren(page, sectionCode); } data.NavItems.Add(item); } // set css classes int selectedItemIndex = data.NavItems.FindIndex(item => item.IsSelected); if (selectedItemIndex > -1) { data.NavItems[selectedItemIndex].CssClass = "active"; } data.CurrentPageID = currentPage.ID; return(View(data)); }
public ActionResult SecondaryNav() { var data = new NavViewModel(); data.SectionCode = ""; // irrelevant as not used var sql = new Sql("where ShowInSecondaryNav=1"); sql.AndIsActive <Page>(); var pages = PageList.Load(sql); foreach (var page in pages) { var item = new NavItem(page); data.NavItems.Add(item); } if (data.NavItems.Count > 0) { data.NavItems[0].CssClass = "first"; } return(View("SecondaryNav", data)); }
public ActionResult SubNav(string sectionCode, Models.Page page) { var data = new NavViewModel(); //var sql = new Sql("where ParentPageID=", page.ID); var sql = new Sql(); if (page.ParentPageID != null) { sql.Add("where ParentPageID=", page.ParentPageID.Value); } else { sql.Add("where ParentPageID=", page.ID); } sql.AndIsActive <Page>(); var pages = PageList.Load(sql); foreach (var childPage in pages) { var item = new NavItem(childPage); if (childPage.ID == page.ID) { item.IsSelected = true; } data.NavItems.Add(item); } int selectedItemIndex = data.NavItems.FindIndex(item => item.IsSelected); if (selectedItemIndex > -1) { data.NavItems[selectedItemIndex].CssClass = "active"; } return(View(data)); }
public ActionResult Search(string searchText) { var data = new ViewModel(); data.ContentPage = Models.Page.LoadOrCreatePageCode("Search"); if (data.ContentPage == null) { throw new Exception("Search page not found"); } data.SearchText = searchText; data.SearchArea = String.IsNullOrEmpty(Web.Request["SearchArea"]) ? "All" : Web.Request["SearchArea"]; int itemsPerPage; if (data.SearchArea == "All") { itemsPerPage = 5; } else { itemsPerPage = 25; } string keywords = searchText; var search = new KeywordSearch(keywords); //#if pages if (searchText.IsNotBlank()) { /* if (data.SearchArea == "All" || data.SearchArea == "Pages") { * Sql sql = new Sql("select * from Page"); * sql.AddSql(search.FullTextJoin("page")); * sql.WhereIsActive<Page>(); * //sql.Add("and (rolesallowed is null)"); // if using page user access control * sql.Add("order by Rank desc,Title"); * sql.Paging(itemsPerPage); * data.PageResults = PageList.Load(sql); * data.Counter += sql.FetchCount(); * } * if (data.SearchArea == "All" || data.SearchArea == "Faqs") { * Sql sql = new Sql("select * from FAQItem"); * sql.AddSql(search.FullTextJoin("FAQItem")); * sql.WhereIsActive<FAQItem>(); * sql.Add("order by Rank,FAQTitle"); * sql.Paging(itemsPerPage); * data.FaqItems = FAQItemList.Load(sql); * data.Counter += sql.FetchCount(); * }*/ //if (data.SearchArea == "All" || data.SearchArea == "News") { // Sql sql = new Sql("select * from News"); // sql.AddSql(search.FullTextJoin("News")); // //sql.WhereIsActive<News>(); // sql.Add("order by Rank,Source"); // sql.Paging(itemsPerPage); // //data.NewsItems = NewsList.Load(sql); // data.Counter += sql.FetchCount(); //} //if (data.SearchArea == "All" || data.SearchArea == "Products") { // Sql sql = new Sql("select * from Product"); // sql.AddSql(search.FullTextJoin("Product")); // //sql.WhereIsActive<Product>(); // sql.Add("order by Rank desc,Title"); // sql.Paging(itemsPerPage); // //data.ProductItems = ProductList.Load(sql); // data.Counter += sql.FetchCount(); //} } data.NumPages = Html.CalcPageCount(data.Counter, itemsPerPage); // note: for full text search, instead use var keywordSearch = new Beweb.KeywordSearch(searchText); var columns = keywordSearch.GetSqlFullTextWhereForTable("Page"); if (columns.IsNotBlank()) { var sql = new Sql("select * from Page where 1=1"); sql.Add("and historypageid is null"); // if page revisions sql.AddRawSqlString(columns); sql.AndIsActive <Page>(); data.PageResults = PageList.Load(sql); } columns = keywordSearch.GetSqlFullTextWhereForTable("Event"); if (columns.IsNotBlank()) { var sql = new Sql("select * from event where 1=1"); sql.AddRawSqlString(columns); sql.AndIsActive <Event>(); data.EventResults = EventList.Load(sql); } columns = keywordSearch.GetSqlFullTextWhereForTable("News"); if (columns.IsNotBlank()) { var sql = new Sql("select * from News where 1=1"); sql.AddRawSqlString(keywordSearch.GetSqlFullTextWhereForTable("News")); sql.AndIsActive <News>(); data.NewsResults = NewsList.Load(sql); } //#endif return(View("SearchResults", data)); }