function tripal_get_bundle_variable

3.x tripal.entities.api.inc tripal_get_bundle_variable($variable_name, $bundle_id, $default = FALSE)

Fetch the value for a given tripal variable.

Parameters

string $variable_name: The name of the variable as in tripal_variables.name.

int $bundle_id: The unique identfier for the bundle you want the value for.

Return value

text The value of the specified variable for the specified bundle.

Related topics

13 calls to tripal_get_bundle_variable()
TripalContentService_v0_1::addDocBundleClasses in tripal_ws/includes/TripalWebService/TripalContentService_v0_1.inc
Adds classes for every content type to the documentation for this service.
TripalContentService_v0_1::addEntityField in tripal_ws/includes/TripalWebService/TripalContentService_v0_1.inc
Adds the field as a property of the entity resource.
TripalContentService_v0_1::addEntityFields in tripal_ws/includes/TripalWebService/TripalContentService_v0_1.inc
Adds the fields as properties of an entity resource.
TripalContentService_v0_1::doContentTypesList in tripal_ws/includes/TripalWebService/TripalContentService_v0_1.inc
Creates a resources that contains the list of content types.
TripalContentService_v0_1::sanitizeFieldKeys in tripal_ws/includes/TripalWebService/TripalContentService_v0_1.inc
Rewrites the keys of a field's items array for use with web services.

... See full list

File

tripal/api/tripal.entities.api.inc, line 823
Provides an application programming interface (API) for working with TripalEntity content types (bundles) and their entities.

Code

function tripal_get_bundle_variable($variable_name, $bundle_id, $default = FALSE) {

  $variable = tripal_get_variable($variable_name);

  // Warn if we can't find the tripal_variable.
  if (!$variable) {
    return $default;
  }

  // Select the value for this variable.
  $value = db_select('tripal_bundle_variables', 'var')
    ->fields('var', array('value'))
    ->condition('var.bundle_id', $bundle_id)
    ->condition('var.variable_id', $variable->variable_id)
    ->execute()
    ->fetchField();

  // Warn if the value appears to be empty.
  if (!$value) {
    return $default;
  }

  return $value;
}