Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-09T15:31:41.593Z
Answers.Text: 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
Answers.UserDisplayName: Pete H
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-09T15:33:15.527Z
Answers.Text: 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? :)
Answers.UserDisplayName: Christopher Dosin
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-09T15:42:12.483Z
Answers.Text: 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.
Answers.UserDisplayName: Pete H
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-09T15:45:27.300Z
Answers.Text: Unfortunately there's not such a parameter. `enabledForSite` accepts just `true` or `false`. I would just go with your query.
Answers.UserDisplayName: Christopher Dosin
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-09T15:45:48.693Z
Answers.Text: OK thanks, appreciate your help :)
Answers.UserDisplayName: Pete H
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-09T15:24:00.957Z
Answers.LastActivityDate: 2019-10-09T15:24:00.957Z
Answers.UserDisplayName: Christopher Dosin
Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-26T09:35:59.893Z
Answers.LastActivityDate: 2020-08-26T11:32:19.210Z
Answers.LastEditDate: 2020-08-26T11:32:19.210Z
Answers.UserDisplayName: James Smith
Body: <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>
  
Tags: <templating><craft3>
Title: How to check if an entry is enabled for a particular site?
ThreadText: # 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](https://docs.craftcms.com/v3/dev/element-queries/entry-queries.html#enabledforsite) and [site query](https://docs.craftcms.com/v3/dev/element-queries/entry-queries.html#site) parameters, it should work like this:
  
  ```
  {% set entries = craft.entries()
      .site('foo')
      .enabledForSite(true)
      .all() %}
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks @username_1 - 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') %}
  
  <html>
  <title>Status Report</title>
  <body>
  <table border="1" cellpadding="5" cellspacing="0">
      {% for entryId, entryData in entriesQuery.all()|group('id') %}
  
          {% set somewhereIsEnabled = false %}
  
          {% set entrySitesStatuses %}            
              {% for entry in entryData %}
                  {% set somewhereIsEnabled = entry.status == 'live' ? true : somewhereIsEnabled %}
                  <li style="{{ entry.status == 'live' ? 'background:green' : 'text-decoration: line-through' }}">
                      {{ entry.site.handle }}: {{ entry.status }}
                  </li>
              {% endfor %}
          {% endset %}
  
          <tr style="{{ not somewhereIsEnabled ? 'background:red' }}">
              <td>{{ loop.index }}</td>
              <td>{{ uniqueEntries[entryId].id }}</td>
              <td>{{ uniqueEntries[entryId].title }}</td>
              <td>{{ uniqueEntries[entryId].status }}</td>
              <td><ul>{{ entrySitesStatuses }}</ul></td>
              <td>{{ uniqueEntries[entryId].type }}</td>
          </tr>
      {% endfor %}
  </table>
  </body>
  </html>
  
  ```
  
  
  ---
  
  