Twig Portal plugin for Craft CMS
Adds a portal tag to Twig, to render DOM anywhere in the document.
Installation
Twig Portal is available in the Plugin Store. You can also install the plugin manually from the command line with the following commands.
composer require carlcs/craft-twigportal
php craft plugin/install twig-portal
Usage
_layout.html
<body>
{% block content %}
{% endblock %}
{{ portalTarget('modals') }}
</body>
index.html
{% extends '_layout' %}
{% block content %}
{{ include('_component') }}
{% endblock %}
_component.html
{% portal 'modals' %}
<p>This will be rendered where the “modals” portal target function is located.</p>
{% endportal %}