PHPackages                             heimrichhannot/contao-modal - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. heimrichhannot/contao-modal

AbandonedArchivedContao-module[Framework](/categories/framework)

heimrichhannot/contao-modal
===========================

A solid contao modal layer framework.

1.9.2(4y ago)45.9k[3 issues](https://github.com/heimrichhannot/contao-modal/issues)2LGPL-3.0+PHPPHP ~5.4 || ~7.0 || ^8.0

Since May 18Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/heimrichhannot/contao-modal)[ Packagist](https://packagist.org/packages/heimrichhannot/contao-modal)[ Docs](https://github.com/heimrichhannot/contao-modal)[ RSS](/packages/heimrichhannot-contao-modal/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (3)Dependencies (6)Versions (50)Used By (2)

Modal - A solid contao modal window framework
=============================================

[](#modal---a-solid-contao-modal-window-framework)

> This package is abandoned and no longer maintained.

Modal provides modal elements within modal archives. It works best together with *'heimrichhannot/contao-teaser'* and its teaser content elements.

Features
--------

[](#features)

- Url alias support with backlinks (browser history)
- extendable for other modal frameworks/libraries
- custom header/footer
- content elements within modal body
- inserttags
- works together with `contao-disclaimer`
- Bootstrap 3 and 4 support
- [Contao Components](https://github.com/heimrichhannot/contao-components) support

Setup
-----

[](#setup)

Install: `composer require heimrichhannot/contao-modal`

We recommend to disable the not used modal framework component in page layout.

### Insertags

[](#insertags)

Insert-TagDescriptionArguments`{{modal_url::*::*::*}}`Returns the modal url (usage: `Hier klicken`)1: modal id/alias, 2: jump to page id/alias, 3: auto\_item id or alias`{{modal_link::*::*::*::*}}`Returns the modal link1: modal id/alias, 2: jump to page id/alias, 3: link text &amp; title, 4: auto\_item id or alias`{{modal_link_open::*::*::*}}`Returns the modal link's opening tag (``).1: modal id/alias, 2: jump to page id/alias, 3: auto\_item id or alias`{{modal_link_close::*}}`Returns the modal link's closing tag (``) -&gt; Requires associated {{modal\_link\_open}} tag.1: modal id/alias### Hooks

[](#hooks)

NameArgumentsExpected return valueDescriptiongenerateModalUrl$arrRow, $strParams, $strUrl$strUrlModify the modal url.generateModal$objTemplate, $objModel, $objConfig, $objModalvoidModify the modal output.getModalContentElement$strContent, $objElement, $objTemplate, $objModel, $objConfig, $objModal$strContentModify the modal within content element.### Register custom modules to make usage of modal

[](#register-custom-modules-to-make-usage-of-modal)

If you want to register you list modules for example to make usage of the modal framework, you should enable by adding your module to the `$GLOBALS['MODAL_MODULES']`

```
config.php
/**
 * Modal module configuration
 */
$GLOBALS['MODAL_MODULES']['mymodule_list'] = array
(
	'invokePalette' => 'customTpl;', // The modal palette will be invoked after the field customTpl; as example
);

```

Than you have to implement the links within you list module. The following example is taken from the newslist implementation within the modal framework:

```
 public function parseArticlesHook(&$objTemplate, $arrArticle, $objModule)
 	{
 		if (!$objModule->useModal || $arrArticle['source'] != 'default') {
 			return false;
 		}

 		$objJumpTo = \PageModel::findPublishedById($objTemplate->archive->jumpTo);

 		if ($objJumpTo === null || !$objJumpTo->linkModal) {
 			return false;
 		}

 		$objModal = ModalModel::findPublishedByIdOrAlias($objJumpTo->modal);

 		if ($objModal === null) {
 			return false;
 		}

 		$objJumpTo = \PageModel::findWithDetails($objJumpTo->id);

 		$arrConfig = ModalController::getModalConfig($objModal->current(), $objJumpTo->layout);

 		$blnAjax = true;
 		$blnRedirect = true;

 		$objTemplate->link         = ModalController::generateModalUrl($arrArticle, $objTemplate->archive->jumpTo, $blnAjax, $blnRedirect);
 		$objTemplate->linkHeadline = ModalController::convertLinkToModalLink($objTemplate->linkHeadline, $objTemplate->link, $arrConfig, $blnRedirect);
 		$objTemplate->more         = ModalController::convertLinkToModalLink($objTemplate->more, $objTemplate->link, $arrConfig, $blnRedirect);
 	}

```

As you can see, we attach to the parseArticles HOOK and adjust all links with `ModalController::generateModalUrl()` or `ModalController::convertLinkToModalLink()` functions.

**To access the Reader entities it is necessary to link the redirect page with a modal. Add a new modal first, attach the reader modules as content element and select "link Modal" within the redirect page in the site structure and assign the previously created modal to the page.**

### Add custom modal framework

[](#add-custom-modal-framework)

To extend modal with your own framework, you have add the following:

#### Add your own modal config

[](#add-your-own-modal-config)

You have to register your custom modal within '$GLOBALS\['TL\_MODALS'\]'.

```
// my_module/config/config.php

/**
 * Modal types
 */
$GLOBALS['TL_MODALS']['my_custom_modal'] = array
(
	'header'   => true,
	'footer'   => true,
	'template' => 'modal_my_custom_modal',
	'link'     => array(
		'attributes' => array(
			'data-toggle' => 'modal',
		),
	),
	'js'       => array
	(
		'system/modules/my_module/assets/js/jquery.my_custom_modal.js',
	),
);

```

#### Add your modal template

[](#add-your-modal-template)

The modal template contains the complete markup of your modal framework. Add as much as possible.

```
// my_module/templates/modals/modal_my_custom_modal.html5
