joomla:modalbox
Dies ist eine alte Version des Dokuments!
Inhaltsverzeichnis
Joomla - Modalbox
Wie stelle ich es an, dass gewisse Inhalte einer Komponente in einer Modalbox angezeigt werden?
Inhalt der Modalbox
Der Inhalt der Modalbox kann zum Beispiel mit einer eigenen Komponenten-View gefüllt werden.
Dazu werden folgende Dateien benötigt:
views/testview/view.raw.php
views/testview/tmpl/modalbox.php
- view.raw.php
<?php // No direct access defined('_JEXEC') or die; use \Joomla\CMS\Factory; /** * View class for modals */ class ComponentViewTestview extends \Joomla\CMS\MVC\View\HtmlView { /** * Display the view * * @param string $tpl Template name * @return void * @throws Exception */ public function display($tpl = null) { $app = Factory::getApplication(); $this->state = $this->get('State'); $this->params = $app->getParams('com_component'); // Check for errors. if (count($errors = $this->get('Errors'))) { throw new Exception(implode("\n", $errors)); } $this->_prepareDocument(); parent::display($tpl); } }
- modalbox.php
<?php // No direct access defined('_JEXEC') or die; //URL: index.php?option=com_component&view=testview&format=raw&layout=modalbox ?> <p>Inhalt der Modalbox</p>
Aufrufen der Modalbox
In diesem Beispiel wird die Modalbox in einer Komponenten-View, in dessen tmpl-file aufgerufen, indem auf den Link mit „Open Modalbox“ geklickt wird.
- default.php
<?php use \Joomla\CMS\HTML\HTMLHelper; use \Joomla\CMS\Router\Route; HTMLHelper::_('behavior.modal'); . . . <a id ="modalbox1" href="<?php echo Route::_('index.php?option=com_component&view=testview&format=raw&layout=modalbox'); ?>" class="modal">Open Modalbox</a>
Damit wird die Modalbox Funktionalität hinzugefügt
joomla/modalbox.1596115270.txt.gz · Zuletzt geändert: 30/07/2020 15:21 von Manuel