You are here

README.txt in Measured Value Field 7

Same filename and directory in other branches
  1. 6 README.txt
-- SUMMARY --

Measured Value Field provides a new field type. This field type consists of 2
subfields:
* value (numeric value of something - this part is outsourced to Number module)
* unit (units in which the given value is measured - this part is outsourced to
Entity Rereference module)
Then in instance settings you can specify in what units you want to render the
entered value (this part is outsourced to Units module). Joining these powerful
modules allows to introduce Measured Value Field.

-- REQUIREMENTS --

The Measure Value Field module requires the following modules:
* Units
* Entity Reference
* Number
* CTools

-- INTEGRATION --

Measured Value Field module currently integrates with the following modules:
* Views - by providing its custom handlers
* Entity API - by providing its entity meta data wrappers. You can run the
  following code:
  <?php
    $node = node_load(1);
    $wrapper = entity_metadata_wrapper('node', $node);

    // Get unit value:
    $value = $wrapper->field_mvf->value->value();
    dpm($value); // 12

    // Get Measure id:
    $unit_id = $wrapper->field_mvf->unit->raw();
    dpm($unit_id); // 5

    // Get whole unit object:
    $unit_object = $wrapper->field_mvf->unit->value();
    dpm($unit_object); // Unit Object

    // Get Measure label:
    $unit_label = $wrapper->field_mvf->unit->value()->label;
    dpm($unit_label); // Dollar

    $euro_value = $wrapper->field_mvf->converted_euro->value();
    dpm($euro_value); // Whatever it is 12 USDs converted into EUR

    // You have all options for fetching converted value like:
    // $wrapper->field_mvf->converted_{machine_name_of_the_target_unit}->value();

    // Change field value and measure type:
    $wrapper->field_mvf->value = 5;
    $wrapper->field_mvf->unit = 6;

    $value = $wrapper->field_mvf->value->value();
    dpm($value); // 5

    $unit_label = $wrapper->field_mvf->unit->value()->label;
    dpm($unit_label); // Euro

    // For multiple fields:
    $value = $wrapper->field_mvf[0]->value->value();
    dpm($value); // 5

    // Check all multiple values:
    foreach($wrapper->field_mvf as $field) {
       $value = field->value->value();
       dpm($value); // 5
    }
  ?>

-- INSTALLATION --

Install as usual. After installation you will have additional field types
available to be attached to any other entity (nodes, taxonomy terms, etc.).

-- CONFIGURATION --

The module itself does not provide any configuration as of the moment.

File

README.txt
View source
  1. -- SUMMARY --
  2. Measured Value Field provides a new field type. This field type consists of 2
  3. subfields:
  4. * value (numeric value of something - this part is outsourced to Number module)
  5. * unit (units in which the given value is measured - this part is outsourced to
  6. Entity Rereference module)
  7. Then in instance settings you can specify in what units you want to render the
  8. entered value (this part is outsourced to Units module). Joining these powerful
  9. modules allows to introduce Measured Value Field.
  10. -- REQUIREMENTS --
  11. The Measure Value Field module requires the following modules:
  12. * Units
  13. * Entity Reference
  14. * Number
  15. * CTools
  16. -- INTEGRATION --
  17. Measured Value Field module currently integrates with the following modules:
  18. * Views - by providing its custom handlers
  19. * Entity API - by providing its entity meta data wrappers. You can run the
  20. following code:
  21. $node = node_load(1);
  22. $wrapper = entity_metadata_wrapper('node', $node);
  23. // Get unit value:
  24. $value = $wrapper->field_mvf->value->value();
  25. dpm($value); // 12
  26. // Get Measure id:
  27. $unit_id = $wrapper->field_mvf->unit->raw();
  28. dpm($unit_id); // 5
  29. // Get whole unit object:
  30. $unit_object = $wrapper->field_mvf->unit->value();
  31. dpm($unit_object); // Unit Object
  32. // Get Measure label:
  33. $unit_label = $wrapper->field_mvf->unit->value()->label;
  34. dpm($unit_label); // Dollar
  35. $euro_value = $wrapper->field_mvf->converted_euro->value();
  36. dpm($euro_value); // Whatever it is 12 USDs converted into EUR
  37. // You have all options for fetching converted value like:
  38. // $wrapper->field_mvf->converted_{machine_name_of_the_target_unit}->value();
  39. // Change field value and measure type:
  40. $wrapper->field_mvf->value = 5;
  41. $wrapper->field_mvf->unit = 6;
  42. $value = $wrapper->field_mvf->value->value();
  43. dpm($value); // 5
  44. $unit_label = $wrapper->field_mvf->unit->value()->label;
  45. dpm($unit_label); // Euro
  46. // For multiple fields:
  47. $value = $wrapper->field_mvf[0]->value->value();
  48. dpm($value); // 5
  49. // Check all multiple values:
  50. foreach($wrapper->field_mvf as $field) {
  51. $value = field->value->value();
  52. dpm($value); // 5
  53. }
  54. ?>
  55. -- INSTALLATION --
  56. Install as usual. After installation you will have additional field types
  57. available to be attached to any other entity (nodes, taxonomy terms, etc.).
  58. -- CONFIGURATION --
  59. The module itself does not provide any configuration as of the moment.