Skip to content

Instantly share code, notes, and snippets.

@zoglo
Last active November 10, 2023 19:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zoglo/c8759b559d3e3bf45350128189ddd904 to your computer and use it in GitHub Desktop.
Save zoglo/c8759b559d3e3bf45350128189ddd904 to your computer and use it in GitHub Desktop.
Enable usage of Xirdion - contao-modal-bundle with Bootstrap
<?php
if ($this->modalClass) {
$GLOBALS['TL_HEAD'][] = '<style>.modal-nobs{color:var(--modal-font-color);border:none;background:transparent}.modal-nobs.visible .modal-overlay{animation:.3s cubic-bezier(0,0,.2,1) modalFadeIn;display:flex}.modal-nobs.visible .modal-container{animation:.3s cubic-bezier(0,0,.2,1) modalSlideIn}.modal-nobs.hide .modal-overlay{animation:.3s cubic-bezier(0,0,.2,1) modalFadeOut;display:none}.modal-nobs.hide .modal-container{animation:.3s cubic-bezier(0,0,.2,1) modalSlideOut}</style>';
$this->modalClass = str_replace('modal ', 'modal-nobs ', $this->modalClass);
}
$this->extend('block_unsearchable');
?>
<?php $this->block('headline'); ?>
<?php $this->endblock(); ?>
<?php $this->block('content'); ?>
<?php if ($this->showModal): ?>
<?php if ($this->modalButton): ?>
<button id="modal-button-<?= $this->modalId ?>" class="js-modal-open modal-opener" data-modal="modal-<?= $this->modalId ?>"><?= $this->modalButton ?></button>
<?php endif; ?>
<dialog id="modal-<?= $this->modalId ?>" class="<?= $this->modalClass ?> hide js-modal" <?= $this->attributes ?>>
<div class="modal-overlay">
<div class="modal-container">
<button class="close modal-close js-modal-close" data-modal="modal-<?= $this->modalId ?>"></button>
<div class="inside">
<div id="<?= $this->contentId ?>" class="<?= $this->contentClass ?> modal-content">
<?php if ($this->headline): ?>
<<?= $this->hl ?> id="<?= $this->headlineId ?>" class="headline"><?= $this->headline ?></<?= $this->hl ?>>
<?php endif; ?>
<?php if ($this->html): ?>
<?= $this->html ?>
<?php endif; ?>
<?php if ($this->addImage): ?>
<?php $this->insert('image', $this->imageData); ?>
<?php endif; ?>
<?php if ($this->text): ?>
<?= $this->text ?>
<?php endif; ?>
<?php if ($this->url): ?>
<a class="hyperlink_txt" href="<?= $this->url ?>" title="<?= $this->titleText ?>"<?php if ($this->target): ?> target="_blank" rel="noopener"<?php endif; ?>>
<?= $this->linkTitle ?>
</a>
<?php endif; ?>
</div>
</div>
</div>
</div>
</dialog>
<?php endif; ?>
<?php $this->endblock(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment