0

I have a list box in my custom block with different theme options. On basis of the List box field value I would like to assign the specific twig template dynamically. What will be the best approach to do it and how ? If possible please provide a code snippet for the same.

2

See https://drupal.stackexchange.com/a/211157/31 for an existing related answer.

You implement the theme suggestions hook, the block_content entity is in $variables['elements']['content']['#block_content'] as shown there, then you can access your field values from there and provide any kind of template suggestions that you want.

|improve this answer|||||
  • Thanks Berdir for guiding me in the right direction.Can this be achieved by some other approach ? – user3560198 Oct 8 '16 at 11:01

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.