Skip to main content
removed "Drupal" and tags from the title
Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

Combine fields from many nodes within a custom controller (Drupal 8 or 9)

I'm going this route as I can't get a view to behave as needed.

In simple terms I have

content type 1 containing custom field 1 with a custom formatter

content type 2 containing custom field 2 with a custom formatter

content type 3 containing custom field 3 with a custom formatter

Each node will display correctly using the formatter if the node is viewed directly so I'm happy with that, however for some of the pages I need to display I need to use all (or partial) content from these content types as a single "entity". What I'm trying to do is generate a response that in effect wrap the output of all 3 sets of fields into a single output that can then be pushed back into Drupal's normal page processing so that other modules can work on the aggregated output before the HTML rendering phase. Additionally, if possible I'd like to be able to use different formatters other than the field default for the fields depending on the use context so a web page used the default formatter, a rest feed used formatter 2, an XML feed used formatter 3

I'm using Drupal 8.9 but will soon be goingmoving to Drupal 9.

Combine fields from many nodes within a custom controller (Drupal 8 or 9)

I'm going this route as I can't get a view to behave as needed.

In simple terms I have

content type 1 containing custom field 1 with a custom formatter

content type 2 containing custom field 2 with a custom formatter

content type 3 containing custom field 3 with a custom formatter

Each node will display correctly using the formatter if the node is viewed directly so I'm happy with that, however for some of the pages I need to display I need to use all (or partial) content from these content types as a single "entity". What I'm trying to do is generate a response that in effect wrap the output of all 3 sets of fields into a single output that can then be pushed back into Drupal's normal page processing so that other modules can work on the aggregated output before the HTML rendering phase. Additionally, if possible I'd like to be able to use different formatters other than the field default for the fields depending on the use context so a web page used the default formatter, a rest feed used formatter 2, an XML feed used formatter 3

I'm using Drupal 8.9 but will soon be going 9

Combine fields from many nodes within a custom controller

I'm going this route as I can't get a view to behave as needed.

In simple terms I have

content type 1 containing custom field 1 with a custom formatter

content type 2 containing custom field 2 with a custom formatter

content type 3 containing custom field 3 with a custom formatter

Each node will display correctly using the formatter if the node is viewed directly so I'm happy with that, however for some of the pages I need to display I need to use all (or partial) content from these content types as a single "entity". What I'm trying to do is generate a response that in effect wrap the output of all 3 sets of fields into a single output that can then be pushed back into Drupal's normal page processing so that other modules can work on the aggregated output before the HTML rendering phase. Additionally, if possible I'd like to be able to use different formatters other than the field default for the fields depending on the use context so a web page used the default formatter, a rest feed used formatter 2, an XML feed used formatter 3

I'm using Drupal 8.9 but will soon be moving to Drupal 9.

Source Link

Combine fields from many nodes within a custom controller (Drupal 8 or 9)

I'm going this route as I can't get a view to behave as needed.

In simple terms I have

content type 1 containing custom field 1 with a custom formatter

content type 2 containing custom field 2 with a custom formatter

content type 3 containing custom field 3 with a custom formatter

Each node will display correctly using the formatter if the node is viewed directly so I'm happy with that, however for some of the pages I need to display I need to use all (or partial) content from these content types as a single "entity". What I'm trying to do is generate a response that in effect wrap the output of all 3 sets of fields into a single output that can then be pushed back into Drupal's normal page processing so that other modules can work on the aggregated output before the HTML rendering phase. Additionally, if possible I'd like to be able to use different formatters other than the field default for the fields depending on the use context so a web page used the default formatter, a rest feed used formatter 2, an XML feed used formatter 3

I'm using Drupal 8.9 but will soon be going 9