Answers.Body: <p>It is likely just a typo in your template. Can you ensure that if your element type class name is of the format <code>Custom_PluginElementType</code> that your template code is then in the following format:</p>
  
  <pre><code>{% set elementType = 'Custom_Plugin' %}
  </code></pre>
  
  <p>Or if your element type class name is of the format <code>CustomElementType</code> that your template code is then in the following format:</p>
  
  <pre><code>{% set elementType = 'Custom' %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-14T08:08:05.697Z
Answers.Text: Yeah as far as I can tell everything looks as though its correct, I have `PluginHandle_FooElementType` as the classname format which is referenced correctly in the templates (ended up copy and pasting it for sanity) and no dice. if I change `{% set elementType = 'Custom_Plugin' %}` to something random the admin page throws a 404, which makes me think it's referenced correctly.
Answers.UserDisplayName: Alec Ritson
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-14T09:31:37.453Z
Answers.Text: so is your template code then
  `{% set elementType = 'PluginHandle_Foo' %}`?
Answers.UserDisplayName: Ben Croker
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-14T09:39:06.230Z
Answers.Text: Yes, it is. I've updated my question to give more details on what i've got set up :)
Answers.UserDisplayName: Alec Ritson
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-14T09:49:14.553Z
Answers.Text: can you post your Plugin_FooModel code too?
Answers.UserDisplayName: Ben Croker
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-14T09:54:27.227Z
Answers.Text: Sure, sorry should have done that before!
Answers.UserDisplayName: Alec Ritson
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-17T08:45:56.587Z
Answers.Text: I can't spot any issues with your code above. can you try reinstalling your plugin? and are you on Craft 2.5?
Answers.UserDisplayName: Ben Croker
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-19T15:43:59.993Z
Answers.Text: Sorry for the delay in replying, yeah tried reinstalling multiple times and running the latest version of 2.5. I might try a clean craft install and go from there...thanks for your time though!
Answers.UserDisplayName: Alec Ritson
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-22T18:01:21.643Z
Answers.Text: sure thing, be sure to let us know if you end up solving it!!
Answers.UserDisplayName: Ben Croker
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-13T20:38:27.140Z
Answers.LastActivityDate: 2015-12-13T20:38:27.140Z
Answers.UserDisplayName: Ben Croker
Answers.Body: <p>I just had the same issue. You forgot to add the modifyElementsQuery method to your Plugin_FooElementType class:</p>
  
  <pre><code>public function modifyElementsQuery(DbCommand $query, ElementCriteriaModel $criteria)
  {
      $query-&gt;join('plugin_foos plugin_foo', 'plugin_foo.id = elements.id');
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-05T14:21:44.997Z
Answers.LastActivityDate: 2016-05-05T14:21:44.997Z
Answers.UserDisplayName: Leevi Graham
Body: <p>I'm creating a plugin with its own ElementType, i've been using the <a href="https://github.com/pixelandtonic/Events" rel="nofollow noreferrer">Events</a> plugin by P&amp;T for reference, so I thought everything was going fine.</p>
  
  <p>Now when I go to my elements index, I seem to just get a listing for all elements, regardless of anything. What could cause this? I have my element type in my template like</p>
  
  <pre><code>{% set elementType = 'Custom_ElementType' %}
  </code></pre>
  
  <p>So if I change this to</p>
  
  <pre><code>{% set elementType = 'Entry' %}
  </code></pre>
  
  <p>I get a list of all entries with the correct sections and whatnot, which is what I expect, but when I change it to the former I get this:</p>
  
  <p><a href="https://i.sstatic.net/55NlU.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/55NlU.jpg" alt="enter image description here"></a></p>
  
  <p>I've obviously overlooked something but I can't figure it out, if anyone else has overcome something similar i'd be grateful for any pointers.</p>
  
  <p><strong>Update</strong></p>
  
  <p>Here is the code i'm using:</p>
  
  <p><em>Plugin_FooElementType.php</em></p>
  
  <pre><code>&lt;?php
  namespace Craft;
  
  class Plugin_FooElementType extends BaseElementType
  {
    public function getName()
    {
      return Craft::t('Foo Element');
    }
    public function getSources($context = null)
    {
      $sources = array(
        '*' =&gt; array(
         'label' =&gt; Craft::t('All sources')
        )
      );
      return $sources;
    }
  
    public function populateElementModel($row)
    {
      return Plugin_FooModel::populateModel($row);
    }
  
    public function defineTableAttributes($source = null)
    {
      return array(
       'id' =&gt; Craft::t('ID'),
       'handle' =&gt; Craft::t('Handle'),
       'path' =&gt; Craft::t('Path'),
      );
    }
  }
  </code></pre>
  
  <p><em>_index.html</em></p>
  
  <pre><code>{% extends "_layouts/elementindex" %}
  {% set title = "Endpoints"|t %}
  
  {% set elementType = 'Plugin_Foo' %}
  
  {% set tabs = {
    events:    { label: "Events"|t, url: url('events') },
    requets: { label: "Requests"|t, url: url('plugin/foos') }
  } %}
  </code></pre>
  
  <p><em>Plugin_FooModel.php</em></p>
  
  <pre><code>&lt;?php
  namespace Craft;
  
  class Plugin_FooModel extends BaseElementModel
  {
   protected $elementType = 'Plugin_Foo';
  
  
   protected function defineAttributes()
   {
      return array_merge(parent::defineAttributes(), array(
          'requestId' =&gt; AttributeType::Number,
          'handle' =&gt; AttributeType::Handle,
          'path' =&gt; AttributeType::String,
      ));
   }
  
   public function getCpEditUrl()
   {
      $relation = $this-&gt;getRelation();
      if ($relation)
      {
          return UrlHelper::getCpUrl('plugin/'.$relation-&gt;handle.'/'.$this-&gt;id);
      }
   }
  
  
   public function getRelation()
   {
      if ($this-&gt;relatedId)
      {
          return craft()-&gt;plugin-&gt;getRelationById($this-&gt;relatedId);
      }
   }
  }
  </code></pre>
  
Tags: <plugin-development><elementtype>
Title: What would cause an custom element listing to just return everything?
ThreadText: # What would cause an custom element listing to just return everything?
  
  (Asked by: username_0 on 2015-12-10)
  
  I'm creating a plugin with its own ElementType, i've been using the [Events](https://github.com/pixelandtonic/Events) plugin by P&T for reference, so I thought everything was going fine.
  
  Now when I go to my elements index, I seem to just get a listing for all elements, regardless of anything. What could cause this? I have my element type in my template like
  
  ```
  {% set elementType = 'Custom_ElementType' %}
  
  ```
  
  So if I change this to
  
  ```
  {% set elementType = 'Entry' %}
  
  ```
  
  I get a list of all entries with the correct sections and whatnot, which is what I expect, but when I change it to the former I get this:
  
  [![enter image description here](https://i.sstatic.net/55NlU.jpg)](https://i.sstatic.net/55NlU.jpg)
  
  I've obviously overlooked something but I can't figure it out, if anyone else has overcome something similar i'd be grateful for any pointers.
  
  **Update**
  
  Here is the code i'm using:
  
  *Plugin\_FooElementType.php*
  
  ```
  <?php
  namespace Craft;
  
  class Plugin_FooElementType extends BaseElementType
  {
    public function getName()
    {
      return Craft::t('Foo Element');
    }
    public function getSources($context = null)
    {
      $sources = array(
        '*' => array(
         'label' => Craft::t('All sources')
        )
      );
      return $sources;
    }
  
    public function populateElementModel($row)
    {
      return Plugin_FooModel::populateModel($row);
    }
  
    public function defineTableAttributes($source = null)
    {
      return array(
       'id' => Craft::t('ID'),
       'handle' => Craft::t('Handle'),
       'path' => Craft::t('Path'),
      );
    }
  }
  
  ```
  
  *\_index.html*
  
  ```
  {% extends "_layouts/elementindex" %}
  {% set title = "Endpoints"|t %}
  
  {% set elementType = 'Plugin_Foo' %}
  
  {% set tabs = {
    events:    { label: "Events"|t, url: url('events') },
    requets: { label: "Requests"|t, url: url('plugin/foos') }
  } %}
  
  ```
  
  *Plugin\_FooModel.php*
  
  ```
  <?php
  namespace Craft;
  
  class Plugin_FooModel extends BaseElementModel
  {
   protected $elementType = 'Plugin_Foo';
  
   protected function defineAttributes()
   {
      return array_merge(parent::defineAttributes(), array(
          'requestId' => AttributeType::Number,
          'handle' => AttributeType::Handle,
          'path' => AttributeType::String,
      ));
   }
  
   public function getCpEditUrl()
   {
      $relation = $this->getRelation();
      if ($relation)
      {
          return UrlHelper::getCpUrl('plugin/'.$relation->handle.'/'.$this->id);
      }
   }
  
   public function getRelation()
   {
      if ($this->relatedId)
      {
          return craft()->plugin->getRelationById($this->relatedId);
      }
   }
  }
  
  ```
  
  **Tags:** plugin-development, elementtype
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2015-12-13. Score: 2
  
  It is likely just a typo in your template. Can you ensure that if your element type class name is of the format `Custom_PluginElementType` that your template code is then in the following format:
  
  ```
  {% set elementType = 'Custom_Plugin' %}
  
  ```
  
  Or if your element type class name is of the format `CustomElementType` that your template code is then in the following format:
  
  ```
  {% set elementType = 'Custom' %}
  
  ```
  
  > **Comments:**
  > **username_0**: Yeah as far as I can tell everything looks as though its correct, I have `PluginHandle_FooElementType` as the classname format which is referenced correctly in the templates (ended up copy and pasting it for sanity) and no dice. if I change `{% set elementType = 'Custom_Plugin' %}` to something random the admin page throws a 404, which makes me think it's referenced correctly.  
  > **username_1**: so is your template code then `{% set elementType = 'PluginHandle_Foo' %}`?  
  > **username_0**: Yes, it is. I've updated my question to give more details on what i've got set up :)  
  > **username_1**: can you post your Plugin_FooModel code too?  
  > **username_0**: Sure, sorry should have done that before!  
  > **username_1**: I can't spot any issues with your code above. can you try reinstalling your plugin? and are you on Craft 2.5?  
  > **username_0**: Sorry for the delay in replying, yeah tried reinstalling multiple times and running the latest version of 2.5. I might try a clean craft install and go from there...thanks for your time though!  
  > **username_1**: sure thing, be sure to let us know if you end up solving it!!  
  
  ---
  
  ### Answer by username_2 on 2016-05-05. Score: 1
  
  I just had the same issue. You forgot to add the modifyElementsQuery method to your Plugin\_FooElementType class:
  
  ```
  public function modifyElementsQuery(DbCommand $query, ElementCriteriaModel $criteria)
  {
      $query->join('plugin_foos plugin_foo', 'plugin_foo.id = elements.id');
  }
  
  ```
  
  
  ---
  
  