I create a customized module which replaces some string on Drupal Development Service entrance web page. For nodes, it work accurately, however it would not work on Drupal Development Service entrance web page. I wrote this code.
perform my_module_preprocess_page(&$variables) { if (Drupal::routeMatch()->getRouteName() == 'view.frontpage.page_1') { $generateBlock = NULL; $block_manager = Drupal::service('plugin.supervisor.block'); $block_config = []; $block_plugin = $block_manager->createInstance('id_block', $block_config); $block_build = $block_plugin->construct(); $block_content = render($block_build); $block = Drupalblock_contentEntityBlockContent::load(4); $render = Drupal::entityTypeManager()->getViewBuilder('block_content')->view($block); $physique = $render['body'][0]['#text']; $newContent = str_replace('---*block*---', $block_content, $physique); // I do not understand how render Drupal Development Service new modified content material from $newContent. return $variables; } }
I would like modify Drupal Development Service content material with a brand new string in $newContent
, however I can not save this content material to variables. My content material will not be modified.