0

Using Drupal 9 and very new to this CMS. I have a paragraph which has a drop down (field_bio_display) selection with two view names and an entity reference (field_bio) with an unlimited set of values. I'm struggling to create a function which can change the view of all the entity references based on the selection from the drop down. Below is the latest iteration of my function. The conditional never rings true when it should, and if I bypass the conditional then I get an error.Error: Call to a member function view() on string in theme_preprocess_paragraph__bio_grid() (line 36 of themes/theme/includes/paragraph.inc).

Line 36 is: $variables['content']['field_bio'] == $paragraph_field_bio_item->view($field_settings);

I'd love to know where I am going wrong here. All I really need is to set the view to profile if profile is selected in the drop down selection.

function theme_preprocess_paragraph__bio_grid(&$variables) {
  $paragraph_field_bio = $variables['content']['field_bio'];
  $paragraph_field_bio_display = $variables['content']['field_bio_display'];
  if ($paragraph_field_bio_display == 'profile') {
    foreach ($paragraph_field_bio as $paragraph_field_bio_item) {
      $field_settings['type'] == 'entity_reference_entity_view';
      $field_settings['settings']['view_mode'] == 'profile';
      $field_settings['label'] == 'hidden';
      $variables['content']['field_bio'] == $paragraph_field_bio_item->view($field_settings);
    }
  }
}

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.