I am currently working on a website that requires the ability to overwrite the document.cshtml file so that I can apply a specific CSS-class based on the user's current location.
I have attempted to use URL alternatives such as:
- Document.cshtml
- Document-url-AreaA.cshtml
- Document-url-AreaB.cshtml
- Document.url-AreaC.cshtml
however it appears that all of them use the Document.cshtml as opposed to using one based on the URL. I could easily understand that this is the intended purpose, however I was wondering if it would be possible to implement the functionality above.
Update
I believe that I may have made some progress in this area, as opposed to using URL alternatives, and simply adding a field on the Model (for the document) to simply pull the current "Area" of the site and apply that class to the body.
(Within document.cshtml)
@using Orchard.Mvc.Html;
@using Orchard.UI.Resources;
@{
RegisterLink(new LinkEntry {Type = "image/x-icon", ...});
string title = Convert.ToString(Model.Title);
string siteName = Convert.ToString(WorkContext.CurrentSite.SiteName);
//Pull the Area here
string area = Model.DesignatedAreaField;
}
<!DOCTYPE html>
<html lang="en" class="static @Html.ClassForPage()">
<head>
<meta charset="utf-8" />
<title>@Html.Title(title, siteName)</title>
@Display(Model.Head)
</head>
<body class='@area'>
//Body goes here
@Display(Model.Body)
@Display(Model.Tail)
</body>
</html>
I believe that this may be an easier solution than the one previously suggested. However, I am wondering what the easiest method of actually placing a field that I could access from the Model of the Document, would be.