mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
#19680: Fixing taxonomy menu item orderinf
Work Item: 19680 --HG-- branch : 1.x
This commit is contained in:
@@ -149,7 +149,7 @@ namespace Orchard.Taxonomies.Controllers {
|
||||
}
|
||||
|
||||
parentTerm.Position++;
|
||||
term.Weight = parentTerm.Position;
|
||||
term.Weight = 10 - parentTerm.Position;
|
||||
|
||||
term.Container = parentTerm.Term == null ? taxonomy.ContentItem : parentTerm.Term.ContentItem;
|
||||
|
||||
|
@@ -56,7 +56,7 @@ namespace Orchard.Taxonomies.Drivers {
|
||||
|
||||
// if no taxonomy is selected, take the first available one as
|
||||
// the terms drop down needs one by default
|
||||
if (model.SelectedTaxonomyId == -1) {
|
||||
if (model.SelectedTaxonomyId <= 0) {
|
||||
var firstTaxonomy = taxonomies.FirstOrDefault();
|
||||
if (firstTaxonomy != null) {
|
||||
model.SelectedTaxonomyId = firstTaxonomy.Id;
|
||||
|
@@ -1,4 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Taxonomies.Models;
|
||||
@@ -9,11 +11,11 @@ namespace Orchard.Taxonomies.Navigation {
|
||||
/// <summary>
|
||||
/// Dynamically injects query results as menu items on NavigationQueryMenuItem elements
|
||||
/// </summary>
|
||||
public class NavigationQueryProvider : INavigationFilter {
|
||||
public class TaxonomyNavigationProvider : INavigationFilter {
|
||||
private readonly IContentManager _contentManager;
|
||||
private readonly ITaxonomyService _taxonomyService;
|
||||
|
||||
public NavigationQueryProvider(
|
||||
public TaxonomyNavigationProvider(
|
||||
IContentManager contentManager,
|
||||
ITaxonomyService taxonomyService) {
|
||||
_contentManager = contentManager;
|
||||
@@ -31,10 +33,12 @@ namespace Orchard.Taxonomies.Navigation {
|
||||
var rootTerm = _taxonomyService.GetTerm(taxonomyNavigationPart.TermId);
|
||||
|
||||
var allTerms = rootTerm != null
|
||||
? _taxonomyService.GetChildren(rootTerm)
|
||||
: _taxonomyService.GetTerms(taxonomyNavigationPart.TaxonomyId);
|
||||
? _taxonomyService.GetChildren(rootTerm).ToArray()
|
||||
: _taxonomyService.GetTerms(taxonomyNavigationPart.TaxonomyId).ToArray();
|
||||
|
||||
var menuPosition = item.Position;
|
||||
var rootPath = rootTerm == null ? "" : rootTerm.FullPath;
|
||||
|
||||
foreach (var contentItem in allTerms) {
|
||||
if (contentItem != null) {
|
||||
var part = contentItem;
|
||||
@@ -42,6 +46,8 @@ namespace Orchard.Taxonomies.Navigation {
|
||||
var menuText = _contentManager.GetItemMetadata(part).DisplayText;
|
||||
var routes = _contentManager.GetItemMetadata(part).DisplayRouteValues;
|
||||
|
||||
var positions = contentItem.FullPath.Substring(rootPath.Length).Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).Select(x => allTerms.First(t => t.Id == Int32.Parse(x)).Weight).ToArray();
|
||||
|
||||
var inserted = new MenuItem {
|
||||
Text = new LocalizedString(menuText),
|
||||
IdHint = item.IdHint,
|
||||
@@ -52,7 +58,7 @@ namespace Orchard.Taxonomies.Navigation {
|
||||
RouteValues = routes,
|
||||
LocalNav = item.LocalNav,
|
||||
Items = new MenuItem[0],
|
||||
Position = menuPosition + contentItem.Path.TrimEnd('/').Replace("/", "."),
|
||||
Position = menuPosition + ":" + String.Join(".", positions.Select(x => x.ToString()).ToArray()),
|
||||
Permissions = item.Permissions,
|
||||
Content = part
|
||||
};
|
||||
|
Reference in New Issue
Block a user