<p>Based on the <a href="https://docs.craftcms.com/v3/dev/element-queries/entry-queries.html#enabledforsite" rel="nofollow noreferrer">anyStatus</a> and <a href="https://docs.craftcms.com/v3/dev/element-queries/entry-queries.html#site" rel="nofollow noreferrer">site query</a> parameters, it should work like this:</p>

<pre><code>{% set entries = craft.entries()
    .site('foo')
    .enabledForSite(true)
    .all() %}
</code></pre>

CC BY-SA 4.0
2019-10-09T15:31:41.593Z
Thanks @ChristopherDosin - however, this would allow me get all entries that are enabled for a particular site, rather than check if a particular entry is enabled for a particular site. I suppose I could do something like `{% set count = craft.entries().id(entry.id).site('foo').enabledForSite(true).count() %}` but it's not ideal
Pete H
CC BY-SA 4.0
2019-10-09T15:33:15.527Z
Why is this not ideal? This would be the query. Get your specific entry, from the specific site and check if it's enabled or not. What's wrong with the query? :)
Christopher Dosin
CC BY-SA 4.0
2019-10-09T15:42:12.483Z
There's nothing wrong with the query. It's a lovely query. It just doesn't do what I need. Your query returns all entries that are enabled for the specified site. I need to check if a specific entry is enable for a specific site. The query I posted would work, but I don't love having to do a whole new query for something that should ideally be a property of the entry object I already have.
Pete H
CC BY-SA 4.0
2019-10-09T15:45:27.300Z
Unfortunately there's not such a parameter. `enabledForSite` accepts just `true` or `false`. I would just go with your query.
Christopher Dosin
CC BY-SA 4.0
2019-10-09T15:45:48.693Z
OK thanks, appreciate your help :)
Pete H
CC BY-SA 4.0
2019-10-09T15:24:00.957Z
2019-10-09T15:24:00.957Z
Christopher Dosin
<p>Just in case it helps anyone else, here's a reasonably efficient complete template I needed which outputs entries and their per-site statuses:</p>
<pre><code>{% set entriesQuery = craft.entries
    .siteId('*')
    .anyStatus()
    .limit(null)
    .orderBy('id')
%}

{% set uniqueEntries = clone(entriesQuery).unique().all()|index('id') %}

&lt;html&gt;
&lt;title&gt;Status Report&lt;/title&gt;
&lt;body&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;&gt;
    {% for entryId, entryData in entriesQuery.all()|group('id') %}

        {% set somewhereIsEnabled = false %}

        {% set entrySitesStatuses %}            
            {% for entry in entryData %}
                {% set somewhereIsEnabled = entry.status == 'live' ? true : somewhereIsEnabled %}
                &lt;li style=&quot;{{ entry.status == 'live' ? 'background:green' : 'text-decoration: line-through' }}&quot;&gt;
                    {{ entry.site.handle }}: {{ entry.status }}
                &lt;/li&gt;
            {% endfor %}
        {% endset %}

        &lt;tr style=&quot;{{ not somewhereIsEnabled ? 'background:red' }}&quot;&gt;
            &lt;td&gt;{{ loop.index }}&lt;/td&gt;
            &lt;td&gt;{{ uniqueEntries[entryId].id }}&lt;/td&gt;
            &lt;td&gt;{{ uniqueEntries[entryId].title }}&lt;/td&gt;
            &lt;td&gt;{{ uniqueEntries[entryId].status }}&lt;/td&gt;
            &lt;td&gt;&lt;ul&gt;{{ entrySitesStatuses }}&lt;/ul&gt;&lt;/td&gt;
            &lt;td&gt;{{ uniqueEntries[entryId].type }}&lt;/td&gt;
        &lt;/tr&gt;
    {% endfor %}
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

CC BY-SA 4.0
2020-08-26T09:35:59.893Z
2020-08-26T11:32:19.210Z
2020-08-26T11:32:19.210Z
James Smith
<p>Is there a way to find out if an entry is enabled for a particular site?</p>

<p>I know there's the <code>enabledForSite</code> property, but it doesn't look like it accepts any arguments. Ideally I'd like to do something like <code>{% if entry.enabledForSite(2) %}</code> or <code>{% if entry.enabledForSite('siteHandle') %}</code>.</p>

<p>Thanks!</p>

<templating><craft3>
How to check if an entry is enabled for a particular site?
# How to check if an entry is enabled for a particular site?

(Asked by: username_0 on 2019-10-09)

Is there a way to find out if an entry is enabled for a particular site?

I know there's the `enabledForSite` property, but it doesn't look like it accepts any arguments. Ideally I'd like to do something like `{% if entry.enabledForSite(2) %}` or `{% if entry.enabledForSite('siteHandle') %}`.

Thanks!

**Tags:** templating, craft3

---

## 2 answers

### Answer by username_1 on 2019-10-09. Score: 2

Based on the anyStatus and site query parameters, it should work like this:
{% set entries = craft.entries()
    .site('foo')
    .enabledForSite(true)
    .all() %}

> **Comments:**
> **username_0**: Thanks @ChristopherDosin - however, this would allow me get all entries that are enabled for a particular site, rather than check if a particular entry is enabled for a particular site. I suppose I could do something like `{% set count = craft.entries().id(entry.id).site('foo').enabledForSite(true).count() %}` but it's not ideal  
> **username_1**: Why is this not ideal? This would be the query. Get your specific entry, from the specific site and check if it's enabled or not. What's wrong with the query? :)  
> **username_0**: There's nothing wrong with the query. It's a lovely query. It just doesn't do what I need. Your query returns all entries that are enabled for the specified site. I need to check if a specific entry is enable for a specific site. The query I posted would work, but I don't love having to do a whole new query for something that should ideally be a property of the entry object I already have.  
> **username_1**: Unfortunately there's not such a parameter. `enabledForSite` accepts just `true` or `false`. I would just go with your query.  
> **username_0**: OK thanks, appreciate your help :)  

---

### Answer by username_2 on 2020-08-26. Score: 1

Just in case it helps anyone else, here's a reasonably efficient complete template I needed which outputs entries and their per-site statuses:
{% set entriesQuery = craft.entries
    .siteId('*')
    .anyStatus()
    .limit(null)
    .orderBy('id')
%}

{% set uniqueEntries = clone(entriesQuery).unique().all()|index('id') %}


Status Report


    {% for entryId, entryData in entriesQuery.all()|group('id') %}

        {% set somewhereIsEnabled = false %}

        {% set entrySitesStatuses %}            
            {% for entry in entryData %}
                {% set somewhereIsEnabled = entry.status == 'live' ? true : somewhereIsEnabled %}
                
                    {{ entry.site.handle }}: {{ entry.status }}
                
            {% endfor %}
        {% endset %}

        
            {{ loop.index }}
            {{ uniqueEntries[entryId].id }}
            {{ uniqueEntries[entryId].title }}
            {{ uniqueEntries[entryId].status }}
            {{ entrySitesStatuses }}
            {{ uniqueEntries[entryId].type }}
        
    {% endfor %}


---

