An Overview of Field Collection
Views Module
Ahana Kundu
www.drupal.org/u/ahana92
● Brief About Field Collection Module
● Why Do We Need Field Collection Views Module
● Making of the module
● Demo
Agenda
● The field collection module helps in grouping a few
fields together and represent it as one field in the
content type.
Why do we use the field collection
module?
● The field collection views module helps in showing
the field collection related data in a table format.
Why do we need the field_collection_views
module?
field_collection_views.info.yml
name: Field Collection views
type: module
description: Provides a field-collection views formatter.
core: 8.x
dependencies:
- drupal:field_collection
Making of the Module
The field formatter formats the field data to be viewed by
the end user. Field formatters are defined as plugins.
module->src->Plugin->Field->FieldFormatter-
>FieldCollectionViewsFormatter.php
Field Formatter
* Plugin implementation of the
* 'views_field_collection_items' formatter.
*
* @FieldFormatter(
* id = "views_field_collection_items",
* label = @Translation("Views field-collection items"),
* field_types = {
* "field_collection"
* }
* )
*/
Field Formatter
public static function defaultSettings() {
return [
'name' => 'field_collection_view',
'display_id' => 'default',
'add' => t('Add'),
] + parent::defaultSettings();
}
Field Formatter Default Settings
public function settingsForm(array $form, FormStateInterface
$form_state) {
$element['name'] = [
'#type' => 'textfield',
'#title' => t('Name'),
'#default_value' => $this->getSetting('name'),
'#description' => t('The machine name of the view to
embed.'),
];
}
Field Formatter Settings Form
Demo
Thank you

An Overview of Field Collection Views Module

  • 1.
    An Overview ofField Collection Views Module Ahana Kundu www.drupal.org/u/ahana92
  • 2.
    ● Brief AboutField Collection Module ● Why Do We Need Field Collection Views Module ● Making of the module ● Demo Agenda
  • 3.
    ● The fieldcollection module helps in grouping a few fields together and represent it as one field in the content type. Why do we use the field collection module?
  • 4.
    ● The fieldcollection views module helps in showing the field collection related data in a table format. Why do we need the field_collection_views module?
  • 5.
    field_collection_views.info.yml name: Field Collectionviews type: module description: Provides a field-collection views formatter. core: 8.x dependencies: - drupal:field_collection Making of the Module
  • 6.
    The field formatterformats the field data to be viewed by the end user. Field formatters are defined as plugins. module->src->Plugin->Field->FieldFormatter- >FieldCollectionViewsFormatter.php Field Formatter
  • 7.
    * Plugin implementationof the * 'views_field_collection_items' formatter. * * @FieldFormatter( * id = "views_field_collection_items", * label = @Translation("Views field-collection items"), * field_types = { * "field_collection" * } * ) */ Field Formatter
  • 8.
    public static functiondefaultSettings() { return [ 'name' => 'field_collection_view', 'display_id' => 'default', 'add' => t('Add'), ] + parent::defaultSettings(); } Field Formatter Default Settings
  • 9.
    public function settingsForm(array$form, FormStateInterface $form_state) { $element['name'] = [ '#type' => 'textfield', '#title' => t('Name'), '#default_value' => $this->getSetting('name'), '#description' => t('The machine name of the view to embed.'), ]; } Field Formatter Settings Form
  • 10.
  • 11.