NAVIGATION
This shows you the differences between two versions of the page.
|
english:phpwcms-system:article:contentparts:form:special-applications:cp-after-form-input [2009/09/17 01:09] Knut Heermann (flip-flop) created |
english:phpwcms-system:article:contentparts:form:special-applications:cp-after-form-input [2018/06/03 18:09] (current) |
||
|---|---|---|---|
| Line 7: | Line 7: | ||
| **Certain content parts only deliver after filling out and sending a form.** \\ | **Certain content parts only deliver after filling out and sending a form.** \\ | ||
| - | FIXME translate and [en] images | + | FIXME better translate and [en]-images |
| - | Es gibt Anwendung, bei denen erst ein Formular ausgefüllt werden muss bevor bestimmte ContentParts für den Seitenbesucher verfügbar werden. Ein Login soll dazu nicht herangezogen werden. | + | There are some applications, with which only a form must be filled out before certain content parts for the site visitor to become available. A Login is not needed for it. |
| + | |||
| + | |||
| + | In the field "on success" the tag {SHOW_CONTENT:CP,XX} is registered, with which the CPs after mailing the form are represented. In this field **{**tags**}** cannot be registered directly, since a safety mechanism removes all **{**tags**}**. | ||
| + | |||
| + | There are two solutions: | ||
| + | |||
| + | **Demonstrated here by the example of a simple form with a downstream CP:** | ||
| + | * Completing the form | ||
| + | * Sending the form | ||
| + | * Automatic call of CPs | ||
| + | |||
| + | **The address of the CPs is not visible from outside.** | ||
| + | |||
| + | \\ | ||
| + | |||
| + | ===== Solution 1: ===== | ||
| + | |||
| + | **Condition:** -> [[http://www.phpwcms-docu.de/confincphp_de.phtml|/config/phpwcms/conf.inc.php]] \\ | ||
| + | * $phpwcms['allow_cntPHP_rt'] = 1; | ||
| + | |||
| + | \\ | ||
| + | For the field "on success" we'll make use of the [PHP] tag by inserting the direct function call of the tag {SHOW_CONTENT}. The **[**tags**]** in square brackets are permitted :-? | ||
| + | |||
| + | For reloading the CP with the ID=2 we would write: | ||
| + | <code php>[PHP]echo showSelectedContent('CP,2');[/PHP]</code> | ||
| + | |||
| + | That´s it, the CP ID=2 is loading after the form is filled in. | ||
| + | |||
| + | \\ | ||
| + | |||
| + | ===== Solution 2: ===== | ||
| + | |||
| + | However- we can achieve our goal with the assistance of a PHP script useing a new function. (Available since release r282). | ||
| + | |||
| + | This function can read, change and return all form inputs. It temporally puts itself between the submit action and the dispatching of the email. | ||
| + | |||
| + | The function call must be registered in the field like "PHP function:" below **"recipient - template:"**. //(See picture below)//. | ||
| - | Im Feld **"bei Erfolg"** wird der Tag {SHOW_CONTENT:CP,XX} eingetragen, mit dem die/der CP/s nach dem Absenden des Formulars dargestellt werden/wird. In diesem Feld können Tags nicht direkt eingetragen werden, da hier ein Sicherheitsmechanismus greift, der alle Tags entfernt. | ||
| - | Wir können allerdings mit der Hilfe eines PHP-Skripts, das eine neue Funktion verwendet, unser Ziel erreichen. (Verfügbar seit der Release r282). | ||
| - | |||
| - | Diese Funktion kann alle Formulareingaben lesen, verändern und zurückgeben. Sie legt sich zeitlich zwischen die Aktion submit und dem Versenden der eMail. | ||
| <note tip> | <note tip> | ||
| - | **Verändern** werden die eingegebene Daten mit einer Funktion im /frontend_init/ -Ordner. \\ | + | The entered data are **changed** with a function in the folder /frontend_init/. \\ |
| - | Siehe dazu: [[http://code.google.com/p/phpwcms/issues/detail?id=131|RT available in form generated E-Mail]] (Verfügbar seit [[http://code.google.com/p/phpwcms/source/detail?r=282|r282]]) | + | Have a look: [[http://code.google.com/p/phpwcms/issues/detail?id=131|RT available in form generated E-Mail]] (Available since [[http://code.google.com/p/phpwcms/source/detail?r=282|r282]]) |
| </note> | </note> | ||
| - | **Hier am Beispiel eines einfachen Formular mit einem nachgeschalteten CP demonstriert:** | ||
| - | * Ausfüllen des Formulars | ||
| - | * Absenden des Formulars | ||
| - | * Autom. Aufruf der CPs | ||
| - | |||
| - | **Die Adresse der CPs ist von außen nicht sichtbar.** | ||
| Docu: -- \\ | Docu: -- \\ | ||
| - | Forum: [[http://forum.phpwcms.org/viewtopic.php?p=119400#p119400|Galerie mit Formular verbinden]] | + | Forum: [[http://forum.phpwcms.org/viewtopic.php?p=119400#p119400|Galerie mit Formular verbinden]][DE] |
| **Autor:** [[http://planmatrix.de|K.Heermann]] //(flip-flop) (16.09.09)// \\ | **Autor:** [[http://planmatrix.de|K.Heermann]] //(flip-flop) (16.09.09)// \\ | ||
| Line 38: | Line 65: | ||
| - | **Bedingung:** -> [[http://www.phpwcms-docu.de/confincphp_de.phtml|/config/phpwcms/conf.inc.php]] \\ | + | **Condition:** -> [[http://www.phpwcms-docu.de/confincphp_de.phtml|/config/phpwcms/conf.inc.php]] \\ |
| * $phpwcms['allow_ext_init'] = 1; | * $phpwcms['allow_ext_init'] = 1; | ||
| \\ | \\ | ||
| + | ===== The script ===== | ||
| + | |||
| + | in **template/inc_sript/frontend_init/my_form_do_it.php** | ||
| + | |||
| + | Here is an example of calling the content part with the ID=2 | ||
| + | |||
| + | <code php|h my_form_do_it.php |h> | ||
| + | <?php | ||
| + | // ------------------------------------------------------------------------------------------- | ||
| + | // obligate check for phpwcms constants | ||
| + | if (!defined('PHPWCMS_ROOT')) { | ||
| + | die("You Cannot Access This Script Directly, Have a Nice Day."); } | ||
| + | // ------------------------------------------------------------------------------------------- | ||
| + | |||
| + | // Simple script for calling a CP from a form, after the submit | ||
| + | |||
| + | |||
| + | function my_form_do_it( &$postvar, &$form, &$mail ) { | ||
| + | |||
| + | $form['onsuccess'] .= '{SHOW_CONTENT:CP,2}'; | ||
| + | } | ||
| + | |||
| + | ?> | ||
| + | </code> | ||
| + | |||
| + | \\ | ||
| ---- | ---- | ||
| ---- | ---- | ||
| Line 49: | Line 102: | ||
| - | === Das Formular: === | + | === The form: === |
| ##example.com/r366/index.php?kategorie01## | ##example.com/r366/index.php?kategorie01## | ||
| Line 56: | Line 109: | ||
| - | === Das Ergebnis: === | + | === The result: === |
| ##example.com/r366/index.php?kategorie01#jumpForm1## | ##example.com/r366/index.php?kategorie01#jumpForm1## | ||
| Line 68: | Line 121: | ||
| - | === Der CP "Einfacher Text": === | + | === The CP "plain text": === |
| - | - Exemplarisch für jeden anderen CP/s in einem versteckten Bereich abgelegt. | + | |
| + | - As an example for any other CP. //(In a hidden area stored)//. | ||
| Line 75: | Line 129: | ||
| - | === Das einfache Formular: === | + | === Simple form: === |
| {{:deutsch:phpwcms-system:artikel:contentparts:formular:spezielle-anwendungen:cp-nach-formulareingabe04_de.gif|}} | {{:deutsch:phpwcms-system:artikel:contentparts:formular:spezielle-anwendungen:cp-nach-formulareingabe04_de.gif|}} | ||
| Line 81: | Line 135: | ||
| - | \\ | ||
| - | ~~UP~~ | ||
| - | ===== Das Skript ===== | ||
| - | in **template/inc_sript/frontend_init/my_form_do_it.php** | ||
| - | |||
| - | Hier beispielhaft der Aufruf des ContentPart mit der ID=2 | ||
| - | |||
| - | <code php > | ||
| - | <?php | ||
| - | // ------------------------------------------------------------------------------------------- | ||
| - | // obligate check for phpwcms constants | ||
| - | if (!defined('PHPWCMS_ROOT')) { | ||
| - | die("You Cannot Access This Script Directly, Have a Nice Day."); } | ||
| - | // ------------------------------------------------------------------------------------------- | ||
| - | |||
| - | // Einfaches Skript fur den Aufruf eines CPs aus einem Formular heraus nach dem submit. | ||
| - | |||
| - | |||
| - | function my_form_do_it( &$postvar, &$form, &$mail ) { | ||
| - | |||
| - | $form['onsuccess'] .= '{SHOW_CONTENT:CP,2}'; | ||
| - | } | ||
| - | |||
| - | ?> | ||
| - | </code> | ||