Forums

remove some params from request url

mdma 20 Aug, 2015
Hello everyone!
i have redirect-action to
Url: http://www.domain2.com
when i submit looks like get request:
http://www.domain2.com/field=&field1=&button=button
is there some way to get rid of field=&field1=&button=button
there are alot options to add params, but how to remove?

is there an easier solution than javascript manipulation?
A chronoform-way?



anybody some hint?
mdma 20 Aug, 2015
Answer
ok now with custom js:
jQuery('#input1,#Input2,#button').removeAttr( 'name' ); 


would there be a "better chronoform" alternative?
GreyHead 21 Aug, 2015
1 Likes
Hi mdma,

The Redirect action will use only the UL and parameters that you set. If you don't need them, you can leave them out. ChronoForms does not ad field or button by default.

Bob
mdma 21 Aug, 2015
Hello Bob, You are totally right !! that came from my custom.js


i have seen the docu "get form data to php" but struggle a bit with understanding:
i need to get the form data of a datepicker(field1)
i have to explode the input Y-M-D and hand over to extra params of redirect dynamically:
day=D from field1
variable monthyear=M-Y from field1

is it realizable like this?
GreyHead 21 Aug, 2015
Hi mdma,

You can use a Custom Code action before the ReDirect to split up the date. Something like this should work:
<?php
$form->data['year'] = date( 'Y', strtotime($form->data['date']) );
$form->data['month_day'] = date( 'm-d', strtotime($form->data['date']) );
?>

Bob
mdma 21 Aug, 2015
and in extra params like this:

newparamname=year
newparamname=['year']

i ill try this thousand thanks..
mdma 21 Aug, 2015
i have a php switch for custom code..

you know how to pass dynmamically the redirect-url from custom code based on language?? or should i make multiple redirects for different lang-url?
mdma 21 Aug, 2015
is there some variable possible to hand over from custom code like?
$form->action['http://wwwredirect-url.com']
mdma 21 Aug, 2015
i ended up with event-action de,en,fr,it
<?php
$lang =& JFactory::getLanguage();
$tag =& $lang->getTag();

switch ( $tag ) {
  case 'de-DE':
  default:
    return 'de';
    break;
 case 'en-EN':
    return 'en';
   break;
 case 'it-IT':
    return 'it';
   break;
  case 'fr-FR':
    return 'fr';
   break;

}
?>

4 different redirects
slightly overkill of configuration...
what do you think may the locales worked maybe inside redirect action url?
GreyHead 21 Aug, 2015
Hi mdma,

What are the different URLs for the different languages?

I don't think that you can set the ReDirect action URL dynamically in CFv5. You could use an event switcher with an event for each language. Or, probably simpler you can use the Joomla! Redirection code
<?php
$app = \JFactory::getApplication();
$url = . . . . // some code here to build the url
$app->redirect($url);
?>

Bob
mdma 21 Aug, 2015
The Problem with the URL i have to reconstruct:
http://www.domain.com/xyz/ab/name.de.html ...de
http://www.domain.com/xyz/ab/name.en-gb.html ...en
http://www.domain.com/xyz/ab/name.it.html ...it
http://www.domain.com/xyz/ab/name.fr.html ...fr

There is a problem with this code cant figure out why it doesnt work (return, switch case problem?)
    <?php
    $lang =& JFactory::getLanguage();
    $tag =& $lang->getTag();

    switch ( $tag ) {
      case 'de-DE':
      default:
        return 'de';
        break;
     case 'en-EN':
        return 'en';
       break;
     case 'it-IT':
        return 'it';
       break;
      case 'fr-FR':
        return 'fr';
       break;

    }
    ?>
GreyHead 21 Aug, 2015
Hi mdma,

I don't quite see where your code fits - this version should do a redirection for you
<?php
$lang = \JFactory::getLanguage();
$tag =& $lang->getTag();
switch ( $tag ) {
  case 'de-DE':
  default:
    $temp = 'de';
    break;
  case 'en-GB':
    $temp = 'en-gb';
    break;
  case 'it-IT':
    $temp = 'it';
    break;
  case 'fr-FR':
    $temp = 'fr';
    break;
}
$url = "http://www.domain.com/xyz/ab/name.{$temp}.html";
$app = \JFactory::getApplication();
$app->redirect($url);
?>

Bob
mdma 22 Aug, 2015
1.)Thankyou alot! I totally checked everything!
2.)The event-code for events works! i had some custom js loading, thats why my events where not working.
3.)I tested now everything. and i came up to also replace the url through locales! it works too

Now i feel like: "havent seeing trees, standing in a forrest"!😶
mdma 22 Aug, 2015
redirect url: http://www.urltoredirectbutreplacethroughloales.com

Locale settings:

urltoredirectbutreplacethroughloales=urltogerman

output:

http://urltogerman.com
This topic is locked and no more replies can be posted.