Answers.Body: <p>Just have your plugin supply a custom <code>MyPluginEntryModel</code> that extends Craft's <code>EntryModel</code> and merges in any custom attribute definitions from your custom table.</p>
  
  <pre><code>class MyPluginEntryModel extends EntryModel
  {
     ....
  
      protected function defineAttributes()
      {
          return array_merge(parent::defineAttributes(), array(
              'customAttribute1' =&gt; AttributeType::Number,
              'customAttribute2' =&gt; AttributeType::String,
          ));
      }
  
     ....
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-09T04:03:47.500Z
Answers.Text: Then how do I populate the model with both the entry and custom data?
Answers.UserDisplayName: a-am
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-09T04:13:28.637Z
Answers.Text: I think this should work?
  $outputModel = MyPluginEntryModel::populateModel($entry,$tablerecord);
Answers.UserDisplayName: a-am
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-09T04:54:32.833Z
Answers.Text: That doesn't seem to work. My goal would be to return a model instead of an array of models.
Answers.UserDisplayName: a-am
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-09T05:42:31.230Z
Answers.Text: You'll need to post the code you're using in the original question. Can't tell what's going on otherwise.
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-09T05:50:19.890Z
Answers.Text: I got that to work just now. How do I return a model to the front end instead of an array of models?
Answers.UserDisplayName: a-am
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-09T05:53:16.540Z
Answers.Text: `$arrayOfModels[0]`? Really hard to tell without your code and some context into what's happening.
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-09T05:55:18.473Z
Answers.Text: Thanks Brad I guess I don't know the question to ask.
Answers.UserDisplayName: a-am
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-09T05:56:19.150Z
Answers.Text: You and me both. :)
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-09T03:55:21.007Z
Answers.LastActivityDate: 2015-01-09T03:55:21.007Z
Answers.UserDisplayName: Brad Bell
Body: <p>In a plugin I am returning entries from a section. Can I combine a returned entry from that section with data from a custom table into one model for output?</p>
  
Tags: <plugin-development><entrymodel>
Title: In plugin combine a returned entry with custom table data
ThreadText: # In plugin combine a returned entry with custom table data
  
  (Asked by: username_0 on 2015-01-09)
  
  In a plugin I am returning entries from a section. Can I combine a returned entry from that section with data from a custom table into one model for output?
  
  **Tags:** plugin-development, entrymodel
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-01-09. Score: 1 | Accepted answer
  
  Just have your plugin supply a custom `MyPluginEntryModel` that extends Craft's `EntryModel` and merges in any custom attribute definitions from your custom table.
  
  ```
  class MyPluginEntryModel extends EntryModel
  {
     ....
  
      protected function defineAttributes()
      {
          return array_merge(parent::defineAttributes(), array(
              'customAttribute1' => AttributeType::Number,
              'customAttribute2' => AttributeType::String,
          ));
      }
  
     ....
  }
  
  ```
  
  > **Comments:**
  > **username_0**: Then how do I populate the model with both the entry and custom data?  
  > **username_0**: I think this should work? $outputModel = MyPluginEntryModel::populateModel($entry,$tablerecord);  
  > **username_0**: That doesn't seem to work. My goal would be to return a model instead of an array of models.  
  > **username_1**: You'll need to post the code you're using in the original question. Can't tell what's going on otherwise.  
  > **username_0**: I got that to work just now. How do I return a model to the front end instead of an array of models?  
  > **username_1**: `$arrayOfModels[0]`? Really hard to tell without your code and some context into what's happening.  
  > **username_0**: Thanks username_1 I guess I don't know the question to ask.  
  > **username_1**: You and me both. :)  
  
  ---
  
  