0
votes

I have some pages which don't always have content in the body and would like to then treat the zone as empty and have it hidden.

Normally I'd use

@if (Model.Content != null)
{
    <section id="layout-content">
        <div class="container">
            <div class="row">
                <div class="col-md-12">
                    @Zone(Model.Content)
                </div>
            </div>
        </div>
    </section>
}

Problem is that Content zone is never null on the Page, there's title and metadata. Even if I hide those with placement, it's still not null so it just displays empty tags.

<section id="layout-content">
    <div class="container">
        <div class="row">
            <div class="col-md-12">
                <div class="zone zone-content">
                    <article class="page content-item">
                        <header> </header>
                    </article>
                </div>
            </div>
        </div>
    </div>
</section>

Can I somehow check for empty body in my layout or would you suggest better approach?

1

1 Answers

0
votes

Don't hide the top-level content zone from layout. Instead, override Content.cshtml and hide local zones from there.