Make PAge, Blog and custom content types creatable by default

--HG--
branch : dev
This commit is contained in:
Renaud Paquay
2010-07-22 18:58:24 -07:00
parent c40fe88002
commit ba8d52f6fb
6 changed files with 20 additions and 1 deletions

View File

@@ -1,8 +1,16 @@
namespace Orchard.Core.Contents.Settings {
using Orchard.ContentManagement.MetaData.Builders;
namespace Orchard.Core.Contents.Settings {
public class ContentTypeSettings {
/// <summary>
/// This setting is used to display a Content Type in Content Mamagement menu like
/// </summary>
public bool Creatable { get; set; }
}
public static class MetaDataExtensions {
public static ContentTypeDefinitionBuilder Creatable(this ContentTypeDefinitionBuilder builder, bool creatable = true) {
return builder.WithSetting(typeof(ContentTypeSettings).Name + ".Creatable", creatable.ToString());
}
}
}

View File

@@ -7,4 +7,5 @@ orchardversion: 0.5.0
features:
Orchard.ContentTypes:
Description: ContentTypes modules enables the creation and alteration of content types not based on code.
Dependencies: Contents
Category: Content

View File

@@ -126,6 +126,10 @@
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
<Name>Orchard.Framework</Name>
</ProjectReference>
<ProjectReference Include="..\..\Core\Orchard.Core.csproj">
<Project>{9916839C-39FC-4CEB-A5AF-89CA7E87119F}</Project>
<Name>Orchard.Core</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />

View File

@@ -7,6 +7,7 @@ using Orchard.ContentManagement.Drivers;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Models;
using Orchard.ContentTypes.ViewModels;
using Orchard.Core.Contents.Settings;
using Orchard.Localization;
namespace Orchard.ContentTypes.Services {
@@ -70,6 +71,7 @@ namespace Orchard.ContentTypes.Services {
var contentTypeDefinition = new ContentTypeDefinition(name, typeViewModel.DisplayName);
_contentDefinitionManager.StoreTypeDefinition(contentTypeDefinition);
_contentDefinitionManager.AlterTypeDefinition(name, cfg => cfg.Creatable());
return new EditTypeViewModel(contentTypeDefinition);
}

View File

@@ -8,4 +8,5 @@ description: The pages module enables the creation and management of pages on an
features:
Orchard.Pages:
Description: Simple pages.
Dependencies: Contents
Category: Content

View File

@@ -6,6 +6,7 @@ using Orchard.ContentManagement;
using Orchard.ContentManagement.MetaData;
using Orchard.Core.Common.Models;
using Orchard.Core.Common.Settings;
using Orchard.Core.Contents.Settings;
using Orchard.Core.Navigation.Models;
using Orchard.Core.Routable.Models;
using Orchard.Core.Settings.Descriptor.Records;
@@ -194,6 +195,7 @@ namespace Orchard.Setup.Services {
.WithPart("CommentsPart")
.WithPart("HasTags")
.WithPart("Localized")
.Creatable()
.Indexed());
contentDefinitionManager.AlterTypeDefinition("Page", cfg => cfg
.DisplayedAs("Page")
@@ -204,6 +206,7 @@ namespace Orchard.Setup.Services {
.WithPart("CommentsPart")
.WithPart("HasTags")
.WithPart("Localized")
.Creatable()
.Indexed());
contentDefinitionManager.AlterPartDefinition("BodyPart", cfg => cfg
.WithSetting("BodyPartSettings.FlavorDefault", BodyPartSettings.FlavorDefaultDefault));