Store default location for the "HasTags" part in initial settings

--HG--
branch : dev
This commit is contained in:
Renaud Paquay
2010-07-21 21:36:38 -07:00
parent 12c17cdccb
commit 6586116004
2 changed files with 17 additions and 7 deletions

View File

@@ -1,4 +1,9 @@
using Orchard.Data.Migration;
using System.Collections.Generic;
using Orchard.ContentManagement.Drivers;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Builders;
using Orchard.Data.Migration;
using Orchard.Tags.Models;
namespace Orchard.Tags.DataMigrations {
public class TagsDataMigration : DataMigrationImpl {
@@ -19,5 +24,13 @@ namespace Orchard.Tags.DataMigrations {
return 1;
}
public int UpdateFrom1() {
ContentDefinitionManager.AlterPartDefinition(typeof(HasTags).Name, cfg => cfg
.WithLocation(new Dictionary<string, ContentLocation> {
{"Default", new ContentLocation { Zone = "primary", Position = "49" }},
{"Editor", new ContentLocation { Zone = "primary", Position = "9" }},
}));
return 2;
}
}
}

View File

@@ -24,8 +24,7 @@ namespace Orchard.Tags.Drivers {
public virtual IUser CurrentUser { get; set; }
protected override DriverResult Display(HasTags part, string displayType) {
var location = part.GetLocation(displayType, "primary", "49");
return ContentPartTemplate(part, "Parts/Tags.ShowTags").Location(location);
return ContentPartTemplate(part, "Parts/Tags.ShowTags").Location(part.GetLocation(displayType));
}
protected override DriverResult Editor(HasTags part) {
@@ -35,8 +34,7 @@ namespace Orchard.Tags.Drivers {
var model = new EditTagsViewModel {
Tags = string.Join(", ", part.CurrentTags.Select((t, i) => t.TagName).ToArray())
};
var location = part.GetLocation("Editor", "primary", "9");
return ContentPartTemplate(model, "Parts/Tags.EditTags").Location(location);
return ContentPartTemplate(model, "Parts/Tags.EditTags").Location(part.GetLocation("Editor"));
}
protected override DriverResult Editor(HasTags part, IUpdateModel updater) {
@@ -51,8 +49,7 @@ namespace Orchard.Tags.Drivers {
_tagService.UpdateTagsForContentItem(part.ContentItem.Id, tagNames);
}
var location = part.GetLocation("Editor", "primary", "9");
return ContentPartTemplate(model, "Parts/Tags.EditTags").Location(location);
return ContentPartTemplate(model, "Parts/Tags.EditTags").Location(part.GetLocation("Editor"));
}
}
}