Answers.Body: <p>You can only return a single content table per element query.</p>
  
  <p>If you need to join multiple content tables, you have two options:</p>
  
  <ol>
  <li><p>Use multiple element queries, one for each group of elements that share a content table. Disadvantage of this approach is, you won't be able to order elements in SQL.</p></li>
  <li><p>Just don’t join in any content tables in the initial elements query, and let your elements lazy-load their content rows if any custom fields are actually accessed on the elements. You can do this by having your element type’s <code>getContentTableForElementsQuery()</code> function return <code>null</code>. The only disadvantage here is that you won't be able to order/filter by custom field values, since those tables won’t have been joined in.</p>
  
  <p>If you go this route, you will need to make sure that your model that extends BaseElementModel is overriding the <code>getContentTable()</code> function (which it should be anyway, if you’re using custom content tables). That way it will know which table to pull data from if any custom field values are requested from it.</p></li>
  </ol>
  
  <p>In your case, if <em>each</em> element is going to have its own content table, then option #2 is probably going to be your best bet.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-10T04:47:19.023Z
Answers.Text: Thanks for the overview of these options. I've settled for a simpler solution for the time being and added a 'Title' field to all the content tables that the user can set like Title Format using the renderObjectModel method.
Answers.UserDisplayName: Ben Parizek
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-25T18:00:46.333Z
Answers.LastActivityDate: 2014-07-25T18:00:46.333Z
Answers.UserDisplayName: Brandon Kelly
Body: <p>I'm building a plugin where each Element created has a unique content table associated with it.  Each individual Element behaves as needed, however, when I try to create an index page that returns all of the records of this Element Type, Craft seems to assume that I'm using the default content table unless I tell it differently in the <code>getContentTableForElementsQuery()</code> method.</p>
  
  <p>However, the results that are being returned have Elements with multiple content tables.</p>
  
  <p>Am I overlooking anything here or is there a different way I should be thinking about this?</p>
  
Tags: <plugin-development><elementcriteriamodel><elementtype>
Title: Is it possible for an Element Type to return multiple content tables with the getContentTableForElementsQuery() method?
ThreadText: # Is it possible for an Element Type to return multiple content tables with the getContentTableForElementsQuery() method?
  
  (Asked by: username_0 on 2014-07-13)
  
  I'm building a plugin where each Element created has a unique content table associated with it. Each individual Element behaves as needed, however, when I try to create an index page that returns all of the records of this Element Type, Craft seems to assume that I'm using the default content table unless I tell it differently in the `getContentTableForElementsQuery()` method.
  
  However, the results that are being returned have Elements with multiple content tables.
  
  Am I overlooking anything here or is there a different way I should be thinking about this?
  
  **Tags:** plugin-development, elementcriteriamodel, elementtype
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-07-25. Score: 3 | Accepted answer
  
  You can only return a single content table per element query.
  
  If you need to join multiple content tables, you have two options:
  
  1. Use multiple element queries, one for each group of elements that share a content table. Disadvantage of this approach is, you won't be able to order elements in SQL.
  2. Just don’t join in any content tables in the initial elements query, and let your elements lazy-load their content rows if any custom fields are actually accessed on the elements. You can do this by having your element type’s `getContentTableForElementsQuery()` function return `null`. The only disadvantage here is that you won't be able to order/filter by custom field values, since those tables won’t have been joined in.
  
     If you go this route, you will need to make sure that your model that extends BaseElementModel is overriding the `getContentTable()` function (which it should be anyway, if you’re using custom content tables). That way it will know which table to pull data from if any custom field values are requested from it.
  
  In your case, if *each* element is going to have its own content table, then option #2 is probably going to be your best bet.
  
  > **Comments:**
  > **username_0**: Thanks for the overview of these options. I've settled for a simpler solution for the time being and added a 'Title' field to all the content tables that the user can set like Title Format using the renderObjectModel method.  
  
  ---
  
  