Return ($name = ‘channel’ || $name = ‘grid’ || $name = ‘fluid_field’) Public function accepts_content_type($name) If we need to define compatibility with other content types, then we override this method for more control. All Fieldtypes initially support the ‘channel’ content type. You can use this function to control backward compatibility. You can leave out everything else, but this is required. We must implement this method to display the field. The display field is the most important function of the field type. To achieve this, we override the in-build function of Fieldtype Class. Suppose your Fieldtype is Input type, then the value of this field must be validated and save. Some of the services mostly operate in the Fieldtype file. There is some other Fieldtype function that can be used based on your Fieldtype features. E.g., You can change the “text” field to email and vice-versa. And this allows the site builder to switch the Fieldtype compatibility to another field type. Here we need to declare the compatibility of the field type. Note: One thing that you must note here, the Add-on folder must have an “” file. ![]() You can return the HTML string of Fieldtype or can use the “form_input” method. In the back end, the “display_field” function is responsible for showing in Fieldtype, as mentioned above, screenshot. This information will display on the Add-ons list in the back end. Here $info variable holds information of Fieldtype like name, version, description, etc. The above code will show an Input type field in the Field list dropdown. File Structureīelow is the basic file structure of Fieldtype. Now let’s move to the Fieldtype file structure. ![]() The name of the Fieldtype file will be “ft.custom_field.php.” Remember that folder name and Fieldtype name will be the same, but only the difference is the Fieldtype file with the prefix -“ft.” The folder path may differ based on the EE version. First of all, we have to create a folder in “system/user/addons” with the name of “custom_field” and put the Fieldtype file here. The location of field type is the same as the third-party addons. Here, I am going to explain how we can create our custom Field types.įieldtype is a part of an Addon, so to create Fieldtype, we will follow the Addon file structure.įirst, choose a field type name let’s say “custom_field.” Location Of Fieldtype File In that case, we need to create a custom field type. ![]() These Fieldtypes mostly fill our requirements in the site’s data management, but in some cases, we need a different type of Fieldtype with different logics.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |