diff --git a/webapp-net/Search/Controllers/TridionDocsSearchController.cs b/webapp-net/Search/Controllers/TridionDocsSearchController.cs index 7f36981db..20aa30557 100644 --- a/webapp-net/Search/Controllers/TridionDocsSearchController.cs +++ b/webapp-net/Search/Controllers/TridionDocsSearchController.cs @@ -196,7 +196,7 @@ private SearchResultSet BuildResultSet(FacetedSearchResults facetedSearchResults PublicationTitle = result.Node.Search.PublicationTitle, Meta = result.Node.Search.Fields, Highlighted = result.Node.Search.Highlighted, - ItemType = result.Node.Search.ItemType + ItemType = (result.Node.Search.ItemType == Sdl.Tridion.Api.Client.ItemType.Binary)? "binary":"Page" }; searchResultSet.QueryResults.Add(searchResult); diff --git a/webapp-net/Search/Providers/OpenSearchProvider.cs b/webapp-net/Search/Providers/OpenSearchProvider.cs index c5af645ab..96f5ca09b 100644 --- a/webapp-net/Search/Providers/OpenSearchProvider.cs +++ b/webapp-net/Search/Providers/OpenSearchProvider.cs @@ -65,8 +65,7 @@ protected virtual SearchItem MapResult(SearchResult result, Type modelType, stri SearchItem searchItem = (SearchItem)Activator.CreateInstance(modelType); searchItem.MvcData = new MvcData(viewName); searchItem.Id = result.Id; - //searchItem.Title = GetContentTitle(result.Id.Replace("_", ":"), result.PageTitle); - searchItem.Title = result.PageTitle; + searchItem.Title = GetPageModelTitle(result.Id.Replace("_", ":"), result.PageTitle); searchItem.Url = result.Url; searchItem.Summary = GetTrimmedContent(result.Highlighted.Contains(contentLanguageFilter) ? result.Highlighted[contentLanguageFilter].ToString() : result.Content); searchItem.CustomFields = new Dictionary(); @@ -93,7 +92,7 @@ public static string GetTrimmedContent(string content) private string GetLanguage(string language) => string.IsNullOrEmpty(language) ? _defaultLanguage : CultureInfo.GetCultureInfo(language.Split('-')[0]).EnglishName.ToLower(); - private string GetContentTitle(string pageUri, string pageTitle) + private string GetPageModelTitle(string pageUri, string pageTitle) { if (string.IsNullOrEmpty(pageUri)) { return string.Empty; } @@ -106,36 +105,26 @@ private string GetContentTitle(string pageUri, string pageTitle) { return pageTitle; } - HashSet validRegionNames = new HashSet { "Main" }; - foreach (var regions in pageModel.Regions) + + IDictionary coreResources = WebRequestContext.Localization.GetResources("core"); + + string separator = string.Empty; + if (coreResources.Contains("core.pageTitleSeparator")) { - if (validRegionNames.Contains(regions.Name) && regions.Entities.Any()) - { - foreach (var entity in regions.Entities) - { - if (entity != null) - { - Type entityType = entity.GetType(); - - // Check if the entity is of type Article using reflection - if (entityType.FullName == "Sdl.Web.Modules.Core.Models.Article") - { - PropertyInfo headlineProperty = entityType.GetProperty("Headline"); - if (headlineProperty != null) - { - object headlineValue = headlineProperty.GetValue(entity); - if (headlineValue != null) - { - return headlineValue.ToString(); - } - } - } - } - } - } + separator = coreResources["core.pageTitleSeparator"].ToString(); } - return pageTitle; + string suffix = string.Empty; + if (coreResources.Contains("core.pageTitlePostfix")) + { + suffix = coreResources["core.pageTitlePostfix"].ToString(); + } + + string replaceTitleSeparatorPostix = $"{separator}{suffix}"; + + string title = pageModel.Title.Replace(replaceTitleSeparatorPostix, ""); + + return title; } protected virtual NameValueCollection SetupParameters(SearchQuery searchQuery, Localization localization)