Esempio n. 1
0
        public ActionResult Index <T>(BasePage basePage) where T : BasePage
        {
            var currentNode  = Current.UmbracoHelper.AssignedContentItem;
            var redirectLink = currentNode.Value <Umbraco.Web.Models.Link>(DocumentTypes.BasePage.Fields.RedirectLink);

            if (!string.IsNullOrEmpty(redirectLink?.Url))
            {
                var url = redirectLink.Url.ToLower();
                if (!url.StartsWith("http"))
                {
                    url = url.Insert(0, "http://");
                }

                System.Web.HttpContext.Current.Response.Redirect(url);
            }

            try
            {
                basePage.HeaderConfiguration = _pageLayoutService.GetHeaderConfiguration(CurrentPage);
                basePage.FooterConfiguration = _pageLayoutService.GetFooterConfiguration(CurrentPage);
                basePage.Theme = _themeService.GetTheme(basePage.Content);
            }
            catch (AppSettingsException e)
            {
                Logger.Error(this.GetType(), e, $"{Umb.ToolBox.Models.Constants.AppConstants.LoggingPrefix} {e.Message}");
                throw e;
            }



            return(base.Index(basePage as T));
        }
Esempio n. 2
0
        public SearchResultModel PerformSearch(string term)
        {
            SearchResultModel result = null;

            try
            {
                // create the result object and assign the search term
                result = new SearchResultModel(Helper.AssignedContentItem)
                {
                    HeaderConfiguration = _pageLayoutService.GetHeaderConfiguration(),
                    FooterConfiguration = _pageLayoutService.GetFooterConfiguration(),
                    Term = term
                };
            }
            catch (AppSettingsException e)
            {
                _logger.Error(this.GetType(), e, $"{AppConstants.LoggingPrefix} {e.Message}");
                throw e;
            }

            var pages = new List <SearchResult>();

            if (ExamineManager.Instance.TryGetIndex("ExternalIndex", out var index))
            {
                // Get the searcher object to perform the search
                var searcher = index.GetSearcher();

                var results = searcher.CreateQuery("content").Field("contents", term.MultipleCharacterWildcard())
                              .Or()
                              .Field("pageTitle", term.MultipleCharacterWildcard())
                              .Or()
                              .Field("mainContent", term.MultipleCharacterWildcard())
                              .Or()
                              .Field(DocumentTypes.ArticlePage.Fields.Abstract, term.MultipleCharacterWildcard())
                              .OrderByDescending(new SortableField("updateDate", SortType.Long))
                              .Execute();

                foreach (var res in results)
                {
                    var node = Helper.Content(res.Id);

                    pages.Add(new SearchResult()
                    {
                        Url      = node.Url(),
                        Abstract = node.HasProperty(DocumentTypes.ArticlePage.Fields.Abstract) ? node.Value <string>(DocumentTypes.ArticlePage.Fields.Abstract) : string.Empty,
                        Title    = node.HasProperty(DocumentTypes.BasePage.Fields.PageTitle) ? node.Value <string>(DocumentTypes.BasePage.Fields.PageTitle) : string.Empty,
                        UrlTitle = node.Name
                    });
                }

                result.Results = pages;
                return(result);
            }

            throw new SearchException("ExternalIndex is not present");
        }
Esempio n. 3
0
 public ActionResult Index()
 {
     return(View("~/Views/Partials/Header.cshtml", _pageLayoutService.GetHeaderConfiguration()));
 }