Created
April 27, 2017 08:38
-
-
Save carlwoodhouse/d30a883db2e70faf2822bb86ce2f5af8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Web.Mvc; | |
| using Orchard; | |
| using Orchard.Mvc.Filters; | |
| using Orchard.UI.Admin; | |
| namespace Example.Filters { | |
| public class ScriptFilter : FilterProvider, IResultFilter { | |
| private readonly IOrchardServices _orchardServices; | |
| public ScriptFilter(IOrchardServices orchardServices) { | |
| _orchardServices = orchardServices; | |
| } | |
| public void OnResultExecuting(ResultExecutingContext filterContext) { | |
| if (!(filterContext.Result is ViewResult) || AdminFilter.IsApplied(filterContext.RequestContext)) { | |
| return; | |
| } | |
| var workContext = filterContext.GetWorkContext(); | |
| if (workContext != null && its the right controller/action?) {; | |
| workContext.Layout.Tail.Add(_orchardServices.New.Scripts_YourScript( | |
| Culture: somevalue), "0"); | |
| } | |
| } | |
| public void OnResultExecuted(ResultExecutedContext filterContext) { | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment