function cck_field_get_setting in Content Construction Kit (CCK) 7.3
Helper function to retrieve field settings stored by CCK.
CCK uses the 'cck_field_settings' table to store custom settings not used by core.
Field settings will have no $instance nor a db bundle column.
4 calls to cck_field_get_setting()
- cck_allowed_values_form in ./
cck.module - Add fields to allowed values form to allow users to input a function or a PHP snippet that will return the allowed values.
- cck_allowed_values_php in ./
cck.module - Callback to return allowed values constructed from php code snippet.
- cck_default_value_form in ./
cck.module - Add fields to default value form to allow users to input a function or a PHP snippet that will return the default values.
- cck_default_value_php in ./
cck.module - Callback to return default value constructed from php code snippet.
File
- ./
cck.module, line 211 - Allows administrators to use php code snippets to define allowed values or default values. The snippets are stored in a database table and retrieved in callback functions.
Code
function cck_field_get_setting($setting, $setting_type, $field, $instance = NULL, $langcode = LANGUAGE_NONE) {
if ($setting_type == 'field' || empty($instance)) {
$value = db_select('cck_field_settings', 'fs')
->fields('fs', array(
'setting_option',
))
->condition('fs.field_name', $field['field_name'])
->condition('fs.setting', $setting)
->condition('fs.setting_type', $setting_type)
->execute()
->fetchField();
}
else {
$value = db_select('cck_field_settings', 'fs')
->fields('fs', array(
'setting_option',
))
->condition('fs.field_name', $field['field_name'])
->condition('fs.entity_type', $instance['entity_type'])
->condition('fs.bundle', $instance['bundle'])
->condition('fs.language', $langcode)
->condition('fs.setting', $setting)
->condition('fs.setting_type', $setting_type)
->execute()
->fetchField();
}
if (in_array($setting, cck_serialized_settings())) {
$value = unserialize($value);
}
return $value;
}