Assume that we have module A which has it's own field type.

We add field(s) in Channel X that is has the field type of module A.

Is there a way inside a module method to know the field id of the field(s) that has those field type?


Here are the assumptions that I have inside the module method

  • The module method already knows the channel name
  • The module method does not know the field_name nor the field_id
  • The module method knows the fieldtype name

Assuming that your fieldtype is called "My Great Fieldtype", with a class name of My_great_fieldtype_ft, use this query:

SELECT field_id FROM exp_channel_fields WHERE field_type = 'my_great_fieldtype'

(Note that the field_type column is all lowercase, without the _ft suffix.)


You can easily find out the field's group id assigned to that channel and then you can fetch field id associated with that channel just by a simple query from the database table exp_channel_fields.

For example, you are having a channel ABC associated with the field group having the id "x". The query will be:

SELECT field_id FROM exp_channel_fields WHERE field_name='FIELD_NAME' AND group_id=x AND site_id=1

I hope, it would help you.

  • I am not sure what the group_id has got to do with this. Can you explain further Feb 15 '13 at 9:34
  • Don't confuse with the group_id if you are thinking that it's member's group id. No it's not. Go to CP -> Admin -> Channel Administration -> Channel Fields. Here you can see all the channel field groups are listed. Now clicking on group which is assigned to your desired channel and check the URL of browser. Within the URL, you can see a query string "group_id". This value of this group id will be used in my example. i hope, it should be clear to you. Feb 15 '13 at 9:53

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.