We've retired the forum in favor of GitHub Discussions.

New conversations can be started on GitHub. Existing conversations will remain for a while longer.

Head over to GitHub →

How to "is_entry" if everything is a collection?

Kaz van Kooten September 17, 2020 by Kaz van Kooten

Now that everything is a collection, how do I use the "is_entry" variable?

My Statamic v2 sites have pages and collection entries and I've used lines of code like this:

  <main class="main{{ if is_entry && collection == 'services' }} entry-services{{ elseif is_entry && collection == 'team' }} entry-team{{ /if }}</main>

Pretty verbose, I know. But it did what I needed it to do.

However... I've now opted to use the "Expects root" option for collections (thanks again for clarifying, Erin) and I'm considering a collection's root as a "page". So — all entries in the "services" collections need to be included in the whole {{ if is_entry && collection == 'services' }} variable, except the collection root entry.

Hoping anyone can help me yet again ;-)

>>>>>>> Unanswered <<<<<<<
3 Replies