Pre/Post Process specific page
Hi,
I am back with another question. :-)
I try to build the complete Site with the pages Module. Now I Have two Pages with a Contact form where I need to do some pre and postprocessing of the form. Is it possible to combine the CMS page with a controller?
Comments
http://docs.getfuelcms.com/general/pages-variables#controller
http://docs.getfuelcms.com/libraries/fuel_pages#func_render
Also, if you are creating a form, you may want to try out the Forms module here:
http://docs.getfuelcms.com/modules/forms
https://github.com/daylightstudio/FUEL-CMS-Forms-Module
I have created a page "aktuelles/presse" and a corresponding controller under application/controllers/aktuelles/presse.php" with a method index().
class Presse extends CI_Controller { public function index() { $this->fuel->pages->render("aktuelles/presse"); } }
Now only an empty site is displayed. The layout from the cms page is not rendered...
What have I done wrong?
When I open the page in the CMS it displays the warning that the page has already a controller method assigned, which in my point of view is correct.
echo "muh"; die();
in front of the render function call and it worked correctly.
I have another question according the Forms-Module.
I built 2 forms with it. In my existing page I have a custom css class for the submit button. Is it possible to configure the form to use this custom css class for the button?
I tried building the form via the html option:
{foreach $fields field } <p class="label">{$field['label']}</p> <p class="form">{$field['field']}</p> {/foreach} <p class="button"><input type="submit" name="sendeButton" value="Formular Senden" class="submitButton" /></p>
My fields are displayed correctly, but the submit button has no function...
$this->fuel->pages->render("aktuelles/presse", array(), array('render_mode' => 'cms'));
I changed the render method in Fuel_pages library to start with
echo "muh"; die();
but still I get a blank page...$this->fuel->pages->render("aktuelles/presse", array(), array('render_mode' => 'cms'));
Regarding your Form question, I'm not quite sure I understand what you mean by "has no function". Do you mean it doesn't have the class or isn't displayed? If you aren't using the HTML option, you can configure the form in your forms.php config to use an entire string of HTML for the "submit_button_text" property like so:
<input type="submit" name="sendeButton" value="Formular Senden" class="submitButton" />
The submit button is displayed, but clicking on it results in nothing. The form is not submitted. I will try the config thing now. I will report :-)
I tried to enter the html code in the cms directly, but that seems not to work.
For a manually created form using HTML, you'll want to include 2 additional hidden fields (if you view source on a generated one, you'll see them):
return_url: The URL to return to after submission
form_url: The URL to submit to
before I go on with manually creating the html.. perhaps I missed something in the docs of the form module...
My existing form looks like:
<form action="http://feuerwehr-bs.de/impressum/anfrage" method="post" accept-charset="utf8"><div style="display:none"> <input type="hidden" name="csrf_f5g5h7z5b4f3f6g4_t" value="65ab6f83f6d998c4caa2f67297f8e9bd" /> </div> <input type="hidden" name="betreff" value="Kontakt über Impressum" /> <p class="label"><label for="message">Nachricht</label></p> <p class="form"><textarea name="message"></textarea></p> <p class="label"><label for="name">Name</label></p> <p class="form"><input type="text" name="name" value="" /></p> <p class="label"><label for="redaktion">Redaktion / Organisation</label></p> <p class="form"><input type="text" name="redaktion" value="" /></p> <p class="label"><label for="email">E-Mail Adresse</label></p> <p class="form"><input type="text" name="email" value="" /></p> <p class="label"><label for="telefon">Telefon</label></p> <p class="form"><input type="text" name="telefon" value="" /></p> <p class="label"><label for="captcha_img">Captcha</label></p> <p><img src="http://feuerwehr-bs.de/captcha/1440658578.8249.jpg" width="150" height="50" style="border:0;" alt=" " /></p> <p class="label"><label for="captcha">Bitte den Text abtippen</label></p> <p class="form"><input type="text" name="captcha" value="" /></p> <p class="button"><input type="submit" name="sendeButton" value="Formular Senden" class="submitButton" /></p> </form>
Additionally I have defined to areas in the view to display validation messages or the success message if given...
I want to rebuild this form in FuelCMS. Until now I did not find a way to build the form via paragraphs instead of the standard table style, so I used the html option.
'form_display' => 'block', 'block_view' => 'application_form',
Similar to the example found in the link below which will point to a block file. The block file can have the HTML in it and it gets passed several variables where are references under the "Customizing the HTML" section.
http://docs.getfuelcms.com/modules/forms
ok got the form working until submission... Now I want to send the email. How can I access the defined mail recipient? I defined it under the "after submit" tab...
Calling the form function will also generate the form with the proper action value in the form tag. You can change this value but it will require you to create your own controller and validation.
You can access the forms object by doing something like the following:
$form = $this->fuel->forms->get('form_name'); print_r($form->email_recipients);
I have entered forms/process/impressum as form action in the cms. unter Form I selected the block view blocks/contact_form which consists of following code:
{foreach $fields field } <p class="label">{$field['label']}</p> <p class="form">{$field['field']}</p> {/foreach} <p class="button"><input type="submit" name="sendeButton" value="Formular Senden" class="submitButton" /></p>
On the resulting page the form tag is missing. What has to be entered in the block view, so that the form action gets generated?
<?php $form = $this->fuel->forms->get('form_name'); ?> <form action="<?=$form->form_action?>" method="POST">
do you know if there is some special configuration needed do get it running?
Error reported is:
220 smtprelay01.ispgateway.de ESMTP dfex hello: 250-smtprelay01.ispgateway.de Hello demo.feuerwehr-bs.de [80.67.28.147] 250-SIZE 104857600 250-8BITMIME 250-PIPELINING 250-AUTH PLAIN LOGIN 250-STARTTLS 250 HELP from: 250 OK data: 503 valid RCPT command must precede DATA Der SMTP-Fehler 503 valid RCPT command must precede DATA ist aufgetreten 500 unrecognized command Der SMTP-Fehler 500 unrecognized command ist aufgetreten Der E-Mail-Versand über SMTP ist fehlgeschlagen. Der Server muss möglicherweise für diese Methode konfiguriert werden. User-Agent: FeuerwehrBadSoden Date: Mon, 31 Aug 2015 12:13:41 +0200 From: <noreply@feuerwehr-bs.de> Return-Path: <noreply@feuerwehr-bs.de> Subject: =?utf-8?Q?Kontakt_über_Impressum?= Reply-To: "noreply@feuerwehr-bs.de" <noreply@feuerwehr-bs.de> X-Sender: noreply@feuerwehr-bs.de X-Mailer: FeuerwehrBadSoden X-Priority: 3 (Normal) Message-ID: <55e428d568b7e@feuerwehr-bs.de> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="B_ALT_55e428d568b89" This is a multi-part message in MIME format. Your email application may not support this format. --B_ALT_55e428d568b89 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Die folgenden Daten wurden aus dem impressum Formular übermittelt: Message: hallo Name: Habib Redaktion: test Email: habib@familiepleines.de Telefon: 1234 Url: http://demo.feuerwehr-bs.de/forms/process/impressum --B_ALT_55e428d568b89 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable Die folgenden Daten wurden aus dem impressum Formular übermittelt: Message: hallo Name: Habib Redaktion: test Email: habib@familiepleines.de Telefon: 1234 Url: http://demo.feuerwehr-bs.de/forms/process/impressum --B_ALT_55e428d568b89--
got another issue with the form builder.
The contact form works fine with a cms page.
Now I have another form:
The form is loaded via a controller which loads the cms page. But in this case the cms page is a special layout which results in layout blocks from the file system getting loaded.
In this view I call the form in following way:
<div class="kontaktformularOpener"><p class="link_open active" id="js_openKontakt"><a href="#" rel="js_contact">Kontaktformular öffnen</a></p></div> <div class="kontaktformularOpener"><p class="link_close" id="js_closeKontakt"><a href="#" rel="js_contact">Kontaktformular schließen</a></p></div> <div class="kontaktformular"> <?=form('presse')?> </div>
This results in
<div class="kontaktformularOpener"><p class="link_open active" id="js_openKontakt"><a href="#" rel="js_contact">Kontaktformular öffnen</a></p></div> <div class="kontaktformularOpener"><p class="link_close" id="js_closeKontakt"><a href="#" rel="js_contact">Kontaktformular schließen</a></p></div> <div class="kontaktformular"> <script src="/fuel/modules/forms/assets/js/jquery.validate.min.js?c=" type="text/javascript" charset="utf-8"></script> <script src="/fuel/modules/forms/assets/js/additional-methods.min.js?c=" type="text/javascript" charset="utf-8"></script> <script src="/fuel/modules/forms/assets/js/jquery.forms.js?c=" type="text/javascript" charset="utf-8"></script> <script src="/fuel/modules/forms/assets/js/forms.js?c=" type="text/javascript" charset="utf-8"></script> </div> </div>
The content of the form is not rendered...
What am I doing wrong? The form presse exists in the cms.