有没有办法更改“登录"和“未找到"视图的区域 [英] Is there a way to change the zone of the LogOn and NotFound view

查看:64
本文介绍了有没有办法更改“登录"和“未找到"视图的区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为自定义主题创建了LogOn和NotFound视图的自定义版本,是否可以更改它们渲染的区域?

I have created a custom version of the LogOn and NotFound views for a custom theme, is it possible to change the zone they render in?

我尝试将<Place LogOn="MobileContent:1"/>放入placement.info文件无济于事.

I've tried putting <Place LogOn="MobileContent:1"/> into the placement.info file to no avail.

推荐答案

LogOn渲染为Content,我认为您不能通过放置更改它.为什么要将此渲染到其他地方?

LogOn renders into Content, I don't think you can change this via placement. Why do want this to render somewhere else?

您是否要在登录表单旁边显示其他内容?您将需要为此创建一个小部件.我做了一个小模块,尽管老实说我并没有做太多的测试,而且我不确定我会相信它那么多^ _ ^但是,该代码可用,应该为您指明正确的方向.

Are you looking to have other content displayed with the logon form alongside it? You will need to create a widget for that. I made a little module, although if I'm honest I didn't really test it much and I'm not sure I would trust it that much ^_^ However, the code is available and should point you in the right direction.

https://modaccountwidgets.codeplex.com/

或者,如果您感觉很勇敢,它就在画廊中,可以安装了;)

Or, if you are feeling brave, it is on the gallery, ready to be installed ;)

https://gallery.orchardproject.net/List/Modules/Orchard.Module.Contrib.Mod.AccountWidgets

编辑

登录只是一种形状,因此从理论上讲您可以覆盖登录网址

Logon is just a shape so you could in theory just overwrite the logon url

yield return new RouteDescriptor
            {
                Priority = 1000,
                Route = new Route("Users/Account/LogOn",
                    new RouteValueDictionary {
                                            {"area", Area},
                                            {"controller", "MyController"},
                                            {"action", "LogOn"},
                    },
                    new RouteValueDictionary(),
                    new RouteValueDictionary { { "area", Area } },
                    new MvcRouteHandler())
            };

然后在这里创建您的登录形状,并将其发送到要使用IWorkContextAccessor的区域(将其注入到新控制器中),例如.

And then in here create your logon shape and send it to the zone you want to using IWorkContextAccessor (inject this into your new controller), eg.

var logon = _orchardServices.New.LogOn().Title(T("Log On").Text);
contextAccessor.GetContext().Layout.Zones["MobileContent"].Add(logon, 1);

但是,我可以想象这变得非常混乱.您可能需要重新考虑自己的操作方式.虽然有人可能为您提供更好的解决方案:)

However, I can imagine this getting fairly messy. You may want to rethink how you are doing this. Although someone may have a better solution for you :)

这篇关于有没有办法更改“登录"和“未找到"视图的区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆