Answers.Body: <p>Something like this should do it:</p>
  
  <pre><code>$criteria = craft()-&gt;elements-&gt;getCriteria(ElementType::MatrixBlock);
  $criteria-&gt;status = null;
  $find = $criteria-&gt;find();
  </code></pre>
  
  <p>Setting <code>status</code> to null will return all elements regardless of their status.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-03T16:42:38.830Z
Answers.Text: The difficultly I'm having with the manual approach is finding the right criteria to restrict the results to the matrix block content for a specific entry id. I can query the db directly - but following the chain of relationships is proving difficult.
Answers.UserDisplayName: Tom
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-03T16:36:23.013Z
Answers.LastActivityDate: 2015-08-03T16:36:23.013Z
Answers.UserDisplayName: Brad Bell
Answers.Body: <p>If you already have an entry object, and know the handle for the Matrix field, you can use:</p>
  
  <pre><code>$criteria = craft()-&gt;elements-&gt;getCriteria(ElementType::MatrixBlock);
  $criteria-&gt;fieldId = craft()-&gt;fields-&gt;getFieldByHandle('matrixFieldHandle')-&gt;id;
  $criteria-&gt;ownerId = $entry-&gt;id;
  $criteria-&gt;status = null;
  $blocks = $criteria-&gt;find();
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-03T17:13:04.757Z
Answers.LastActivityDate: 2015-08-03T17:13:04.757Z
Answers.UserDisplayName: Tom
Body: <p>I've got a plugin which needs to be able to access all the blocks in a matrix - regardless of if the blocks are enabled or disabled.</p>
  
  <p>The entry objects returned by the likes of <code>craft()-&gt;entries-&gt;getEntryById</code> only seem to include blocks in the matrix fields which are enabled.</p>
  
  <p>Is there a way to access this information through a service - or do I need to work out how this is handled in the control panel (which does show disabled matrix blocks)?</p>
  
Tags: <plugin-development>
Title: Accessing disabled matrix blocks in a plugin
ThreadText: # Accessing disabled matrix blocks in a plugin
  
  (Asked by: username_0 on 2015-08-03)
  
  I've got a plugin which needs to be able to access all the blocks in a matrix - regardless of if the blocks are enabled or disabled.
  
  The entry objects returned by the likes of `craft()->entries->getEntryById` only seem to include blocks in the matrix fields which are enabled.
  
  Is there a way to access this information through a service - or do I need to work out how this is handled in the control panel (which does show disabled matrix blocks)?
  
  **Tags:** plugin-development
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2015-08-03. Score: 2
  
  Something like this should do it:
  
  ```
  $criteria = craft()->elements->getCriteria(ElementType::MatrixBlock);
  $criteria->status = null;
  $find = $criteria->find();
  
  ```
  
  Setting `status` to null will return all elements regardless of their status.
  
  > **Comments:**
  > **username_0**: The difficultly I'm having with the manual approach is finding the right criteria to restrict the results to the matrix block content for a specific entry id. I can query the db directly - but following the chain of relationships is proving difficult.  
  
  ---
  
  ### Answer by username_0 on 2015-08-03. Score: 1
  
  If you already have an entry object, and know the handle for the Matrix field, you can use:
  
  ```
  $criteria = craft()->elements->getCriteria(ElementType::MatrixBlock);
  $criteria->fieldId = craft()->fields->getFieldByHandle('matrixFieldHandle')->id;
  $criteria->ownerId = $entry->id;
  $criteria->status = null;
  $blocks = $criteria->find();
  
  ```
  
  
  ---
  
  