Answers.Body: <p>I guess it is either a bug or the developers don't want us to do it via cp request. In my plugin (phpCode) I can activate and deactivate categories per site easily but the cp template is missing the required input. When you compare the route of a category and an entry you'll notice it easily</p>
  
  <p>Take a look at <code>entries/_edit.html</code></p>
  
  <pre><code>&lt;ul id="sites" class="pane"&gt;
          {% set parentIdParam = craft.app.request.getParam('parentId.0') ?: craft.app.request.getParam('parentId') %}
          {% for siteId in siteIds %}
              {% set site = craft.app.sites.getSiteById(siteId) %}
              &lt;li{% if siteId == entry.siteId %} class="sel"{% endif %}&gt;
                  {%- if siteId == entry.siteId -%}
                      {{ site.name|t('site') }}
                      {{ forms.lightswitch({
                          name: 'enabledForSite',
                          on:   entry.enabledForSite,
                          small: true,
                          disabled: isVersion
                      }) }}
                  {%- else -%}
                      {% set siteEntryUrl = url(
                          'entries/'~sectionHandle~'/'~craft.app.request.getSegment(3)~'/'~site.handle,
                          (parentIdParam ? { parentId: parentIdParam })
                      ) -%}
                      &lt;a href="{{ siteEntryUrl }}"&gt;{{ site.name|t('site') }}&lt;/a&gt;
                      &lt;div class="status {{ siteId in enabledSiteIds ? 'enabled' : 'disabled' }}"&gt;&lt;/div&gt;
                  {%- endif -%}
              &lt;/li&gt;
          {% endfor %}
      &lt;/ul&gt;
  </code></pre>
  
  <p>and the <code>categories/_edit.html</code></p>
  
  <pre><code>&lt;ul id="sites" class="pane"&gt;
          {% set parentIdParam = craft.app.request.getParam('parentId.0') ?: craft.app.request.getParam('parentId') %}
          {% for siteId in siteIds %}
              {% set site = craft.app.sites.getSiteById(siteId) %}
              &lt;li{% if siteId == category.siteId %} class="sel"{% endif %}&gt;
                  {%- if siteId == category.siteId -%}
                      {{ site.name|t('site') }}
                  {%- else -%}
                      {% set siteCategoryUrl = url(
                          'categories/'~groupHandle~'/'~craft.app.request.getSegment(3)~'/'~site.handle,
                          (parentIdParam ? { parentId: parentIdParam })
                      ) -%}
                      &lt;a href="{{ siteCategoryUrl }}"&gt;{{ site.name|t('site') }}&lt;/a&gt;
                  {%- endif -%}
              &lt;/li&gt;
          {% endfor %}
      &lt;/ul&gt;
  </code></pre>
  
  <p>It's missing the</p>
  
  <pre><code>{{ forms.lightswitch({
       name: 'enabledForSite',
       on:   entry.enabledForSite,
       small: true,
       disabled: isVersion
   }) }}
  </code></pre>
  
  <p>even though when I include the input to the template it does not work since it's not populated correctly. The <code>_populateCategoryModel</code> method does not recognize the field.</p>
  
  <p>To compare it: <code>EntriesController</code>:</p>
  
  <pre><code>private function _populateEntryModel(Entry $entry)
  {
      // Set the entry attributes, defaulting to the existing values for whatever is missing from the post data
      $entry-&gt;typeId = Craft::$app-&gt;getRequest()-&gt;getBodyParam('typeId', $entry-&gt;typeId);
      $entry-&gt;slug = Craft::$app-&gt;getRequest()-&gt;getBodyParam('slug', $entry-&gt;slug);
      $entry-&gt;postDate = (($postDate = Craft::$app-&gt;getRequest()-&gt;getBodyParam('postDate')) !== false ? (DateTimeHelper::toDateTime($postDate) ?: null) : $entry-&gt;postDate);
      $entry-&gt;expiryDate = (($expiryDate = Craft::$app-&gt;getRequest()-&gt;getBodyParam('expiryDate')) !== false ? (DateTimeHelper::toDateTime($expiryDate) ?: null) : null);
      $entry-&gt;enabled = (bool)Craft::$app-&gt;getRequest()-&gt;getBodyParam('enabled', $entry-&gt;enabled);
      $entry-&gt;enabledForSite = (bool)Craft::$app-&gt;getRequest()-&gt;getBodyParam('enabledForSite', $entry-&gt;enabledForSite);
      $entry-&gt;title = Craft::$app-&gt;getRequest()-&gt;getBodyParam('title', $entry-&gt;title);
  </code></pre>
  
  <p>has the <code>$entry-&gt;enabledForSite</code> but the <code>CategoryController</code></p>
  
  <pre><code> private function _populateCategoryModel(Category $category)
  {
      // Set the category attributes, defaulting to the existing values for whatever is missing from the post data
      $category-&gt;slug = Craft::$app-&gt;getRequest()-&gt;getBodyParam('slug', $category-&gt;slug);
      $category-&gt;enabled = (bool)Craft::$app-&gt;getRequest()-&gt;getBodyParam('enabled', $category-&gt;enabled);
  
      $category-&gt;title = Craft::$app-&gt;getRequest()-&gt;getBodyParam('title', $category-&gt;title);
  </code></pre>
  
  <p>does not have it</p>
  
  <p>If you want you could create a plugin to fix this issue, it's actually not that complicated since you can change everything in craft now, so you could overwrite the function. But It would be easier to create a ticket with a feature request or something. Maybe Brad could make it clearer<br></p>
  
  <p><strong>To Resume</strong><br>
  If you want to enable categories per site, you have to include the field to the template and to the controller in <code>_populateCategoryModel</code> then it works</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-21T11:19:30.077Z
Answers.LastActivityDate: 2017-11-21T12:58:52.033Z
Answers.LastEditDate: 2017-11-21T12:58:52.033Z
Answers.UserDisplayName: Robin Schambach
Body: <p>In the CP, is it possible to disable Category X for site A, and not for Site B? And if so, how?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-11-21T09:08:41.030Z
Comments.Text: Via custom php code/plugin or via cp request?
Comments.UserDisplayName: Robin Schambach
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-11-21T09:11:49.127Z
Comments.Text: In the CP. Edited question.
Comments.UserDisplayName: Paul
Tags: <categories><craft3><category><status>
Title: In Craft 3, (how) can I disable a category on a per site basis?
ThreadText: # In Craft 3, (how) can I disable a category on a per site basis?
  
  (Asked by: username_0 on 2017-11-21)
  
  In the CP, is it possible to disable Category X for site A, and not for Site B? And if so, how?
  
  **Tags:** categories, craft3, category, status
  
  > **Comments:**
  > **username_1**: Via custom php code/plugin or via cp request?  
  > **username_0**: In the CP. Edited question.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-11-21. Score: 3
  
  I guess it is either a bug or the developers don't want us to do it via cp request. In my plugin (phpCode) I can activate and deactivate categories per site easily but the cp template is missing the required input. When you compare the route of a category and an entry you'll notice it easily
  
  Take a look at `entries/_edit.html`
  
  ```
  <ul id="sites" class="pane">
          {% set parentIdParam = craft.app.request.getParam('parentId.0') ?: craft.app.request.getParam('parentId') %}
          {% for siteId in siteIds %}
              {% set site = craft.app.sites.getSiteById(siteId) %}
              <li{% if siteId == entry.siteId %} class="sel"{% endif %}>
                  {%- if siteId == entry.siteId -%}
                      {{ site.name|t('site') }}
                      {{ forms.lightswitch({
                          name: 'enabledForSite',
                          on:   entry.enabledForSite,
                          small: true,
                          disabled: isVersion
                      }) }}
                  {%- else -%}
                      {% set siteEntryUrl = url(
                          'entries/'~sectionHandle~'/'~craft.app.request.getSegment(3)~'/'~site.handle,
                          (parentIdParam ? { parentId: parentIdParam })
                      ) -%}
                      <a href="{{ siteEntryUrl }}">{{ site.name|t('site') }}</a>
                      <div class="status {{ siteId in enabledSiteIds ? 'enabled' : 'disabled' }}"></div>
                  {%- endif -%}
              </li>
          {% endfor %}
      </ul>
  
  ```
  
  and the `categories/_edit.html`
  
  ```
  <ul id="sites" class="pane">
          {% set parentIdParam = craft.app.request.getParam('parentId.0') ?: craft.app.request.getParam('parentId') %}
          {% for siteId in siteIds %}
              {% set site = craft.app.sites.getSiteById(siteId) %}
              <li{% if siteId == category.siteId %} class="sel"{% endif %}>
                  {%- if siteId == category.siteId -%}
                      {{ site.name|t('site') }}
                  {%- else -%}
                      {% set siteCategoryUrl = url(
                          'categories/'~groupHandle~'/'~craft.app.request.getSegment(3)~'/'~site.handle,
                          (parentIdParam ? { parentId: parentIdParam })
                      ) -%}
                      <a href="{{ siteCategoryUrl }}">{{ site.name|t('site') }}</a>
                  {%- endif -%}
              </li>
          {% endfor %}
      </ul>
  
  ```
  
  It's missing the
  
  ```
  {{ forms.lightswitch({
       name: 'enabledForSite',
       on:   entry.enabledForSite,
       small: true,
       disabled: isVersion
   }) }}
  
  ```
  
  even though when I include the input to the template it does not work since it's not populated correctly. The `_populateCategoryModel` method does not recognize the field.
  
  To compare it: `EntriesController`:
  
  ```
  private function _populateEntryModel(Entry $entry)
  {
      // Set the entry attributes, defaulting to the existing values for whatever is missing from the post data
      $entry->typeId = Craft::$app->getRequest()->getBodyParam('typeId', $entry->typeId);
      $entry->slug = Craft::$app->getRequest()->getBodyParam('slug', $entry->slug);
      $entry->postDate = (($postDate = Craft::$app->getRequest()->getBodyParam('postDate')) !== false ? (DateTimeHelper::toDateTime($postDate) ?: null) : $entry->postDate);
      $entry->expiryDate = (($expiryDate = Craft::$app->getRequest()->getBodyParam('expiryDate')) !== false ? (DateTimeHelper::toDateTime($expiryDate) ?: null) : null);
      $entry->enabled = (bool)Craft::$app->getRequest()->getBodyParam('enabled', $entry->enabled);
      $entry->enabledForSite = (bool)Craft::$app->getRequest()->getBodyParam('enabledForSite', $entry->enabledForSite);
      $entry->title = Craft::$app->getRequest()->getBodyParam('title', $entry->title);
  
  ```
  
  has the `$entry->enabledForSite` but the `CategoryController`
  
  ```
   private function _populateCategoryModel(Category $category)
  {
      // Set the category attributes, defaulting to the existing values for whatever is missing from the post data
      $category->slug = Craft::$app->getRequest()->getBodyParam('slug', $category->slug);
      $category->enabled = (bool)Craft::$app->getRequest()->getBodyParam('enabled', $category->enabled);
  
      $category->title = Craft::$app->getRequest()->getBodyParam('title', $category->title);
  
  ```
  
  does not have it
  
  If you want you could create a plugin to fix this issue, it's actually not that complicated since you can change everything in craft now, so you could overwrite the function. But It would be easier to create a ticket with a feature request or something. Maybe Brad could make it clearer
  
  **To Resume**  
  If you want to enable categories per site, you have to include the field to the template and to the controller in `_populateCategoryModel` then it works
  
  
  ---
  
  