RSS .92| RSS 2.0| ATOM 0.3
  • Home
  • About
  •  

    Getting rid of the javascript in Powermail

    Sometimes you do not want to use javascript as means of validation in the Powermail forms. Powermail can be set in the constants to either use the Mootools or the Prototype library. When for example using jQuery at the same time, you might want to disable the javascript in Powermail since most of the times you cannot use 2 different javascript libraries at the same time.

    Powermail PHP field validation

    At this moment jQuery is still not implemented in Powermail, though it seems they are working on it.  Unfortunately javascript cannot be switched of at the present (Powermail 1.5.3) via the constant editor. When using 2 different libraries chances are that for example jQuery or another lib might work ok and the field validation in Powermail will work fine with PHP. But.. the page contains errors and for example Internet Explorer will produce an annoying script error :

    Powermail Javascript error

    Powermail Javascript error in Internet Explorer

    Disable javascript in Powermail

    To get rid of this error and to get cleaner code you can do the following :

    In Typoscript, setup disable the loading of the js :

    page.includeJS.file31311 >
    page.includeJS.file31312 >
    page.includeJS.file31313 >
    page.includeJS.file31314 >
    page.headerData.31310 >
    

    This will make sure prototype.js (or mootools.js), effects.js, fabtabulous.js and checkbox.js are not loaded in the HTML source. The last line makes sure the validation script is not loaded. More info on disabling the javascript in Powermail here.

    Powermail javascript error in Internet Explorer

    You might wanna think that this would solve it, however after that another error appears :

    Powermail Javascript error

    Another javascript error with Powermail

    It seems in the source the following is the cause :

    <script type="text/javascript">
      function formCallback(result, form) {
         window.status = "valiation callback for form '"
         + form.id + "': result = " + result;
       }
        var valid = new Validation('MyNiceForm',
        {immediate : true, onFormValidate : formCallback});
    </script>
    

    So we need to get rid of that too. This is located in the Powermail extension file “templates/tmpl_formwrap.html”. This file can be edited via the Extension Manager, choose Loaded extensions, than click on Powermail and Edit files. After removing the script part, save the file.

    If you do see the message “SAVING IS DISABLED” instead of the save button go to the install manager first, find in all configuration “[noEdit]” (use ctrl-F in Firefox to search),  uncheck it and than scroll down totally and click on “Write to localconf.php”.

    2 Responses to “Getting rid of the javascript in Powermail”

    1. mtness says:

      Hi there!
      Thanks for this nice roundup.

      If you do not want to mess with the source fiels of the extension, you may use the TS constants of the ext, too.

      put this in the constants section of your TS-template:

      plugin.powermail {
      libraryToUse =
      template.formWrap = path/to/your/templates/tmpl_formwrap.html
      }

      Kind regards, mtness.

    2. katja says:

      THX …. after 1000 hours of searching and trying… THAT helps!!

      greetings katja

    Leave a Reply