Neuigkeiten
  • Die modified eCommerce Shopsoftware ist kostenlos, aber nicht umsonst.
    Spenden
  • Damit wir die modified eCommerce Shopsoftware auch zukünftig kostenlos anbieten können:
    Spenden
  • Thema: MODUL: Kontaktformular mit eigenem E-Mail Template

    astaller

    • Fördermitglied
    • Beiträge: 686
    • Geschlecht:
    Hallo,

    also ich habe mal versucht das umzusetzen für Shopversion 1.06.

    Altes Design der Kontaktformular Mail:

    [ Für Gäste sind keine Dateianhänge sichtbar ]

    So kann es mit dem neuen E-Mail Template beispielsweise formatiert werden:

    [ Für Gäste sind keine Dateianhänge sichtbar ]

    Die Änderungen wurde in der "includes/contact_us.php" vorgenommen und befinden sich zwischen den Zeilen (ab Nr. 67)

    // BOF - Template-Datei für Kontaktformular verwenden
    // EOF - Template-Datei für Kontaktformular verwenden

    Code: PHP  [Auswählen]
    <?php
    /* -----------------------------------------------------------------------------------------
       $Id: contact_us.php 4321 2013-01-15 16:42:37Z web28 $

       modified eCommerce Shopsoftware
       http://www.modified-shop.org

       Copyright (c) 2009 - 2013 [www.modified-shop.org]
       -----------------------------------------------------------------------------------------
       based on:
       (c) 2006 XT-Commerce

       Released under the GNU General Public License
       ---------------------------------------------------------------------------------------*/


    //included by shop_content.php

      //use contact_us.php language file
      require_once (DIR_WS_LANGUAGES.$_SESSION['language'].'/contact_us.php');
     
      $error = false;
      if (isset ($_GET['action']) && ($_GET['action'] == 'send')) {

        //BOF - web28 - 2010-04-03 - New error handling for required fileds
        //jedes Feld kann hier auf die gewünschte Bedingung getestet und eine Fehlermeldung zugeordnet werden
        //BOF error handling
        $err_msg = '';
        if (!xtc_validate_email(trim($_POST['email']))) $err_msg .= ERROR_EMAIL;
        if ((strtoupper($_POST['vvcode']) != $_SESSION['vvcode']) || $_SESSION['vvcode']=='') $err_msg .= ERROR_VVCODE;
        if (trim($_POST['message_body']) == '') $err_msg .= ERROR_MSG_BODY;
        //EOF error handling

        $smarty->assign('error_message', ERROR_MAIL . $err_msg);

        if ($err_msg != '') $error = true;

        //Wenn kein Fehler Email formatieren und absenden
        if (!$error) {
          // Datum und Uhrzeit
          $datum= date("d.m.Y");
          $uhrzeit= date("H:i");

          // BOF - Tomcraft - 2009-11-05 - Advanced contact form (additional fields)
          $additional_fields = '';
          if (isset($_POST['company']))  $additional_fields =  EMAIL_COMPANY. $_POST['company'] . "\n" ;
          if (isset($_POST['street']))   $additional_fields .= EMAIL_STREET . $_POST['street'] . "\n" ;
          if (isset($_POST['postcode'])) $additional_fields .= EMAIL_POSTCODE . $_POST['postcode'] . "\n" ;
          if (isset($_POST['city']))     $additional_fields .= EMAIL_CITY . $_POST['city'] . "\n" ;
          if (isset($_POST['phone']))    $additional_fields .= EMAIL_PHONE . $_POST['phone'] . "\n" ;
          if (isset($_POST['fax']))      $additional_fields .= EMAIL_FAX . $_POST['fax'] . "\n" ;
          // EOF - Tomcraft - 2009-11-05 - Advanced contact form (additional fields)

          // BOF - Tomcraft - 2009-11-05 - Advanced contact form (check for USE_CONTACT_EMAIL_ADDRESS)
          $use_contact_email_query = xtc_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'USE_CONTACT_EMAIL_ADDRESS'");
          $use_contact_email = xtc_db_fetch_array($use_contact_email_query);
          if ($use_contact_email['configuration_value'] == 'true') {
              $email = trim(CONTACT_US_EMAIL_ADDRESS);
            $name = CONTACT_US_NAME;
            $notify =  EMAIL_NOTIFY . "\n\n";
          } else {
            $email = trim($_POST['email']);
            $name = $_POST['name'];
            $notify =  '';
          }
          // EOF - Tomcraft - 2009-11-05 - Advanced contact form (check for USE_CONTACT_EMAIL_ADDRESS)

    // BOF - Template-Datei für Kontaktformular verwenden
    /* ORIGINAL
          $email_layout = sprintf(EMAIL_SENT_BY, CONTACT_US_NAME, CONTACT_US_EMAIL_ADDRESS, $datum , $uhrzeit) . "\n" .
                  "--------------------------------------------------------------" . "\n" . $notify .
                  EMAIL_NAME. $_POST['name'] . "\n" .
                  EMAIL_EMAIL. trim($_POST['email']) . "\n" .
                  // BOF - Tomcraft - 2009-11-05 - Advanced contact form (additional fields)
                  $additional_fields .
                  // EOF - Tomcraft - 2009-11-05 - Advanced contact form (additional fields)
                  "\n".EMAIL_MESSAGE."\n ". $_POST['message_body'] . "\n";

          xtc_php_mail($email,
                 $name,
                 CONTACT_US_EMAIL_ADDRESS,
                 CONTACT_US_NAME,
                 CONTACT_US_FORWARDING_STRING,
                 $email,
                 $name,
                 '',
                 '',
                 CONTACT_US_EMAIL_SUBJECT,
                 nl2br($email_layout),
                 $email_layout
                 );
    */

          $email_subject = sprintf(CONTACT_US_EMAIL_SUBJECT);

          $smarty->assign('language', $_SESSION['language']);
          $smarty->assign('tpl_path', 'templates/'.CURRENT_TEMPLATE.'/');    
          $smarty->assign('logo_path', HTTP_SERVER.DIR_WS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/img/');
          $smarty->assign('NAME', $_POST['name']);
          $smarty->assign('EMAIL', $_POST['email']);
          $smarty->assign('FIRMA', $_POST['company']);
          $smarty->assign('STRASSE', $_POST['street']);
          $smarty->assign('PLZ', $_POST['postcode']);
          $smarty->assign('STADT', $_POST['city']);
          $smarty->assign('TELEFON', $_POST['phone']);
          $smarty->assign('FAX', $_POST['fax']);
          $smarty->assign('MESSAGE', nl2br($_POST['message_body']));

          // dont allow cache
          $smarty->caching = false;

          // use template file
          $html_mail = $smarty->fetch(CURRENT_TEMPLATE.'/mail/'.$_SESSION['language'].'/contact_us.html');
          $txt_mail = $smarty->fetch(CURRENT_TEMPLATE.'/mail/'.$_SESSION['language'].'/contact_us.txt');

          // send mail
          xtc_php_mail($email, $name, CONTACT_US_EMAIL_ADDRESS, CONTACT_US_NAME, CONTACT_US_FORWARDING_STRING, $email, $name, '', '', $email_subject, $html_mail, $txt_mail);
    // EOF - Template-Datei für Kontaktformular verwenden

          if (!isset ($mail_error)) {
            xtc_redirect(xtc_href_link(FILENAME_CONTENT, 'action=success&coID='.(int) $_GET['coID']));
          } else {
            $smarty->assign('error_message', $mail_error);
          }
        }
        //EOF - web28 - 2010-04-03 - New error handling for required fileds
      }

      $smarty->assign('CONTACT_HEADING', $shop_content_data['content_heading']);
      if (isset ($_GET['action']) && ($_GET['action'] == 'success')) {
        $smarty->assign('success', '1');
        $smarty->assign('BUTTON_CONTINUE', '<a href="'.xtc_href_link(FILENAME_DEFAULT).'">'.xtc_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE).'</a>');

      } else {
        if ($shop_content_data['content_file'] != '') {
          ob_start();
          if (strpos($shop_content_data['content_file'], '.txt'))
            echo '<pre>';
          include (DIR_FS_CATALOG.'media/content/'.$shop_content_data['content_file']);
          if (strpos($shop_content_data['content_file'], '.txt'))
            echo '</pre>';
        $contact_content = ob_get_contents();
        ob_end_clean();
        } else {
          $contact_content = $shop_content_data['content_text'];
        }
        require (DIR_WS_INCLUDES.'header.php');

        // BOF - Tomcraft - 2009-11-05 - Advanced contact form (fix override by error request)
        if (isset ($_SESSION['customer_id']) && !$error) {
        // EOF - Tomcraft - 2009-11-05 - Advanced contact form (fix override by error request)
          $customers_name = $_SESSION['customer_first_name'].' '.$_SESSION['customer_last_name'];
          // BOF - Dokuman - 2009-09-04: preallocate email address on contact form
          //$email_address = $_SESSION['customer_email_address'];
          $c_query = xtc_db_query("SELECT * FROM ".TABLE_CUSTOMERS." WHERE customers_id='".(int)$_SESSION['customer_id']."'");
          $c_data  = xtc_db_fetch_array($c_query);
          $email_address = stripslashes($c_data['customers_email_address']);
          // EOF - Dokuman - 2009-09-04: preallocate email address on contact form
          // BOF - Tomcraft - 2009-11-05 - Advanced contact form (additional fields)
          $phone   = stripslashes($c_data['customers_telephone']);
          $fax     = stripslashes($c_data['customers_fax']);
          // BOF - Dokuman - 2010-10-14: preallocate additional fields on contact form correctly
          //$company  = stripslashes($c_data['entry_company']);
          //$street   = stripslashes($c_data['entry_street_address']);
          //$postcode = stripslashes($c_data['entry_postcode']);
          //$city     = stripslashes($c_data['entry_city']);
          $address_query = xtc_db_query("select
                            entry_company,
                            entry_street_address,
                            entry_city,
                            entry_postcode
                            from "
    . TABLE_ADDRESS_BOOK . "
                            where customers_id = '"
    . (int)$_SESSION['customer_id'] . "'
                            and address_book_id = '"
    . (int)$_SESSION['customer_default_address_id'] . "'");
          $address_data = xtc_db_fetch_array($address_query);
          $company  = stripslashes($address_data['entry_company']);
          $street   = stripslashes($address_data['entry_street_address']);
          $postcode = stripslashes($address_data['entry_postcode']);
          $city     = stripslashes($address_data['entry_city']);
          // EOF - Dokuman - 2010-10-14: preallocate additional fields on contact form correctly
          // EOF - Tomcraft - 2009-11-05 - Advanced contact form (additional fields)
        } elseif (!$error) {
            $customers_name = '';
            $email_address = '';
            $phone = '';
            $company = '';
            $street = '';
            $postcode = '';
            $city = '';
            $fax = '';
        }

        // BOF - Tomcraft - 2009-11-05 - Advanced contact form (product question)
        $products_info = '';
        // BOF - web28 - 2010-07-14 -  false clamp fixing
        //if (trim($_GET['products_name'] != '')) {$products_info= trim($_GET['products_name']);}
        //if (trim($_GET['products_model'] != '')) {$products_info= trim($products_info . ' - ' . trim($_GET['products_model']));}
        //if ($products_info != '') {$products_info = trim($_GET['question'])."\n" . $products_info . "\n"; }
        if (!empty($_GET['products_name'])) {$products_info = trim($_GET['products_name']);}
        if (!empty($_GET['products_model'])) {$products_info = trim($products_info . ' - ' . trim($_GET['products_model']));}
        if (!empty($_GET['question'])) {$products_question = trim($_GET['question'])."\n";}
        if ($products_info != '') {$products_info = $products_question . $products_info . "\n"; }
        // EOF - web28 - 2010-07-14 -  false clamp fixing
        if (!$error) $message_body = $products_info . "\n";
        // EOF - Tomcraft - 2009-11-05 - Advanced contact form (product question)

        $smarty->assign('CONTACT_CONTENT', $contact_content);
        //BOF - Dokuman - 2009-12-23 - send contact form information with SSL
        //$smarty->assign('FORM_ACTION', xtc_draw_form('contact_us', xtc_href_link(FILENAME_CONTENT, 'action=send&coID='.(int) $_GET['coID'])));
        $smarty->assign('FORM_ACTION', xtc_draw_form('contact_us', xtc_href_link(FILENAME_CONTENT, 'action=send&coID='.(int) $_GET['coID'], 'SSL')));
        //EOF - Dokuman - 2009-12-23 - send contact form information with SSL
        //BOF - web28 - 2009-07-28 - FIX SSL captcha image path
        $smarty->assign('VVIMG', '<img src="'.xtc_href_link(FILENAME_DISPLAY_VVCODES,'','SSL').'" alt="Captcha" />');
        //EOF - web28 - 2009-07-28 - FIX SSL captcha image path
        $smarty->assign('INPUT_CODE', xtc_draw_input_field('vvcode', '', 'size="8" maxlength="6"', 'text', false));
        $smarty->assign('INPUT_NAME', xtc_draw_input_field('name', ($error ? $_POST['name'] : $customers_name), 'size="30"'));
        $smarty->assign('INPUT_EMAIL', xtc_draw_input_field('email', ($error ? $_POST['email'] : $email_address), 'size="30"'));
        // BOF - Tomcraft - 2009-11-05 - Advanced contact form (additional fields)
        $smarty->assign('INPUT_PHONE', xtc_draw_input_field('phone', ($error ? $_POST['phone'] : $phone), 'size="30"'));
        $smarty->assign('INPUT_COMPANY', xtc_draw_input_field('company', ($error ? $_POST['company'] : $company), 'size="30"'));
        $smarty->assign('INPUT_STREET', xtc_draw_input_field('street', ($error ? $_POST['street'] : $street), 'size="30"'));
        $smarty->assign('INPUT_POSTCODE', xtc_draw_input_field('postcode', ($error ? $_POST['postcode'] : $postcode), 'size="30"'));
        $smarty->assign('INPUT_CITY', xtc_draw_input_field('city', ($error ? $_POST['city'] : $city), 'size="30"'));
        $smarty->assign('INPUT_FAX', xtc_draw_input_field('fax', ($error ? $_POST['fax'] : $fax), 'size="30"'));
        // EOF - Tomcraft - 2009-11-05 - Advanced contact form (additional fields)
        // BOF - Tomcraft - 2009-09-29 - fixed word-wrap in contact-form
        //$smarty->assign('INPUT_TEXT', xtc_draw_textarea_field('message_body', 'soft', 50, 15, ($error ? xtc_db_input($_POST['message_body']) : $first_name)));
        // BOF - Tomcraft - 2010-02-18 - Fixed width of textarea in FireFox under Linux.
        //$smarty->assign('INPUT_TEXT', xtc_draw_textarea_field('message_body', 'soft', 50, 15, ($error ? $_POST['message_body'] : $message_body)));
        $smarty->assign('INPUT_TEXT', xtc_draw_textarea_field('message_body', 'soft', 45, 15, ($error ? $_POST['message_body'] : $message_body)));
        // EOF - Tomcraft - 2010-02-18 - Fixed width of textarea in FireFox under Linux.
        // EOF - Tomcraft - 2009-09-29 - fixed word-wrap in contact-form
        $smarty->assign('BUTTON_SUBMIT', xtc_image_submit('button_send.gif', IMAGE_BUTTON_SEND));
        $smarty->assign('FORM_END', '</form>');
      }

      $smarty->assign('language', $_SESSION['language']);
      $smarty->caching = 0;
      $main_content = $smarty->fetch(CURRENT_TEMPLATE.'/module/contact_us.html');
    ?>

    Vieleicht mag da mal ein kluger Kopf mal drüber schauen und prüfen ob das so i.O. ist, funktionieren tut es :-)
    PS: Die für mich passende Template-Datei hab ich natürlich angelegt.
    Code: Text  [Auswählen]
    <table width="980" border="0" align="center" cellpadding="0" cellspacing="0" style="font-family:Verdana, Geneva, sans-serif; font-size:11px; margin:auto; width:980px;">
      <tr>
        <td><img src="{$logo_path}logo.gif"><br /><br /></td>
      </tr>
      <tr>
        <td>
          <table width="100%" border="0" cellpadding="3" cellspacing="0" style="font-family:Verdana, Geneva, sans-serif; font-size:11px;">
            <tr>
              <td>
                <p style="color:#1C3A82;"><strong>Sie haben eine Kontaktanfrage erhalten.</strong></p>
                <p><strong>Absender:</strong><br /><br />
                  Name: {$NAME}<br />
                  E-Mail: {$EMAIL}<br />
                  Firma: {$FIRMA}<br />
                  Strasse: {$STRASSE}<br />
                  PLZ: {$PLZ}<br />
                  Stadt: {$STADT}<br />
                  Telefon: {$TELEFON}<br />
                  Fax: {$FAX}
                </p>
              </td>
            </tr>
          </table>
          <br />
          <table width="100%" border="0" cellpadding="3" cellspacing="0" style="font-family:Verdana, Geneva, sans-serif; font-size:11px;">
            <tr>
              <td>
                <strong style="color:#1C3A82;">Nachricht:</strong>
                <p>{$MESSAGE}</p>
              </td>
            </tr>
          </table>
        </td>
      </tr>
    </table>

    MfG
    Achim S.

    [EDIT Tomcraft 21.06.2014: Installationsanleitung & Screenshots ergänzt.]

    Linkback: https://www.modified-shop.org/forum/index.php?topic=30433.0

    Tomcraft

    • modified Team
    • Gravatar
    • Beiträge: 46.366
    • Geschlecht:
    Re: MODUL: Kontaktformular mit eigenem E-Mail Template
    Antwort #1 am: 20. Juni 2014, 13:26:43
    Schaut gut aus, Dankeschön! :thx:

    Grüße

    Torsten

    noRiddle (revilonetz)

    • Experte
    • Beiträge: 13.975
    • Geschlecht:
    Re: MODUL: Kontaktformular mit eigenem E-Mail Template
    Antwort #2 am: 20. Juni 2014, 16:21:21
    Vielen Dank astaller, klasse (und überfällige) Idee.
    Hatte das auch mal für popup_content gemacht und das wurde von web28 in den Core übernommen.
    Hoffe, daß das mit der vorliegenden Idee ebenfalls geschieht.

    Gruß,
    noRiddle

    Dato

    • Mitglied
    • Beiträge: 214
    Re: MODUL: Kontaktformular mit eigenem E-Mail Template
    Antwort #3 am: 20. Juni 2014, 16:34:32
    Hallo,
    also ich habe mal versucht das umzusetzen für Shopversion 1.06.

    Hallo und Danke erstmal, aber für welche version genau ?

    1.06-r4642_SP1
    1.06-r4642
    1.06-r4356

    noRiddle (revilonetz)

    • Experte
    • Beiträge: 13.975
    • Geschlecht:
    Re: MODUL: Kontaktformular mit eigenem E-Mail Template
    Antwort #4 am: 20. Juni 2014, 16:38:49
    Das ist egal, die Code-Änderungen sind marginal und dürften überall gleich sein.

    Gruß,
    noRiddle

    astaller

    • Fördermitglied
    • Beiträge: 686
    • Geschlecht:
    Re: MODUL: Kontaktformular mit eigenem E-Mail Template
    Antwort #5 am: 20. Juni 2014, 16:45:16
    Yepp ganz genau ;-)
    Das geht von Version 1.05xx bis hoch zur neuen 2er Version.

    MfG
    Achim S.

    Dato

    • Mitglied
    • Beiträge: 214
    Re: MODUL: Kontaktformular mit eigenem E-Mail Template
    Antwort #6 am: 20. Juni 2014, 19:41:57
    Hallo,
    vielen Dank für die Antworten.
    Dann kann ich jetzt erstmal ein Update machen und hoffen das am Ende alles läuft. ;-)

    astaller

    • Fördermitglied
    • Beiträge: 686
    • Geschlecht:
    Re: MODUL: Kontaktformular mit eigenem E-Mail Template
    Antwort #7 am: 21. Juni 2014, 13:28:14
    Hallo,

    ich habe jetzt doch noch eine Installationsanleitung geschrieben und Screenshots angehängt.

    MfG
    Achim S.

    [EDIT Tomcraft 21.06.2014: Installationsanleitung & Screenshots in Beitrag 1 angehängt.]

    Tomcraft

    • modified Team
    • Gravatar
    • Beiträge: 46.366
    • Geschlecht:
    Re: MODUL: Kontaktformular mit eigenem E-Mail Template
    Antwort #8 am: 21. Juni 2014, 15:01:23
    Richtig hübsch, danke dir! :thx:
    Das wird seinen Weg in die neue Shopversion finden. :!:

    Grüße

    Torsten

    sl-chickery

    • Fördermitglied
    • Beiträge: 49
    Re: MODUL: Kontaktformular mit eigenem E-Mail Template
    Antwort #9 am: 21. Juni 2014, 15:19:40
    Danke für das klasse Modul.

    Habe es eben direkt eingebaut und die Farbe geändert.

     :-B

    sixtyseven

    • Fördermitglied
    • Beiträge: 107
    • Geschlecht:
    Re: MODUL: Kontaktformular mit eigenem E-Mail Template
    Antwort #10 am: 14. Juli 2014, 13:56:45
    Ich hab's noch mal ein wenig umgestrickt. Da nicht alle Templates über ein contact_us mailtemplate verfügen, habe ich die Originalfunktion drin gelassen und mittels einer file_exists abfrage nachgeschaltet.

    Außerdem habe ich die Abfrage der Sprachsession rausgenommen und die beiden benötigten mailtemplates in den root des mail ordners verschoben. Hintergrund: Der Shop-Admin muss m.E. die Mails nicht in Abhängigkeit der im Frontend gewählten Sprache erhalten  ;-)

    Hier meine Einbauanleitung:

    In includes/contact_us.php suchen:

    Code: PHP  [Auswählen]
    $email_layout = sprintf(EMAIL_SENT_BY, CONTACT_US_NAME, CONTACT_US_EMAIL_ADDRESS, $datum , $uhrzeit) . "\n" .
                      "--------------------------------------------------------------" . "\n" . $notify .
                      EMAIL_NAME. $_POST['name'] . "\n" .
                      EMAIL_EMAIL. trim($_POST['email']) . "\n" .
                      // BOF - Tomcraft - 2009-11-05 - Advanced contact form (additional fields)
                      $additional_fields .
                      // EOF - Tomcraft - 2009-11-05 - Advanced contact form (additional fields)
                      "\n".EMAIL_MESSAGE."\n ". $_POST['message_body'] . "\n";
         
              xtc_php_mail($email,
                     $name,
                     CONTACT_US_EMAIL_ADDRESS,
                     CONTACT_US_NAME,
                     CONTACT_US_FORWARDING_STRING,
                     $email,
                     $name,
                     '',
                     '',
                     CONTACT_US_EMAIL_SUBJECT,
                     nl2br($email_layout),
                     $email_layout
                     );

    ersetzen durch:

    Code: PHP  [Auswählen]
    // BOF: Template-Datei für Kontaktformular verwenden
              $email_subject = sprintf(CONTACT_US_EMAIL_SUBJECT);
         
              $smarty->assign('language', $_SESSION['language']);
              $smarty->assign('tpl_path', 'templates/'.CURRENT_TEMPLATE.'/');    
              $smarty->assign('logo_path', HTTP_SERVER.DIR_WS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/img/');
              $smarty->assign('NAME', $_POST['name']);
              $smarty->assign('EMAIL', $_POST['email']);
              $smarty->assign('FIRMA', $_POST['company']);
              $smarty->assign('STRASSE', $_POST['street']);
              $smarty->assign('PLZ', $_POST['postcode']);
              $smarty->assign('STADT', $_POST['city']);
              $smarty->assign('TELEFON', $_POST['phone']);
              $smarty->assign('FAX', $_POST['fax']);
              $smarty->assign('MESSAGE', nl2br($_POST['message_body']));
         
              // dont allow cache
              $smarty->caching = false;
         
                      $html_tmpl = CURRENT_TEMPLATE.'/mail/contact_us.html';
                      $txt_tmpl = CURRENT_TEMPLATE.'/mail/contact_us.txt';
                      if(file_exists(DIR_FS_DOCUMENT_ROOT.'templates/'.$html_tmpl) && file_exists(DIR_FS_DOCUMENT_ROOT.'templates/'.$txt_tmpl)){
                     
                              // use template file
                              $html_mail = $smarty->fetch($html_tmpl);
                              $txt_mail = $smarty->fetch(CURRENT_TEMPLATE.'/mail/'.$_SESSION['language'].'/contact_us.txt');
                     
                              // send mail
                              xtc_php_mail($email, $name, CONTACT_US_EMAIL_ADDRESS, CONTACT_US_NAME, CONTACT_US_FORWARDING_STRING, $email, $name, '', '', $email_subject, $html_mail, $txt_mail);
                             
                      } else {
                              // send normal mail
                             
                              $email_layout = sprintf(EMAIL_SENT_BY, CONTACT_US_NAME, CONTACT_US_EMAIL_ADDRESS, $datum , $uhrzeit) . "\n" .
                      "--------------------------------------------------------------" . "\n" . $notify .
                      EMAIL_NAME. $_POST['name'] . "\n" .
                      EMAIL_EMAIL. trim($_POST['email']) . "\n" .
                      // BOF - Tomcraft - 2009-11-05 - Advanced contact form (additional fields)
                      $additional_fields .
                      // EOF - Tomcraft - 2009-11-05 - Advanced contact form (additional fields)
                      "\n".EMAIL_MESSAGE."\n ". $_POST['message_body'] . "\n";
         
              xtc_php_mail($email,
                     $name,
                     CONTACT_US_EMAIL_ADDRESS,
                     CONTACT_US_NAME,
                     CONTACT_US_FORWARDING_STRING,
                     $email,
                     $name,
                     '',
                     '',
                     CONTACT_US_EMAIL_SUBJECT,
                     nl2br($email_layout),
                     $email_layout
                     );
                      }
        // EOF: Template-Datei für Kontaktformular verwenden

    Dann im Ordner templates/DEIN_TEMPLATE/mail die Datei contact_us.html mit folgendem Inhalt erstellen:

    Code: XML  [Auswählen]
    <table  width="100%" border="0" align="center" cellpadding="4" cellspacing="0">
      <tr>
        <td style="border-bottom: 1px solid; border-color: #cccccc;"><div align="right"><img src="{$logo_path}logo.gif"></div></td>
      </tr>
      <tr>
        <td><p><strong>Sie haben eine Kontaktanfrage erhalten. Nachfolgend die Details der Anfrage:</strong></p>
                <p><strong>Absender:</strong><br /><br />
                  <strong>Name:</strong> {$NAME}<br />
                  <strong>E-Mail:</strong> {$EMAIL}<br />
                  <strong>Firma:</strong> {$FIRMA}<br />
                  <strong>Strasse:</strong> {$STRASSE}<br />
                  <strong>PLZ:</strong> {$PLZ}<br />
                  <strong>Stadt:</strong> {$STADT}<br />
                  <strong>Telefon:</strong> {$TELEFON}<br />
                  <strong>Fax:</strong> {$FAX}</td>
      </tr>
      <tr>
            <td>
        <p><strong>Nachricht:</strong></p>
         <p>{$MESSAGE}</p></td>
      </tr>
    </table>
     

    danach im gleichen Ordner die Datei contact_us.txt imt folgendem Inhalt erstellen:

    Code: XML  [Auswählen]
    Sie haben eine Kontaktanfrage erhalten. Nachfolgend die Details der Anfrage:

    Absender:

    Name: {$NAME}
    E-Mail: {$EMAIL}
    Firma: {$FIRMA}
    Strasse: {$STRASSE}
    PLZ: {$PLZ}
    Stadt: {$STADT}
    Telefon: {$TELEFON}
    Fax: {$FAX}

    Nachricht:

    {$MESSAGE}

    Läuft wunderbar und ist kompatibel mit allen Templates

    noRiddle (revilonetz)

    • Experte
    • Beiträge: 13.975
    • Geschlecht:
    Re: MODUL: Kontaktformular mit eigenem E-Mail Template
    Antwort #11 am: 28. Juli 2014, 16:03:29
    Habe mir das mal gerade angeschaut.
    Um die $additional_fields variabel zu halten, denn dafür sind sie da, und um den Code zu straffen würde ich es so machen:
    Code: PHP  [Auswählen]
    // BOC: Template-Datei für Kontaktformular verwenden wenn vorhanden
        $email_subject = sprintf(CONTACT_US_EMAIL_SUBJECT);
         
        $smarty->assign('language', $_SESSION['language']);
        $smarty->assign('tpl_path', 'templates/'.CURRENT_TEMPLATE.'/');    
        $smarty->assign('logo_path', HTTP_SERVER.DIR_WS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/img/');
        $smarty->assign('NAME', $_POST['name']);
        $smarty->assign('EMAIL', $_POST['email']);
        $smarty->assign('ADDITIONAL_FIELDS', nl2br($additional_fields));
        $smarty->assign('MESSAGE', nl2br($_POST['message_body']));
         
        // dont allow cache
        $smarty->caching = false;
         
        $html_tmpl = CURRENT_TEMPLATE.'/mail/contact_us.html';
        $txt_tmpl = CURRENT_TEMPLATE.'/mail/contact_us.txt';
       
        $has_tpl = (file_exists(DIR_FS_DOCUMENT_ROOT.'templates/'.$html_tmpl) && file_exists(DIR_FS_DOCUMENT_ROOT.'templates/'.$txt_tmpl));
       
        if($has_tpl){
            // use template file
            $html_mail = $smarty->fetch($html_tmpl);
            $txt_mail = $smarty->fetch(CURRENT_TEMPLATE.'/mail/'.$_SESSION['language'].'/contact_us.txt');
        }                        
                         
        $email_layout = sprintf(EMAIL_SENT_BY, CONTACT_US_NAME, CONTACT_US_EMAIL_ADDRESS, $datum , $uhrzeit) . "\n" .
                                "--------------------------------------------------------------" . "\n" . $notify .
                                EMAIL_NAME. $_POST['name'] . "\n" .
                                EMAIL_EMAIL. trim($_POST['email']) . "\n" .
                                // BOF - Tomcraft - 2009-11-05 - Advanced contact form (additional fields)
                                $additional_fields .
                                // EOF - Tomcraft - 2009-11-05 - Advanced contact form (additional fields)
                                "\n".EMAIL_MESSAGE."\n ". $_POST['message_body'] . "\n";
         
        xtc_php_mail($email,
                     $name,
                     CONTACT_US_EMAIL_ADDRESS,
                     CONTACT_US_NAME,
                     CONTACT_US_FORWARDING_STRING,
                     $email,
                     $name,
                     '',
                     '',
                     ($has_tpl ? $email_subject : CONTACT_US_EMAIL_SUBJECT),
                     ($has_tpl ? $html_mail : nl2br($email_layout)),
                     ($has_tpl ? $txt_mail : $email_layout)
                    );

    // EOC: Template-Datei für Kontaktformular verwenden wenn vorhanden

    Natürlich muß dann noch das Template an den Smarty-Platzhalter ADDITIONAL_FIELDS angepasst werden.

    Außerdem sollte man noch Datum und Uhrzeit mit aufnehmen in die Smarty-Assigns.

    Gruß,
    noRiddle
    1 Antworten
    933 Aufrufe
    09. Juni 2021, 16:59:54 von Hans Bambel
    4 Antworten
    9155 Aufrufe
    30. März 2016, 11:38:50 von swolfram [templatix]
    18 Antworten
    20341 Aufrufe
    21. Januar 2013, 21:36:59 von Kwonga
    11 Antworten
    4467 Aufrufe
    28. August 2014, 20:11:45 von hgu