Adding MenuItemLink alternates

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2012-05-21 17:04:01 -07:00
parent cf4411a644
commit f1d3458afa
16 changed files with 95 additions and 14 deletions

View File

@@ -8,5 +8,9 @@
/// Used to determine if this content type supports draft versions
/// </summary>
public bool Draftable { get; set; }
/// <summary>
/// Defines the stereotype of the type
/// </summary>
public string Stereotype { get; set; }
}
}

View File

@@ -60,6 +60,16 @@ namespace Orchard.Core.Navigation {
.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());
return 3;
@@ -112,6 +122,16 @@ namespace Orchard.Core.Navigation {
.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;
}
}

View File

@@ -1,7 +1,5 @@
using System.Web;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects;
using Orchard.Core.Common.Models;
using Orchard.Core.Navigation.Models;
using Orchard.Localization;
using Orchard.UI.Navigation;
@@ -26,9 +24,9 @@ namespace Orchard.Core.Navigation.Services {
var part = menuPart;
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
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));
}
}
}

View File

@@ -107,7 +107,7 @@
.menu-items-zone {
background:#F3F4F5;
border:1px solid #E4E5E6;
padding:5px;
padding:0px;
}
.menu-items-zone h2 {
@@ -118,8 +118,9 @@
.menu-items-zone li {
background:#FFF;
border:1px solid #EAEAEA;
margin: 2px;
padding: 5px;
padding-right:60px;
padding-right:65px;
display: block;
position:relative;
}

View File

@@ -29,6 +29,8 @@ else {
<label for="MenuText">@T("Menu text")</label>
@Html.TextBoxFor(m => m.MenuText, new { @class = "textMedium", autofocus = "autofocus" })
<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>
}

View File

@@ -0,0 +1 @@
<span class="raw">@Html.Raw(Model.Content.BodyPart.Text)</span>

View File

@@ -525,6 +525,9 @@
<ItemGroup>
<Content Include="Shapes\Views\MenuItemLink.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Navigation\Views\MenuItemLink-HtmlMenuItem.cshtml" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.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.

View File

@@ -94,6 +94,18 @@ namespace Orchard.Core.Shapes {
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")
.OnDisplaying(displaying => {
var menu = displaying.Shape;