rickbutterfield / Umbraco.Community.BlockPreview

Easy to use rich HTML backoffice previews for the Umbraco Block List and Block Grid editors.
MIT License
15 stars 10 forks source link

Change BackOfficePreviewService to use the Razor Engine to find the View #14

Closed 37Stars closed 1 year ago

37Stars commented 1 year ago

Instead of hardcoding the path for views to "/Views/Partials/blockgrid/Components/{contentAlias}.cshtml" or "/Views/Partials/blocklist/Components/{contentAlias}.cshtml", use the Razor Engine to find the view.

Changing line 120 in BackOfficePreviewService.cs:

string partialPath = _razorViewEngine.FindView(controllerContext, contentAlias, false).ViewName;

** I was going to create a pull request, but I was prompted to merge into a branch first and I wasn't sure how you wanted to work with pull requests.

rickbutterfield commented 1 year ago

This is a great idea! Feel free to fork and and send a PR, I'm happy either with a temp/ or feature/ branch 😃

37Stars commented 1 year ago

I have made the code updates, but it requires 1) adding search paths to the Razor View Engine if you want to move the views outside of the \blockgrid\Component folder and 2) modifying the items.cshtml file in the \blockgrid folder. Would you like that information in the readme markdown file?

rickbutterfield commented 1 year ago

@37Stars yes please! I'll review one you've opened a PR