banrep
unknown
php
3 years ago
2.2 kB
4
Indexable
function banrep_drupal_tools_form_alter(&$form, &$form_state, $form_id) { if ($form_id == 'block_content_basic_edit_form') { $configPageFooter = []; $configPageFooter[] =["target_id" => "monedafooter"]; $configPageFooter[] =["target_id" => "footermenubanrep"]; $configPageFooter[] =["target_id" => "menuinformaciondeinteresyayuda"]; $configPageFooter[] =["target_id" => "datosdecontacto"]; foreach ($configPageFooter as $key => $block) { $block = \Drupal\block\Entity\Block::load($block['target_id']); $uuid = $block->getPlugin()->getDerivativeId(); $block_content = \Drupal::service('entity.repository')->loadEntityByUuid('block_content', $uuid); if ($form_state->getformObject()->getEntity()->id() == $block_content->id()) { $form['actions']['submit']['#submit'][] = 'createFileFooter'; } } } } function createFileFooter() { $fichero_url = fopen("footer.css", "r"); $texto = ""; while ($trozo = fgets($fichero_url, 1024)) { $texto .= $trozo; } $html = '<style>' . $texto . '</style>'; //HTML $configPageFooter = []; $configPageFooter[] =["target_id" => "monedafooter"]; $configPageFooter[] =["target_id" => "footermenubanrep"]; $configPageFooter[] =["target_id" => "menuinformaciondeinteresyayuda"]; $configPageFooter[] =["target_id" => "datosdecontacto"]; $html .= '<footer class="footer-page" id="footer-page-banrep"> <div class="row">'; foreach ($configPageFooter as $key => $block) { $block = \Drupal\block\Entity\Block::load($block['target_id']); $uuid = $block->getPlugin()->getDerivativeId(); $block_content = \Drupal::service('entity.repository')->loadEntityByUuid('block_content', $uuid); if ($block_content) { $body = $block_content->body->value; $html = $html . '<div class="' . $block->getThirdPartySettings("block_class")["classes"] . '">'; if ($key > 1) { $html .= '<h2 class="block-title">' . $block->label() . '</h2>'; } $html .= $body . '</div>'; } } $html = $html . '</div> </footer>'; $archivo = fopen("archivo.html", "w") or die("error creando fichero!"); fwrite($archivo, $html); fclose($archivo); }
Editor is loading...