简体   繁体   中英

How to add custom css class for each page?

Im a newbie in Orchard CMS and I cant find help in Google.

I want to assign a custom css class in every page. Like . I tried using vandelay classy module but it doesnt seem to be working.

Thanks for any help.

Vandelay Classy does actually work, it's Orchard itself that has a bad implementation of Content.cshtml . If you override that template in your theme with the following, it should just work:

@using Orchard.Utility.Extensions;
@{
    if (Model.Title != null) {
        Layout.Title = Model.Title;
    }

    Model.Classes.Add("content-item");

    var contentTypeClassName = ((string)Model.ContentItem.ContentType).HtmlClassify();
    Model.Classes.Add(contentTypeClassName);

    var tag = Tag(Model, "article");
}
@tag.StartElement
    <header>
        @Display(Model.Header)
        @if (Model.Meta != null) {
            <div class="metadata">
                @Display(Model.Meta)
            </div>
        }
    </header>
    @Display(Model.Content)
    @if(Model.Footer != null) {
        <footer>
            @Display(Model.Footer)
        </footer>
    }
@tag.EndElement

I've patched 1.x so that 1.7 gets this out of the box and the override will no longer be necessary.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM