mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Update FrontEndCultureSelector shape template to accommodate home alias changes.
This commit is contained in:
@@ -1,16 +1,15 @@
|
|||||||
@using System.Globalization
|
@using System.Globalization
|
||||||
@using Orchard.Alias
|
@using Orchard.Autoroute.Services
|
||||||
@using Orchard.ContentManagement
|
@using Orchard.ContentManagement
|
||||||
@using Orchard.ContentManagement.Aspects
|
@using Orchard.ContentManagement.Aspects
|
||||||
@using Orchard.Localization.Services
|
@using Orchard.Localization.Services
|
||||||
@{
|
@{
|
||||||
var localizableAspects = Enumerable.Empty<ILocalizableAspect>();
|
var localizableAspects = Enumerable.Empty<ILocalizableAspect>();
|
||||||
|
var homePage = WorkContext.Resolve<IHomeAliasService>().GetHomePage();
|
||||||
var homePage = GetByPath(string.Empty);
|
|
||||||
|
|
||||||
if (homePage != null) {
|
if (homePage != null) {
|
||||||
var localizationService = WorkContext.Resolve<ILocalizationService>();
|
var localizationService = WorkContext.Resolve<ILocalizationService>();
|
||||||
localizableAspects = localizationService.GetLocalizations(homePage).Concat<ILocalizableAspect>(new[] { homePage.As<ILocalizableAspect>() });
|
localizableAspects = localizationService.GetLocalizations(homePage).Concat(new[] { homePage.As<ILocalizableAspect>() });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@if (localizableAspects.Any()) {
|
@if (localizableAspects.Any()) {
|
||||||
@@ -31,21 +30,3 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@functions{
|
|
||||||
public IContent GetByPath(string aliasPath) {
|
|
||||||
var contentRouting = WorkContext.Resolve<IAliasService>().Get(aliasPath);
|
|
||||||
|
|
||||||
if (contentRouting == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
object id;
|
|
||||||
if (contentRouting.TryGetValue("id", out id)) {
|
|
||||||
int contentId;
|
|
||||||
if (int.TryParse(id as string, out contentId)) {
|
|
||||||
return WorkContext.Resolve<IContentManager>().Get(contentId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user