Dynamic Preview – Replace slider with a custom text message in admin preview
-
Hi there,
I have used the ‘Flexible Content’ field type to create different layouts, and one of it is a ‘photo slider’ layout.
Within the ‘Photo slider’ flexible layout, it has a ‘Relationship’ field to select one ‘slider’ from the Custom Post Type ‘Photo Slider'(screenshot: https://snipboard.io/Bs2duk.jpg).
In the admin preview, I don’t want to display the actual slider, but replace it with the following text message:
“[Photo Slider]Cannot display preview in the admin.”The slider will only be displayed in the front-end.
I did try to use these hooks: ‘Before Layout Render’ and ‘After Layout Render’, and did it in a similar way to replace gravity form shortcodes with a custom text message.
However, it doesn’t work the way I wanted.acfe/flexible/render/after_template/layout=my_layout acfe/flexible/render/before_template/layout=my_layout
my code:
add_action('acfe/flexible/render/before_template/layout=gallery_slider_block', 'flexible_disable_slider_preview', 10, 3); function flexible_disable_slider_preview($field, $layout, $is_preview){ if($is_preview){ echo '<div style="padding:50px 0; text-align:center; background:#f4f4f4;">[Photo Slider]<br> Cannot display preview in the admin. </div>'; } }
It does display the message in the admin, but the slider is still there in the admin preview. (screenshot: https://snipboard.io/ms5fIV.jpg)
I would like to replace the slider (which is using the ‘Relationship’ field type) with some text rather than displaying the slider in the admin preview.How can I accomplish this?
Thanks!
- The topic ‘Dynamic Preview – Replace slider with a custom text message in admin preview’ is closed to new replies.