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

Field-specific settings data

Development and Programming

Joe Michaud's avatar
Joe Michaud
154 posts
15 years ago
Joe Michaud's avatar Joe Michaud

Hi Everyone,

I’ve developed a custom field for storing nutrition information for food products. There is now just one small glitch remaining that I can’t figure out.

I need to be able to access the settings for the particular field but I only see global settings stored in $this->settings… Where can I find the settings specified under admin -> channel administration -> custom fields?

Thanks!

       
Pascal Kriete's avatar
Pascal Kriete
2,589 posts
15 years ago
Pascal Kriete's avatar Pascal Kriete

All the settings get merged into that array, so that specific field settings can override the globals.

What page (or method) are you trying to access these settings from?

       
Joe Michaud's avatar
Joe Michaud
154 posts
15 years ago
Joe Michaud's avatar Joe Michaud

Hi Pascal,

I am trying to access field settings from the replace_tag() method.

I believe my initial mistake was sticking the global settings into an array with the same name as the field-specific settings. The global settings are really only used to provide default values for when a new field is created. I have since changed the name of the global array but still can’t see anything else inside the settings property.

If you are saying that I should be able to see the field settings under the following circumstances then I will go looking for whatever I’ve done to clobber them:

function replace_tag($data, $params = array(), $tagdata = FALSE)
{
    $stuff = $this->settings['field_settings'];
    ...
}

Thanks!

       
Joe Michaud's avatar
Joe Michaud
154 posts
15 years ago
Joe Michaud's avatar Joe Michaud

So I ended up having to pull the field settings directly out of the database as follows:

$query = $this->EE->db->query('SELECT field_settings FROM exp_channel_fields WHERE field_id="'.$this->field_id.'"');
if ($query->num_rows() == 1) {
    $query = unserialize(base64_decode($query->row('field_settings')));
}

Please let me know if these settings are already in memory so I can avoid an unnecessary query. Thanks!

       

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.