Monday, 15 February 2016

Orchard Hosting Tips: How to add culture picker in Orchard v.1.8.0.0+(MultiLanguage support)?

Leave a Comment
In this BestWindowsHostingASP.NET's Tutorial, Install Localization-Version 1.6 and Culture Picker - Version 1.6.0.0. following features are enabled Localization,culture picker,culture picker main menu filtering, culture picker content filtering, culture picker home page auto redirect.


If Orchard.CulturePicker project not load references like Orchard.Alias,Orchard.Core etc, modify
target framework.

Add Orchard.Content picker reference to Orchard.CulturePicker. Modify: LocalizableMainMenuNavigationFilter class it is placed under Orchard.CulturePicker\Services\ LocalizableMainMenuNavigationFilter.cs then replace this class with below code.
using System.Collections.Generic;
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects;
using Orchard.Core.Navigation.Models;
using Orchard.Environment.Extensions;
using Orchard.Localization.Services;
using Orchard.UI.Navigation;
using Orchard.ContentPicker.Models;
namespace Orchard.CulturePicker.Services {
[UsedImplicitly]
[OrchardFeature("Orchard.CulturePicker.MainMenu")]
public class LocalizableMainMenuNavigationFilter : INavigationFilter {
private readonly ICultureManager _cultureManager;
private readonly IWorkContextAccessor _workContextAccessor;

public LocalizableMainMenuNavigationFilter(ICultureManager cultureManager, IWorkContextAccessor workContextAccessor) {
_cultureManager = cultureManager;
_workContextAccessor = workContextAccessor;
}

#region INavigationFilter Members

public IEnumerable<MenuItem> Filter(IEnumerable<MenuItem> menuItems) {
string currentCulture = _cultureManager.GetCurrentCulture(_workContextAccessor.GetContext().HttpContext);
foreach (MenuItem menuItem in menuItems) {
ILocalizableAspect localizationPart = menuItem.Content.Is<ContentMenuItemPart>()
      ? menuItem.Content.As<ContentMenuItemPart>().Content.As<ILocalizableAspect>()
      : menuItem.Content.As<ILocalizableAspect>();
if (localizationPart == null
|| localizationPart.Culture == null
|| localizationPart.Culture == currentCulture)
yield return menuItem;
}
}

#endregion
}
}

Add culture picker widget through Widgets from admin panel.

Best Orchard Hosting Recommendation

One of the most important things when choosing a good Orchard hosting is the feature and reliability. HostForLIFE is the leading provider of Windows hosting and affordable Orchard, their servers are optimized for PHP web applications such as the latest Orchard version. The performance and the uptime of the hosting service are excellent and the features of the web hosting plan are even greater than what many hosting providers ask you to pay for. 

At HostForLIFE.eu, customers can also experience fast Orchard hosting. The company invested a lot of money to ensure the best and fastest performance of the datacenters, servers, network and other facilities. Its datacenters are equipped with the top equipments like cooling system, fire detection, high speed Internet connection, and so on. That is why HostForLIFE.eu guarantees 99.9% uptime for Orchard. And the engineers do regular maintenance and monitoring works to assure its Orchard hosting are security and always up. 

http://hostforlife.eu

0 comments:

Post a Comment