I am currently trying to display a list of nodes with a custom form containing taxonomy dropdowns (placed above node list) to filter out the contents. Now, on page load all content is displaying well by theming with custom template. Now my form is an Ajax form. After filtering I want to display the result with by using same template just passing the filter array of the node(s). Please find my ajax submit callback code.
render() works only if I pass nodes by loading node by viewMultiples. is there any way I can use similiar to
theme() of drupal 7 like
$nodes= Myclass::getNodesByEntityQuery($params); $build = \Drupal::entityTypeManager()->getViewBuilder('node')->viewMultiple($nodes, 'full'); $response = new AjaxResponse(); $response->addCommand( new HtmlCommand( '.result_message', '<div class="my_top_message">'.render($build).'</div>' ) ); return $response;
On page load I am theming
$page_params['content'] = MyClass::getNodesByEntityQuery($params); $build = [ '#theme' => 'my_content_build_page', '#page_params' => $page_params, ];
Can I reuse the same template in Ajax Callback?