I use PHP scripts in the assets folder to process mails, or JavaScripts that contain German texts. It is not one of the basic functions of Kirby to translate these files. What is the usual solution for providing such scripts in multiple languages? This is also the case in other CMSs, where scripts for multilingual projects are integrated. Currently, I have duplicated them for each language (an absolutely inefficient way).
Here are two excerpts of how these scripts are structured:
Quform-Mailer:
$vorname = new Quform_Element('vorname', 'Vorname');
$vorname -> addFilter('trim');
$vorname -> addValidator('required', array(
'messages' => array(
'required' => 'Bitte den Vornamen eintragen.')));
$vorname -> addValidator('stringLength', array(
'min' => 2,
'max' => 100,
'messages' => array(
'too_short' => 'Der Vorname muss min. %1$d Zeichen enthalten. %3$d Zeichen ist zu wenig.',
'too_long' => 'Der Vorname darf max. %1$d Zeichen enhalten. %3$d Zeichen sind zu viel.')));
$form -> addElement($vorname);
Labels for form fields:
var $file = $(this).addClass('custom-file-upload-hidden'), // the original file input
$wrap = $('<div class="file-upload-wrapper d-flex align-items-stretch">'),
$input = $('<input type="text" class="file-upload-input" />'),
// Button that will be used in non-IE browsers
$button = $('<button type="button" class="file-upload-button">Datei auswählen</button>'),
// Hack for IE
$label = $('<label class="file-upload-button" for="'+ $file[0].id +'">Datei auswählen</label>');
Many thanks for the tip. I have never worked with the proposed solution before, so I need some “support for newbies”. However, the link you provided leads to a completely different topic:
(By the way: I really like using this script, it’s great!).
I’m not familiar with how it works, so I didn’t recognize the solution. Is there a simple example here in the forum or in a cookbook on how to load a PHP script from the assets folder?
I apologize for the delay. Unfortunately, my everyday life also consists of many customer appointments.
In the meantime, however, I have found out that the Quform nailer script cannot be used in several languages. A copy has to be created for each language. The developer has come up with an unfavorable strategy.
Unfortunately, I haven’t found out how to integrate external PHP scripts …
You can require the file where you need it. Maybe it would be better to convert it into a plugin. But this Quform thingy seems to be a Wordpress plugin rather than some independent package? I think there are many alternatives out there that are probably better suited to the job?
But this Quform thingy seems to be a Wordpress plugin
The Quform mailer is available as a WP plugin and as a standalone solution. It works excellently and reliably. I have been using it for many years on over 15 websites. I particularly like the configurable form validators and the query via AJAX. But the Quform mailer is also extremely complex. I suspect that instead of adapting the code to keep up with trending technologies, new functions have always been added again and again (the mailer has been around since 2010).
I think there are many alternatives out there that are probably better suited to the job?
I agree with you! Furthermore, I would much rather use the core functions of Kirby. However, the form input must be checked with AJAX, otherwise my captcha won’t work.
I had already tried your cookbook, but no mails arrived. That’s why I couldn’t use it.
Would this plugin be a help for creating complex forms?