Pre/Post Process specific page

edited August 2015 in Modules
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

  • edited 3:44AM
    but then this page will not be visible under pages in the backend won't it?
  • edited 3:44AM
    You could, for example, create a page in the backend with a location value of "contact" that has all the information you want to display the page. Then in your controller, you can call $this->fuel->pages->render('contact') to display the page.
    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
  • edited August 2015
    Hi,
    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.
  • edited 3:44AM
    Is it hitting the index method on the controller at all? I'd perhaps add an exit('test'); before $this->fuel->pages->render("aktuelles/presse"); to test if it outputs "test" to the browser.
  • edited 3:44AM
    yes, I added
    echo "muh"; die();
    in front of the render function call and it worked correctly.
  • edited 3:44AM
    Hi,

    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...
  • edited August 2015
    For the page not rendering in the controller, is their a view file at the same path? If so, try try adding the "render_mode" property like so:
    $this->fuel->pages->render("aktuelles/presse", array(), array('render_mode' => 'cms'));
  • edited 3:44AM
    No, there is no view file present and it doesn't work anyway
  • edited 3:44AM
    Hi,
    I changed the render method in Fuel_pages library to start with echo "muh"; die(); but still I get a blank page...
  • edited 3:44AM
    Sorry... the code snippet should have been the following (was missing the "render" part):
    $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" />
  • edited 3:44AM
    ok... the thing with page rendering works...

    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 :-)
  • edited 3:44AM
    hmmm how should I define the submit_button_text property? Do I have to have a $config['forms']['forms'] entry for each form I define in the cms?
    I tried to enter the html code in the cms directly, but that seems not to work.
  • edited 3:44AM
    The column fields for submit_value_text is only set to 50 characters so you'll need to up it for the html version.

    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
  • edited 3:44AM
    Hi,

    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.
  • edited 3:44AM
    You will need to create your own template to do this. In the fuel/application/config/forms.php config file, you can specify the:
    '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
  • edited 3:44AM
    Hi,

    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...
  • edited 3:44AM
    I'm not sure I quite understand what you mean by "access the defined mail recipient". The After Submit tab does have that information as to where to send the email.
  • edited 3:44AM
    Exactly that is the question. I have defined the Email under "After submit". How can I access that value in the controller?
  • edited 3:44AM
    Or how Do I have to submit the form to be automatically sent?
  • edited 3:44AM
    You can automatically process the form by using the form tags "action" attribute to point to forms/process/{formname}.

    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);
  • edited 3:44AM
    hmmm ok.
    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?
  • edited 3:44AM
    You could do something like:
    <?php $form = $this->fuel->forms->get('form_name'); ?> <form action="<?=$form->form_action?>" method="POST">
  • edited August 2015
    On processing the form I get an error from the email library. The library is configured identically to the one used on the current live platform where it works (without fuel, only CI.

    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_&uuml;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--
  • edited 3:44AM
    ah got it. I forgot to define a test_email in the config :-)
  • edited 3:44AM
    Hi,

    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&szlig;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&szlig;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.
  • edited 3:44AM
    If you instead create the form fields in the fuel/application/config/forms.php (as opposed to the cms), does that work? You may need to rename the one in the CMS or the config because the CMS one will be checked first. I'm trying to determine if it's simply the form isn't rendering or if it has something to do with it being in the CMS.
  • edited 3:44AM
    That variant works.
Sign In or Register to comment.