1

From within a plugin/module using PHP; is there a way to query all element types being used, including custom elements?

I know in the elements database table there is a type column that I could potentially query. But I wasn't sure if there is a native Craft method I could take advantage of instead?

In an ideal world I just need an array of all the element types:

Example:

['asset', 'category', 'entry', 'globalset', 'matrixblock', 'tag', 'user', 'single', 'event', 'product']```
1

Ok, I found this:

https://docs.craftcms.com/api/v3/craft-services-elements.html#method-getallelementtypes

Craft::$app->getElements()->getAllElementTypes()
1
  • Whilst this mostly works, in my case it doesn't include Solspace\Calendar\Elements\Event which is in the elements → types column. But it does include verbb\supertable\elements\SuperTableBlockElement which isn't in the same database column. Seems a bit backwards, but currently doesn't impact what I wanted to acheive. – Mark Notton Jan 4 at 23:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.