问题
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