Skip to content

This extension helps with the usage of Turbo in Contao applications.

License

Notifications You must be signed in to change notification settings

inspiredminds/contao-turbo-helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contao Turbo Helper

This extension helps with the usage of Turbo in Contao applications.

  • It provides a Turbo Frame wrapper as content elements.
  • It forces the status code to 422 Unprocessable Entity when a Contao form does not validate.
  • It forces a JavaScript load of a form's target URL, in case it would redirect to a URL outside the current domain.

Streams

You can also create streams within your legacy Contao PHP templates:

<!-- templates/mod_newslist.html5 -->
<?php $this->startTurboStream(); ?>
  <turbo-stream action="append" target="mod-newslist-articles-<?= $this->id ?>">
    <template><?= implode('', $this->articles) ?></template>
  </turbo-stream>
  <turbo-stream action="update" target="mod-newslist-pagination-<?= $this->id ?>">
    <template><?= $this->pagination ?></template>
  </turbo-stream>
<?php $this->endTurboStream(); ?>

<?php $this->extend('mod_newslist'); ?>

<?php $this->block('content'); ?>

  <?php if (empty($this->articles)): ?>
    <p class="empty"><?= $this->empty ?></p>
  <?php else: ?>
    <div id="mod-newslist-articles-<?= $this->id ?>">
      <?= implode('', $this->articles) ?>
    </div>
    <div id="mod-newslist-pagination-<?= $this->id ?>">
      <?= $this->pagination ?>
    </div>
  <?php endif; ?>

<?php $this->endblock(); ?>

The server will then respond with these streams if there was a request with Accept: text/vnd.turbo-stream.html (e.g. through a link with data-turbo-stream).

About

This extension helps with the usage of Turbo in Contao applications.

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages