psijkof / ModernBusiness.OC.RazorPages

Start Bootstrap's Modern Business Theme for Orchard Core as a decoupled Razor Pages Module
MIT License
20 stars 7 forks source link

Suggestions on Theming CMS pages #15

Closed remesq closed 5 years ago

remesq commented 5 years ago

Just a couple of thoughts:

  1. On the /ModernBusiness.Theme/Views/Shared/NotFound.cshtml page, consider adding

    @{ Layout = "_Layout.cshtml" }

    This helps avoid having to maintain the template in two separate layout files in case you make changes to one. EDIT: I see now this won't work because of the Breadcrumbs, unless you check if the model is empty by making the following change in /ModelBusiness.Pages.Shared/Pages/Shared/BreadcrumHeader.cshtml

    …
    <h3 class="m-subheader__title m-subheader__title--separator">
            @if (Model != null)
            {
                @Model.DisplayText
            }
            @if (Model != null)
            {
                @if (Model.Content != null)
                {
                    <small>@(Model.Content?.SubtitlePart?.Subtitle.Text ?? "")</small>
                }
                else
                {
                    <small>@(Model.SubTitle ?? "")</small>
                }
            }
        </h3>
    …

    It would work then, for example, when a Not Found is thrown (not sure about other errors). Otherwise, without this change you would get a Cannot perform runtime binding on a null reference error.

  2. Consider adding a Content.cshtml view to /ModernBusiness.Theme/Views. Any pages created in the CMS won't by themed otherwise. I just used the Content.cshtml file from TheTheme and modified it to my needs. You can then add the layout to theme it

    @{ Layout = "../Views/Shared/_Layout.cshtml" … }

  3. Not sure how to trigger the _error.cshtml view in /ModernBusiness.Pages/Pages because I wanted to check if it, too, was being properly themed. That's not really a suggestion, just my ramblings. :) I guess maybe importing the layout in that file would work?

psijkof commented 5 years ago

Great suggestions @remesq. ad. 1 I specified the layout to be used in the NotFound page and it renders fine. (Also made it simpler).

psijkof commented 5 years ago

ad 2. I made something basic working, added to both themes. @remesq great to hear some feedback about this. ad 3. Providing an Error.cshtml in the Theme project (in Views/Shared) does not result in that view being displayed in case of an error. I'm not sure what I should configure and where... @jtkech any insights, again, really appreciated.