1. Go to this page and download the library: Download qstart-soft/html-modal library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
qstart-soft / html-modal example snippets
use Qstart\HtmlModal\AbstractModalContainer;
use Qstart\HtmlModal\ModalBuilderMethod;
use Qstart\HtmlModal\ModalName;
#[ModalBuilderMethod('buildModal')]
class ModalContainer extends AbstractModalContainer
{
#[ModalName('first-modal', 'second-modal')]
public function viewFirstModal($modalId, $modalName)
{
return $this->templating->render('modal-template');
}
#[ModalName('another-modal')]
#[ModalBuilderMethod(ModalBuilderMethod::EMPTY_BUILDER)]
public function viewAnotherModal($modalId, $modalName)
{
return $this->templating->render('another-modal-template');
}
public function buildModal($content)
{
// For example with Bootstrap Modal Component
return sprintf(
'<div class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Modal title</h5>
</div>
<div class="modal-body">%s</div>
<div class="modal-footer"></div>
</div>
</div>
</div>',
$content
);
}
}
use Qstart\HtmlModal\ModalBuilder;
use Qstart\HtmlModal\ModalConfig;
use Symfony\Component\Templating\PhpEngine;
class ModalController
{
public function actionShow(PhpEngine $templating, $modalName, $modalId = null)
{
$config = new ModalConfig(new ModalContainer(), $templating);
// Additional containers are connected by the following method:
$config->setContainers([]);
$builder = new ModalBuilder($config, $modalName, $modalId);
$content = $builder->getContent();
return $content;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.