mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-22 20:13:50 +08:00
Converting local navs to a new core shape (AKA making louis happy :))
--HG-- branch : dev
This commit is contained in:
@@ -372,6 +372,12 @@
|
||||
<ItemGroup>
|
||||
<Content Include="Shapes\Views\ShapeResult\Display.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Shapes\Views\LocalMenu.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Shapes\Views\LocalMenuItem.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.
|
||||
|
@@ -85,6 +85,22 @@ namespace Orchard.Core.Shapes {
|
||||
menuItem.Metadata.Alternates.Add("MenuItem__" + menu.MenuName);
|
||||
});
|
||||
|
||||
builder.Describe("LocalMenu")
|
||||
.OnDisplaying(displaying => {
|
||||
var menu = displaying.Shape;
|
||||
string menuName = menu.MenuName;
|
||||
menu.Classes.Add("localmenu-" + menuName.HtmlClassify());
|
||||
menu.Classes.Add("localmenu");
|
||||
menu.Metadata.Alternates.Add("LocalMenu__" + menuName);
|
||||
});
|
||||
|
||||
builder.Describe("LocalMenuItem")
|
||||
.OnDisplaying(displaying => {
|
||||
var menuItem = displaying.Shape;
|
||||
var menu = menuItem.Menu;
|
||||
menuItem.Metadata.Alternates.Add("LocalMenuItem__" + menu.MenuName);
|
||||
});
|
||||
|
||||
// 'List' shapes start with several empty collections
|
||||
builder.Describe("List")
|
||||
.OnCreated(created => {
|
||||
|
10
src/Orchard.Web/Core/Shapes/Views/LocalMenu.cshtml
Normal file
10
src/Orchard.Web/Core/Shapes/Views/LocalMenu.cshtml
Normal file
@@ -0,0 +1,10 @@
|
||||
@{
|
||||
// Model is Model.Menu from the layout (Layout.Menu)
|
||||
var tag = Tag(Model, "ul");
|
||||
}
|
||||
<nav>
|
||||
@tag.StartElement
|
||||
@* see MenuItem shape template *@
|
||||
@DisplayChildren(Model)
|
||||
@tag.EndElement
|
||||
</nav>
|
22
src/Orchard.Web/Core/Shapes/Views/LocalMenuItem.cshtml
Normal file
22
src/Orchard.Web/Core/Shapes/Views/LocalMenuItem.cshtml
Normal file
@@ -0,0 +1,22 @@
|
||||
@{
|
||||
// odd formatting in this file is to cause more attractive results in the output.
|
||||
var items = (IEnumerable<dynamic>)Enumerable.Cast<dynamic>(Model);
|
||||
}
|
||||
@{
|
||||
if (!HasText(Model.Text)) {
|
||||
@DisplayChildren(Model)
|
||||
} else {
|
||||
if (Model.Href.TrimEnd('/').ToUpperInvariant() == Request.Path.TrimEnd('/').ToUpperInvariant()) {
|
||||
Model.Classes.Add("current");
|
||||
}
|
||||
var tag = Tag(Model, "li");
|
||||
@tag.StartElement
|
||||
<a href="@Model.Href">@Model.Text</a>
|
||||
if (items.Any()) {
|
||||
<ul>
|
||||
@DisplayChildren(Model)
|
||||
</ul>
|
||||
}
|
||||
@tag.EndElement
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user