Reputation: 1
is there a way to display a new page with a new layout? Right now what I'm doing is to create a new module but without using [Themed] I'm looking for a simpler way to do it? Thanks
Upvotes: 0
Views: 77
Reputation: 5155
Assumed by layout you mean theme you can implement Orchard.Themes.IThemeSelector
to select a specific theme. Here is an example which shows a theme selector which picks the theme based on a ThemePickerPart
:
public class ThemePickerPartThemeSelector : Orchard.Themes.IThemeSelector
{
public ThemePickerPartThemeSelector(Orchard.ContentManagement.IContentManager aContentManager)
{
mContentManager = aContentManager;
}
public Orchard.Themes.ThemeSelectorResult GetTheme(System.Web.Routing.RequestContext aContext)
{
// get current content item, based on http://www.ideliverable.com/blog/getting-the-current-content-item-in-orchard
object lID;
if (aContext.RouteData.Values.TryGetValue("id", out lID))
{
string lIDStr = lID as string;
if (lIDStr != null)
{
int lContentID;
if(int.TryParse(lIDStr as string, out lContentID))
{
// try to get theme from theme picker part
var lContentItem = mContentManager.Get(lContentID, Orchard.ContentManagement.VersionOptions.Published);
if (lContentItem != null)
{
var lThemePickerPart = lContentItem.As<ThemePickerPart>();
if (lThemePickerPart != null)
{
if (!string.IsNullOrEmpty(lThemePickerPart.ThemeId))
{
// return selected theme
var lResult = new Orchard.Themes.ThemeSelectorResult {Priority = -3, ThemeName = lThemePickerPart.ThemeId};
return lResult;
}
}
}
}
}
}
return null; // use configured theme
}
// private
private Orchard.ContentManagement.IContentManager mContentManager;
}
Upvotes: 0