简体   繁体   English

如何在页面上创建localNav样式的选项卡式布局

[英]How can I create a localNav style tabbed layout on a page

I want to have a page that has two tabs, and I can see how to do this in AdminMenu.cs using LocalNav() BUT I need this on a third level item. 我想要一个包含两个选项卡的页面,我可以在AdminMenu.cs中使用LocalNav()进行操作,但是我在第三级项目上需要这样做。

My page structure is 我的页面结构是

Admin Menu 管理菜单

  • My module 我的模块
    • Content Item 1 内容项目1
      • Tab 1 标签1
      • Tab 2 标签2
    • Content Item 2 内容项目2
      • Tab 1 标签1
      • Tab 2 标签2

I can't get these to appear as it only seems to support having tabs off the "my module" link, and not the lower level links. 我无法显示这些内容,因为它似乎仅支持关闭“我的模块”链接中的选项卡,而不支持较低级别的链接。

Is there another way to display the tabbed interface on my "content item 1" and "content item 2" pages? 还有另一种方式可以在“内容项目1”和“内容项目2”页面上显示选项卡式界面吗?

I don't believe there is a way to do this using Orchard's Navigation provider alone. 我不相信有一种方法可以单独使用Orchard的Navigation提供商。 I've done something similar, but I had to handle the tertiary level separately, and implement the menu UI myself from my own controller. 我做了类似的事情,但是我不得不分别处理第三级,并从自己的控制器自己实现菜单UI。

You will still need to add the third level in your module's Navigation Provider, as this will then mark the LHS menu and Tab selections correctly. 您仍然需要在模块的导航提供程序中添加第三级,因为这将正确标记LHS菜单和选项卡选择。 Something along the lines of: 类似于以下内容:

namespace Company.MyModule {
    public class TileSortAdminMenu : INavigationProvider {

        private Localizer T { get; set; }

        public string MenuName { get { return "admin"; } }

        public void GetNavigation(NavigationBuilder builder) {

            builder
                .AddImageSet("mymodule")
                .Add(T("My Module"), "5", menu => menu
                    .LinkToFirstChild(true)
                    .Add(T("Content Item 1"), "1", item => item
                        .LocalNav()
                        .LinkToFirstChild(true)
                        .Add(T("Tab 1"), "1", tab => tab
                            .LocalNav()
                            .Action("Index", "MyModuleAdmin", new { area = "Company.MyModule"})
                        )
                        .Add(T("Tab 2"), "2", tab => tab
                            .LocalNav()
                            .Action("Tab2", "MyModuleAdmin", new { area = "Company.MyModule"})
                        )
                    )
                    .Add(T("Content Item 2"), "2", item => item
                        .LocalNav()
                        .LinkToFirstChild(true)
                        .Add(T("Tab 1"), "1", tab => tab
                            .LocalNav()
                            .Action("ContentItem2Tab1", "MyModuleAdmin", new { area = "Company.MyModule"})
                        )
                        .Add(T("Tab 2"), "2", tab => tab
                            .LocalNav()
                            .Action("ContentItem2Tab2", "MyModuleAdmin", new { area = "Company.MyModule"})
                        )
                    )
                );
        }
    }
}

In your View, you can maintian Orchard's styling by using something like: 在您的视图中,您可以使用以下方法维护Orchard的样式:

<ul class="localmenu localmenu-submenu">
    <li class="selected"><a href="@Url.Action("Index", "MyModuleAdmin", new { area = "Company.MyModule"})">Tab 1</a<</li>
    <li><a href="@Url.Action("Tab2", "MyModuleAdmin", new { area = "Company.MyModule"})">Tab 2</a></li>
</ul>

Where the class localmenu-submenu is a styling hook for your own style tweaks, and you add the class selected to whichever tab you're viewing. 其中localmenu-submenu类是针对您自己的样式调整的样式钩子,您可以将selected的类添加到要查看的任何选项卡上。

Alternatively, depending on what you're trying to achieve, you could just implement jQuery UI's Tabs (available through the Orchard.jQuery resource manifest), and just update the styling to look Orchard-y. 另外,根据您要实现的目标,您可以只实现jQuery UI的Tabs(可通过Orchard.jQuery资源清单获得),并且只需更新样式即可使其看起来像Orchard-y。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM