Set the node view mode

Created on 15 January 2024, 6 months ago

Problem/Motivation

Hello,
i'm blocked with a simple thing : render a node with a view mode different depending on a field value

I think the problem comes from the way to render the node.
I try with the event "Prepare content entity view" and with "view Content entity".

It seems i miss something.

I have a content custom type : admission with a field : field_step which contain integer.
I want change the display (view mode) of the node depending of the value of this field.
I have also a custom display mode : Init (machine name : node.init)

If field_step.value == 0 then display node with view mode : Init
If field_step.value == 1 then display node with view mode : teaser
if field_step.value > 1 then display node with view mode : default

Impossible to find the solution and display the node with the right view mode.
To simplify the process, I have removed the condition on the field even if the condition is verified.

Your help is welcome.

Thanks

πŸ’¬ Support request
Status

Closed: duplicate

Version

1.1

Component

Code

Created by

πŸ‡«πŸ‡·France dsivori

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024