mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-12-03 12:03:51 +08:00
Adding MenuItemLink alternates
--HG-- branch : 1.x
This commit is contained in:
@@ -8,5 +8,9 @@
|
|||||||
/// Used to determine if this content type supports draft versions
|
/// Used to determine if this content type supports draft versions
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Draftable { get; set; }
|
public bool Draftable { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Defines the stereotype of the type
|
||||||
|
/// </summary>
|
||||||
|
public string Stereotype { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,6 +60,16 @@ namespace Orchard.Core.Navigation {
|
|||||||
.Column<bool>("OnAdminMenu")
|
.Column<bool>("OnAdminMenu")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
ContentDefinitionManager.AlterTypeDefinition("HtmlMenuItem", cfg => cfg
|
||||||
|
.WithPart("MenuPart")
|
||||||
|
.WithPart("BodyPart")
|
||||||
|
.WithPart("CommonPart")
|
||||||
|
.DisplayedAs("Html Menu Item")
|
||||||
|
.WithSetting("Description", "Renders some custom HTML in the menu.")
|
||||||
|
.WithSetting("BodyPartSettings.FlavorDefault", "html")
|
||||||
|
.WithSetting("Stereotype", "MenuItem")
|
||||||
|
);
|
||||||
|
|
||||||
ContentDefinitionManager.AlterPartDefinition("AdminMenuPart", builder => builder.Attachable());
|
ContentDefinitionManager.AlterPartDefinition("AdminMenuPart", builder => builder.Attachable());
|
||||||
|
|
||||||
return 3;
|
return 3;
|
||||||
@@ -112,6 +122,16 @@ namespace Orchard.Core.Navigation {
|
|||||||
.AlterTable("MenuPartRecord", table => table.AddColumn<int>("MenuRecord_id"))
|
.AlterTable("MenuPartRecord", table => table.AddColumn<int>("MenuRecord_id"))
|
||||||
;
|
;
|
||||||
|
|
||||||
|
ContentDefinitionManager.AlterTypeDefinition("HtmlMenuItem", cfg => cfg
|
||||||
|
.WithPart("MenuPart")
|
||||||
|
.WithPart("BodyPart")
|
||||||
|
.WithPart("CommonPart")
|
||||||
|
.DisplayedAs("Html Menu Item")
|
||||||
|
.WithSetting("Description", "Renders some custom HTML in the menu.")
|
||||||
|
.WithSetting("BodyPartSettings.FlavorDefault", "html")
|
||||||
|
.WithSetting("Stereotype", "MenuItem")
|
||||||
|
);
|
||||||
|
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
using System.Web;
|
using System.Web;
|
||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
using Orchard.ContentManagement.Aspects;
|
|
||||||
using Orchard.Core.Common.Models;
|
|
||||||
using Orchard.Core.Navigation.Models;
|
using Orchard.Core.Navigation.Models;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
using Orchard.UI.Navigation;
|
using Orchard.UI.Navigation;
|
||||||
@@ -26,9 +24,9 @@ namespace Orchard.Core.Navigation.Services {
|
|||||||
var part = menuPart;
|
var part = menuPart;
|
||||||
|
|
||||||
if (part.Is<MenuItemPart>())
|
if (part.Is<MenuItemPart>())
|
||||||
builder.Add(new LocalizedString(HttpUtility.HtmlEncode(part.MenuText)), part.MenuPosition, item => item.Url(part.As<MenuItemPart>().Url));
|
builder.Add(new LocalizedString(HttpUtility.HtmlEncode(part.MenuText)), part.MenuPosition, item => item.Url(part.As<MenuItemPart>().Url).Content(part));
|
||||||
else
|
else
|
||||||
builder.Add(new LocalizedString(HttpUtility.HtmlEncode(part.MenuText)), part.MenuPosition, item => item.Action(_contentManager.GetItemMetadata(part.ContentItem).DisplayRouteValues));
|
builder.Add(new LocalizedString(HttpUtility.HtmlEncode(part.MenuText)), part.MenuPosition, item => item.Action(_contentManager.GetItemMetadata(part.ContentItem).DisplayRouteValues).Content(part));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,7 +107,7 @@
|
|||||||
.menu-items-zone {
|
.menu-items-zone {
|
||||||
background:#F3F4F5;
|
background:#F3F4F5;
|
||||||
border:1px solid #E4E5E6;
|
border:1px solid #E4E5E6;
|
||||||
padding:5px;
|
padding:0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu-items-zone h2 {
|
.menu-items-zone h2 {
|
||||||
@@ -118,8 +118,9 @@
|
|||||||
.menu-items-zone li {
|
.menu-items-zone li {
|
||||||
background:#FFF;
|
background:#FFF;
|
||||||
border:1px solid #EAEAEA;
|
border:1px solid #EAEAEA;
|
||||||
|
margin: 2px;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
padding-right:60px;
|
padding-right:65px;
|
||||||
display: block;
|
display: block;
|
||||||
position:relative;
|
position:relative;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ else {
|
|||||||
<label for="MenuText">@T("Menu text")</label>
|
<label for="MenuText">@T("Menu text")</label>
|
||||||
@Html.TextBoxFor(m => m.MenuText, new { @class = "textMedium", autofocus = "autofocus" })
|
@Html.TextBoxFor(m => m.MenuText, new { @class = "textMedium", autofocus = "autofocus" })
|
||||||
<span class="hint">@T("The text that should appear in the menu.")</span>
|
<span class="hint">@T("The text that should appear in the menu.")</span>
|
||||||
|
@Html.HiddenFor(m => m.OnMenu, true)
|
||||||
|
@Html.HiddenFor(m => m.CurrentMenuId, Request["menuId"])
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<span class="raw">@Html.Raw(Model.Content.BodyPart.Text)</span>
|
||||||
@@ -525,6 +525,9 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Shapes\Views\MenuItemLink.cshtml" />
|
<Content Include="Shapes\Views\MenuItemLink.cshtml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="Navigation\Views\MenuItemLink-HtmlMenuItem.cshtml" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
|||||||
@@ -94,6 +94,18 @@ namespace Orchard.Core.Shapes {
|
|||||||
menuItem.Metadata.Alternates.Add("MenuItem__" + menu.MenuName);
|
menuItem.Metadata.Alternates.Add("MenuItem__" + menu.MenuName);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
builder.Describe("MenuItemLink")
|
||||||
|
.OnDisplaying(displaying => {
|
||||||
|
var menuItem = displaying.Shape;
|
||||||
|
var menu = menuItem.Menu;
|
||||||
|
menuItem.Metadata.Alternates.Add("MenuItemLink__" + menu.MenuName);
|
||||||
|
|
||||||
|
string contentType = menuItem.Content.ContentItem.ContentType;
|
||||||
|
if(contentType != null) {
|
||||||
|
menuItem.Metadata.Alternates.Add("MenuItemLink__" + contentType);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
builder.Describe("LocalMenu")
|
builder.Describe("LocalMenu")
|
||||||
.OnDisplaying(displaying => {
|
.OnDisplaying(displaying => {
|
||||||
var menu = displaying.Shape;
|
var menu = displaying.Shape;
|
||||||
|
|||||||
@@ -59,6 +59,7 @@
|
|||||||
<Compile Include="Services\ContentDefinitionService.cs" />
|
<Compile Include="Services\ContentDefinitionService.cs" />
|
||||||
<Compile Include="Services\IContentDefinitionService.cs" />
|
<Compile Include="Services\IContentDefinitionService.cs" />
|
||||||
<Compile Include="ViewModels\AddFieldViewModel.cs" />
|
<Compile Include="ViewModels\AddFieldViewModel.cs" />
|
||||||
|
<Compile Include="ViewModels\ContentTypeSettingsViewModel.cs" />
|
||||||
<Compile Include="ViewModels\EditFieldNameViewModel.cs" />
|
<Compile Include="ViewModels\EditFieldNameViewModel.cs" />
|
||||||
<Compile Include="ViewModels\CreatePartViewModel.cs" />
|
<Compile Include="ViewModels\CreatePartViewModel.cs" />
|
||||||
<Compile Include="ViewModels\EditFieldViewModel.cs" />
|
<Compile Include="ViewModels\EditFieldViewModel.cs" />
|
||||||
@@ -122,7 +123,7 @@
|
|||||||
<Content Include="Views\Admin\EditField.cshtml" />
|
<Content Include="Views\Admin\EditField.cshtml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Views\DefinitionTemplates\ContentTypeSettings.cshtml" />
|
<Content Include="Views\DefinitionTemplates\ContentTypeSettingsViewModel.cshtml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
using Orchard.ContentManagement.MetaData;
|
using Orchard.ContentManagement.MetaData;
|
||||||
using Orchard.ContentManagement.MetaData.Builders;
|
using Orchard.ContentManagement.MetaData.Builders;
|
||||||
using Orchard.ContentManagement.MetaData.Models;
|
using Orchard.ContentManagement.MetaData.Models;
|
||||||
using Orchard.ContentManagement.ViewModels;
|
using Orchard.ContentManagement.ViewModels;
|
||||||
|
using Orchard.ContentTypes.ViewModels;
|
||||||
using Orchard.Core.Contents.Extensions;
|
using Orchard.Core.Contents.Extensions;
|
||||||
using Orchard.Core.Contents.Settings;
|
using Orchard.Core.Contents.Settings;
|
||||||
|
|
||||||
@@ -11,15 +13,26 @@ namespace Orchard.ContentTypes.Settings {
|
|||||||
public class EditorEvents : ContentDefinitionEditorEventsBase {
|
public class EditorEvents : ContentDefinitionEditorEventsBase {
|
||||||
|
|
||||||
public override IEnumerable<TemplateViewModel> TypeEditor(ContentTypeDefinition definition) {
|
public override IEnumerable<TemplateViewModel> TypeEditor(ContentTypeDefinition definition) {
|
||||||
var model = definition.Settings.GetModel<ContentTypeSettings>();
|
var settings = definition.Settings.GetModel<ContentTypeSettings>();
|
||||||
|
var model = new ContentTypeSettingsViewModel {
|
||||||
|
Creatable = settings.Creatable,
|
||||||
|
Draftable = settings.Draftable,
|
||||||
|
};
|
||||||
|
|
||||||
|
if(definition.Settings.ContainsKey("Stereotype")) {
|
||||||
|
model.Stereotype = definition.Settings["Stereotype"] ?? String.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
yield return DefinitionTemplate(model);
|
yield return DefinitionTemplate(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IEnumerable<TemplateViewModel> TypeEditorUpdate(ContentTypeDefinitionBuilder builder, IUpdateModel updateModel) {
|
public override IEnumerable<TemplateViewModel> TypeEditorUpdate(ContentTypeDefinitionBuilder builder, IUpdateModel updateModel) {
|
||||||
var model = new ContentTypeSettings();
|
var model = new ContentTypeSettingsViewModel();
|
||||||
updateModel.TryUpdateModel(model, "ContentTypeSettings", null, null);
|
updateModel.TryUpdateModel(model, "ContentTypeSettingsViewModel", null, null);
|
||||||
|
|
||||||
builder.Creatable(model.Creatable);
|
builder.Creatable(model.Creatable);
|
||||||
builder.Draftable(model.Draftable);
|
builder.Draftable(model.Draftable);
|
||||||
|
builder.WithSetting("Stereotype", model.Stereotype);
|
||||||
|
|
||||||
yield return DefinitionTemplate(model);
|
yield return DefinitionTemplate(model);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
namespace Orchard.ContentTypes.ViewModels {
|
||||||
|
public class ContentTypeSettingsViewModel {
|
||||||
|
public bool Creatable { get; set; }
|
||||||
|
public bool Draftable{ get; set; }
|
||||||
|
public string Stereotype { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
@model Orchard.Core.Contents.Settings.ContentTypeSettings
|
@model Orchard.ContentTypes.ViewModels.ContentTypeSettingsViewModel
|
||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
@Html.EditorFor(m => m.Creatable)
|
@Html.EditorFor(m => m.Creatable)
|
||||||
@@ -13,3 +13,10 @@
|
|||||||
@Html.ValidationMessageFor(m => m.Draftable)
|
@Html.ValidationMessageFor(m => m.Draftable)
|
||||||
<span class="hint">@T("Determines if this content type supports draft versions.")</span>
|
<span class="hint">@T("Determines if this content type supports draft versions.")</span>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<label for="@Html.FieldIdFor(m => m.Stereotype)">@T("Stereotype")</label>
|
||||||
|
@Html.TextBoxFor(m => m.Stereotype, new { @class = "textMedium"})
|
||||||
|
@Html.ValidationMessageFor(m => m.Stereotype)
|
||||||
|
<span class="hint">@T("(Optional) The stereotype of the content type. e.g., Widget, MenuItem, ...")</span>
|
||||||
|
</fieldset>
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Web.Routing;
|
using System.Web.Routing;
|
||||||
|
using Orchard.ContentManagement;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
using Orchard.Security.Permissions;
|
using Orchard.Security.Permissions;
|
||||||
|
|
||||||
@@ -24,6 +25,7 @@ namespace Orchard.UI.Navigation {
|
|||||||
public RouteValueDictionary RouteValues { get; set; }
|
public RouteValueDictionary RouteValues { get; set; }
|
||||||
public IEnumerable<MenuItem> Items { get; set; }
|
public IEnumerable<MenuItem> Items { get; set; }
|
||||||
public IEnumerable<Permission> Permissions { get; set; }
|
public IEnumerable<Permission> Permissions { get; set; }
|
||||||
|
public IContent Content { get; set; }
|
||||||
public IList<string> Classes {
|
public IList<string> Classes {
|
||||||
get { return _classes; }
|
get { return _classes; }
|
||||||
set {
|
set {
|
||||||
|
|||||||
@@ -151,7 +151,8 @@ namespace Orchard.UI.Navigation {
|
|||||||
.RouteValues(menuItem.RouteValues)
|
.RouteValues(menuItem.RouteValues)
|
||||||
.Item(menuItem)
|
.Item(menuItem)
|
||||||
.Menu(menu)
|
.Menu(menu)
|
||||||
.Parent(parentShape);
|
.Parent(parentShape)
|
||||||
|
.Content(menuItem.Content);
|
||||||
|
|
||||||
foreach (var className in menuItem.Classes)
|
foreach (var className in menuItem.Classes)
|
||||||
menuItemShape.Classes.Add(className);
|
menuItemShape.Classes.Add(className);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Web.Routing;
|
using System.Web.Routing;
|
||||||
|
using Orchard.ContentManagement;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
using Orchard.Security.Permissions;
|
using Orchard.Security.Permissions;
|
||||||
|
|
||||||
@@ -26,11 +27,17 @@ namespace Orchard.UI.Navigation {
|
|||||||
_item.MenuId = menuId;
|
_item.MenuId = menuId;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NavigationItemBuilder Url(string url) {
|
public NavigationItemBuilder Url(string url) {
|
||||||
_item.Url = url;
|
_item.Url = url;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public NavigationItemBuilder Content(IContent content) {
|
||||||
|
_item.Content = content;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public NavigationItemBuilder IdHint(string idHint) {
|
public NavigationItemBuilder IdHint(string idHint) {
|
||||||
_item.IdHint = idHint;
|
_item.IdHint = idHint;
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -96,7 +96,8 @@ namespace Orchard.UI.Navigation {
|
|||||||
Url = item.Url,
|
Url = item.Url,
|
||||||
LinkToFirstChild = item.LinkToFirstChild,
|
LinkToFirstChild = item.LinkToFirstChild,
|
||||||
Href = item.Href,
|
Href = item.Href,
|
||||||
MenuId = item.MenuId
|
MenuId = item.MenuId,
|
||||||
|
Content = item.Content
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -225,6 +226,7 @@ namespace Orchard.UI.Navigation {
|
|||||||
Position = SelectBestPositionValue(items.Select(x => x.Position)),
|
Position = SelectBestPositionValue(items.Select(x => x.Position)),
|
||||||
Permissions = items.SelectMany(x => x.Permissions).Distinct(),
|
Permissions = items.SelectMany(x => x.Permissions).Distinct(),
|
||||||
MenuId = items.First().MenuId,
|
MenuId = items.First().MenuId,
|
||||||
|
Content = items.First().Content
|
||||||
};
|
};
|
||||||
return joined;
|
return joined;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user