First - you can get this count in your template by using {my_matrix_field:total_rows} - but I'll assume you need the number stored as a value in a field for other purposes (use in orderby perhaps).

In which case - yes, you'd write an extension, and use the entry_submission_ready hook.

Then in your method, pass $data by reference, so you can modify it. Check to make sure you're in the channel you're looking for, then dump the $data array so you can see how the data is structured. From there you can figure out how to count your Matrix rows, and then set the value of $data['field_id_XX'] (which would be your "counter" field).

function entry_submission_ready($meta, &amp;$data, $autosave)
{
    if($meta['channel_id'] == XX)
    {
        // This is just to let you examine the data - you'd remove it after
        print_r($data);
        exit();
    }
}


What is the best way to modify entry data when submitting and updating entries
I need help I'm working on a project that needs to translate the language of the site automactically depending on the country the user is from. I've never done this before so please any help would be wonderful.
