Is there a way to change the zone of the LogOn and NotFound view

為{幸葍}努か 提交于 2019-12-24 21:09:19

问题


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?

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


回答1:


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

EDIT

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())
            };

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 :)



来源:https://stackoverflow.com/questions/22174966/is-there-a-way-to-change-the-zone-of-the-logon-and-notfound-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!