We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

[v2] Custom field plus plugin?

Development and Programming

mhulse's avatar
mhulse
329 posts
16 years ago
mhulse's avatar mhulse

Hi,

Can a custom field also work as a template plugin? If so, could anyone point me towards an example of one that does this? =)

I am in the process of writing a plugin, and I would love to have this plugin’s code double as a custom field (or, maybe have the custom field class utilize the plugin class?)

Sorry if this is a stupid question, I am just trying to learn new things… Kinda need a kick in the right direction.

Any skilled EE addon pros feel like schooling a noob?

Thanks! M

       
Greg Aker's avatar
Greg Aker
6,022 posts
about 16 years ago
Greg Aker's avatar Greg Aker

mhulse:

What will your plugin do? How do you see it fitting in with data coming from a channel?

-greg

       
Brett DeWoody's avatar
Brett DeWoody
140 posts
about 16 years ago
Brett DeWoody's avatar Brett DeWoody

Mhulse - I’m doing something similar with my Flickr for EE2 add-on. The add-on consists of a custom fieldtype and a plugin. I use the custom fieldtype’s settings panel to get the user’s Flickr API key and some other needed settings. The custom field creates a Flickr fieldtype which lets you browse your Flickr photos, select a photo and display it within an entry.

The plugin provides some more general template tags (to display your photostream, favorites, etc) but it uses the settings from the custom field’s settings panel. To do this I initialize the EE_Fieldtype class within my plugin class, then drill down through the EE_Fieldtype object to retrieve the needed settings from my fieldtype.

$fieldtype_class  = new EE_Fieldtype();
     $fieldtype_settings = $fieldtype_class->EE->config->EE->api_channel_fields->field_types['YOUR_FIELD_TYPE']->settings;

I’d be interested in hearing from some more experienced EE developers their thoughts on this. Is there a more preferred way to go about this. I thought about using a module/fieldtype combo instead of the plugin/fieldtype.

-Brett

       
Brett DeWoody's avatar
Brett DeWoody
140 posts
15 years ago
Brett DeWoody's avatar Brett DeWoody

Ok, scratch my previous post. That’ll only (sometimes) work if the user had already created a custom field. I had to redo my own custom field to correct for this. Here’s how I’m doing it now:

$this->EE =& get_instance();
        
$this->EE->load->library('api/api_channel_fields'); 
        
$fieldtype_settings = $this->EE->api_channel_fields->get_global_settings('[YOUR_FIELDTYPE_NAME]');

That should return an array of your fieldtype’s global settings.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.