magda

After pressing OK, the Notice Window is shown

Files: Requires logging in with Slack to view/download
Screenshot from 2020-07-09 18-43-25.png
magda

Hey people 👋 I extended a gridfield with my own Gridfield action - it just sends an email to an email-address, saved in the chosen object. before I send the email, I validate the item, if an correct email-address is set. if not, I notify the User Controller::curr()->getResponse()->setStatusCode( 404, 'Invalid email-address!' ); works almost fine.. the user is notified with a notice-window BUT my problem.. if I send the Response with any Error-StatusCode like 404, 400 or 500 whatever, the Browser also shows following window, which confuses the user. how can i avoid it? or is there an other way to get the notice-window?

magda

Hey everyone 🙂 Is it possible to add Google Analytics or any tracking tool to the CMS? if yes, where do I have to add it? 🤔 I already added it to the Frontend, but I also need it in the CMS.

magda

@nightjarnz thx works fine with sessions. you're my king 😄

😗 (1) 🙂 (1) 👍 (1)
magda

hm okay.. I thought maybe I could avoid a pagereload when I just reload the form, but so I will try it with cookies. thx for your help 🙂

magda

the problem is, when I reload the form, the translated text is still the old one. what I am doing:

  1. click on Button english
  2. JS: ajax call to custom LocaleController and reload of form
    1. $('#English').on('click', function () {
    2. var url = '/locale/setLocale/en_US';
    3.  
    4. $.ajax({
    5. url: url,
    6. dataType: 'json',
    7. method: 'get'
    8. })
    9. .done(function ( response ) {
    10. //reload form
    11. $('#RegisterForm ').load(location.href + ' #RegisterForm>*', function () {
    12. render('recaptcha1'); //renders recaptcha again
    13. });
    14.  
    15. })
    16. .fail(function ( xhr ) {
    17. ...
    18. });
    19.  
    20. });

    and my Controller function:

    1. public function setLocale ( SS_HttpRequest $request ) {
    2.  
    3. $locale = $request->param( 'Locale' );
    4.  
    5. if( empty( $locale ) ) {
    6. return $this->sendJson( 'Locale must be given', 400 );
    7. }
    8.  
    9. if ( !i18n::validate_locale($locale) ) {
    10. return $this->sendJson( 'Locale not found', 404 );
    11. }
    12.  
    13. i18n::set_locale( $locale );
    14.  
    15. return $this->sendJson( 'Locale set to' . i18n::get_locale(), 200 );
    16.  
    17. }

    i think there is smth wrong with the reload of the form, but how could I reload the form, to use the new locale? It always use the default locale I set in _config.php

magda

@nightjarnz thx for your support. I'm not creating the form in the controller, it's in the .ss Template file like:

  1. <form id="RegisterForm" class="register-form" action="{$ApplicationBaseUrl}detail" method="post">
  2. <fieldset>
  3. <label class="label" for="emailLabel-1"><%t General.Email 'E-Mailadresse' %>
  4. <abbr class="req" title="required">*</abbr>
  5. </label>
  6. <input type="email" title="<%t General.Email 'E-Mailadresse' %> *" id="emailLabel-1" placeholder="<mailto:[email protected]|[email protected]>" name="email" required>
  7. .....
  8. </form>
magda

Any recommendations to solve the issue in another way is very welcome 😊

magda

Hey guys :) Is it possible to change the locale without pagereload? I have an application-form which should be available in 2 languages. Therefore i have 2 Buttons. One for german, one for english. Default is german. When i click on the english button, the locale is changed via ajax (call to custom controller and i18n::set_locale("en_US") ) and the form is reloaded. But unfortunately the text is still german. I am using <% t .. %> for the text.

I have no language Extension like fluent ... because the whole website is only available in German, just this one form should be translatable