How to iterate over matrix field from a plugin I'm writing a plugin where I have the id of an entry, that entry has a matrix field, and I want to iterate over the blocks of the matrix field. In php. How do I do that? Pointers to good documentation for how to do this would be appreciated too.
So, first you want to get the entry model using your entry id. In the EntriesService there is a method called getEntryById which you can use like so:

$entry = craft()-&gt;entries-&gt;getEntryById(123);


This will return you an EntryModel which has on it all your fields. So, if you matrix field handle is called matrixFieldHandle then you would access the field contents like so:

$matrixBlocks = $entry-&gt;matrixFieldHandle;


A matrix field will return you an array of MatrixBlockModels from which you can get at everything else you need e.g.:

foreach ($matrixBlocks as $block){
  echo $block-&gt;id;
  echo $block-&gt;fieldHandle;
}


Note that to play with block types you will need to look at the MatrixService and getBlockTypeById() to do things like filter out different blocks based on their block types.