Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By zenimagine on
I created 2 block views:
message_activity_stream_timeline_public
message_activity_stream_timeline_private
I added the following code in the TWIG template of my homepage :
<div class="main-timeline">
{{ drupal_view('message_activity_stream_timeline_public', 'block_1') }}
{{ drupal_view('message_activity_stream_timeline_private', 'block_1') }}
</div>
I do not want to display the 2 blocks at the same time I want to create a toggle button and switch from block message_activity_stream_timeline_public
to message_activity_stream_timeline_private
with ajax and vice versa.
How can I do this ?
Comments
One possible way is to create
One possible way is to create a custom module with custom block and form.
A block will be display a form.
A form will be contains two elements: 'checkbox' (toggle button) and 'view'.
In the 'buildForm' method we check the value of 'checkbox' element and depend on it display corresponded view.
See the example:
Form class
Block class
Thanks for your help ;-)
Thanks for your help ;-)