custom/dynamic Chrono fields (i.e. redirect)

Please post your suggestions or any hacks you have made here

custom/dynamic Chrono fields (i.e. redirect)

Postby spaceman on Tue Aug 28, 2007 2:03 am

Hey all,
I was just transferring some custom javascript over to chronoforms when I found I needed a dynamic redirect field instead of the 'static' one provided on the control panel.

So I did a minor hack to /components/com_chronocontact/chronocontact.php that I thought I'd share.

In my case, I wanted a dynamic redirect field (i.e. "How do you want to pay? <select name="payment_type" onchange="resetRedirect(this.form)" ><option value="Paypal">Paypal</option><option selected value="check">check</option>" and depending on the answer, the redirect is to the check URL or the paypal URL).

Solution
to FormHTM:
I added a hidden field called redirect
Code: Select all
<input type="hidden" name="redirect" value="http://mysite.com/thankyou_check.html">

(where http://mysite.com/thankyou_check.html is now the default to match the selected option value above.

to /components/com_chronocontact/chronocontact.php:
I changed the following section:
Code: Select all
       /**
        * Redirect the page if requested
        */
       if ( !empty($rows[0]->redirecturl) ) {
           mosRedirect($rows[0]->redirecturl);
       }

to read:
Code: Select all
       /**
        * Redirect the page if requested
        */
       if ( !empty($fields['redirect']) ) {
           mosRedirect($fields['redirect']);
       } else {
         if ( !empty($rows[0]->redirecturl) ) {
           mosRedirect($rows[0]->redirecturl);
         }
       }


to FormJavaScript:
I added something like
Code: Select all
function resetRedirect {
   var paypalUrl = 'https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=info%40mysite.com&item_name=MyItemName&amount=' 100'&currency_code=USD&return=http://mysite.com/thankyou_paypal.htm;

   if (theForm.payment_type.value == "Paypal"«») {
      theForm.redirect.value = paypalUrl;
   } else {
      theForm.redirect.value = "http://mysite.com/thankyou_check.htm";
   }
   
}


I figure you can do similar hacks to other Chrono fields. Hope this helps some similar situations out there.
STEVE
spaceman
Fresh Boarder
 
Posts: 1
Joined: Mon Aug 27, 2007 6:29 pm

Re:custom/dynamic Chrono fields (i.e. redirect)

Postby admin on Tue Aug 28, 2007 4:28 pm

Hi Spaceman,

Thanks very much for sharing your hack here with everybody, for those who can't hack the file and prefer to do the same function without the hack, just follow all spaceman steps but instead of hacking the core chronoforms file do this :

At the "on Submit Before email" field, please write this code :
Code: Select all
<?php
$rows[0]->redirecturl = $_POST['redirect'];

?>


this will override the static value in the CPanel of Chronoforms for the redirectURL ;)

Cheers

Max
ChronoForms/ChronoConnectivity/ChronoComments Developer Thanks for using our components!
If you have any problems with any extension please tell us.
If you like any of our extensions please post a review at Joomla.org
Want users to submit their content to your website ? try Submit Story
Want to list/edit/delete your data ? try ChronoConnectivity
Want to have stylish AJAX comments ? try ChronoComments
User avatar
admin
Platinum Boarder
 
Posts: 4283
Joined: Mon Aug 14, 2006 5:29 am


Return to ChronoForms Suggestions & Hacks

Who is online

Users browsing this forum: No registered users and 1 guest