You are here

README.txt in Extrafield Views Integration 8

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

The Extrafield Views Integration Module enables all Drupal core extra fields in
the system from type "display" as fields in views.

-- REQUIREMENTS --

Views
Entity

 -- INSTALLATION --

For installing the module, just download the source code and enable the module.
That's all.

-- CONFIGURATION --

The module itself needs no configuration, because the extra fields that you
want to use need an render_class key and a class implements ExtrafieldRenderClassInterface.
Every module can use hook_entity_extra_field_info to register the extra fields. Normally it looks like
this:

function hook_entity_extra_field_info() {
  $extra_fields = array(
    'entity_type' => array(
      'bundle' => array(
        'display' => array(
           'field_name' => array(
            'label' => 'field label',
            'description' => 'field description',
            'weight' => 0,
            'visible' => false,
            'render_class' => 'full\qualified\namespace\RenderClass',
          ),
        ),
      ),
   ),
);

return $extra_fields;
}

The class simply look like this:

<?php

namespace Drupal\your_module;

use Drupal\extrafield_views_integration\lib\ExtrafieldRenderClassInterface;
use Drupal\Core\Entity\Entity;

/**
 * Created by PhpStorm.
 * User: dasricardo
 * Date: 01.04.16
 * Time: 19:14
 */
class YourClass implements ExtrafieldRenderClassInterface
{
    public static function render(Entity $entity)
    {
        return "String";
    }
}

The module needs both, the render_class key and the existing class defined
in the render_class key. The module only registers extra fields from type
"display" with the required key and the existing class. Views then
passes the entity to the static render function of the field.

-- FAQ --

Q:  I register an extra field for node type "article". But views doesn't show
    me the extra field.

A:  Ensure that you add the render_class key to the extra field array and that the
    class you defined in the render_class key exists.

Q:  I see my field for the node type "article" but I don't see any output.

A:  Ensure that your render function returns a value.

File

README.txt
View source
  1. -- SUMMARY --
  2. The Extrafield Views Integration Module enables all Drupal core extra fields in
  3. the system from type "display" as fields in views.
  4. -- REQUIREMENTS --
  5. Views
  6. Entity
  7. -- INSTALLATION --
  8. For installing the module, just download the source code and enable the module.
  9. That's all.
  10. -- CONFIGURATION --
  11. The module itself needs no configuration, because the extra fields that you
  12. want to use need an render_class key and a class implements ExtrafieldRenderClassInterface.
  13. Every module can use hook_entity_extra_field_info to register the extra fields. Normally it looks like
  14. this:
  15. function hook_entity_extra_field_info() {
  16. $extra_fields = array(
  17. 'entity_type' => array(
  18. 'bundle' => array(
  19. 'display' => array(
  20. 'field_name' => array(
  21. 'label' => 'field label',
  22. 'description' => 'field description',
  23. 'weight' => 0,
  24. 'visible' => false,
  25. 'render_class' => 'full\qualified\namespace\RenderClass',
  26. ),
  27. ),
  28. ),
  29. ),
  30. );
  31. return $extra_fields;
  32. }
  33. The class simply look like this:
  34. namespace Drupal\your_module;
  35. use Drupal\extrafield_views_integration\lib\ExtrafieldRenderClassInterface;
  36. use Drupal\Core\Entity\Entity;
  37. /**
  38. * Created by PhpStorm.
  39. * User: dasricardo
  40. * Date: 01.04.16
  41. * Time: 19:14
  42. */
  43. class YourClass implements ExtrafieldRenderClassInterface
  44. {
  45. public static function render(Entity $entity)
  46. {
  47. return "String";
  48. }
  49. }
  50. The module needs both, the render_class key and the existing class defined
  51. in the render_class key. The module only registers extra fields from type
  52. "display" with the required key and the existing class. Views then
  53. passes the entity to the static render function of the field.
  54. -- FAQ --
  55. Q: I register an extra field for node type "article". But views doesn't show
  56. me the extra field.
  57. A: Ensure that you add the render_class key to the extra field array and that the
  58. class you defined in the render_class key exists.
  59. Q: I see my field for the node type "article" but I don't see any output.
  60. A: Ensure that your render function returns a value.