<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>

CC BY-SA 3.0
2015-12-14T08:08:05.697Z
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.
Alec Ritson
CC BY-SA 3.0
2015-12-14T09:31:37.453Z
so is your template code then
`{% set elementType = 'PluginHandle_Foo' %}`?
Ben Croker
CC BY-SA 3.0
2015-12-14T09:39:06.230Z
Yes, it is. I've updated my question to give more details on what i've got set up :)
Alec Ritson
CC BY-SA 3.0
2015-12-14T09:49:14.553Z
can you post your Plugin_FooModel code too?
Ben Croker
CC BY-SA 3.0
2015-12-14T09:54:27.227Z
Sure, sorry should have done that before!
Alec Ritson
CC BY-SA 3.0
2015-12-17T08:45:56.587Z
I can't spot any issues with your code above. can you try reinstalling your plugin? and are you on Craft 2.5?
Ben Croker
CC BY-SA 3.0
2015-12-19T15:43:59.993Z
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!
Alec Ritson
CC BY-SA 3.0
2015-12-22T18:01:21.643Z
sure thing, be sure to let us know if you end up solving it!!
Ben Croker
CC BY-SA 3.0
2015-12-13T20:38:27.140Z
2015-12-13T20:38:27.140Z
Ben Croker
<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>

CC BY-SA 3.0
2016-05-05T14:21:44.997Z
2016-05-05T14:21:44.997Z
Leevi Graham
<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>

<plugin-development><elementtype>
What would cause an custom element listing to just return everything?
# 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 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:

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
 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
 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');
}


---

