Forums

Configuring redirect

hmmclark 26 Aug, 2010
hello - I'm doing a pro bono project for a local charity event. I need to redirect to this url:

http://www.hmmclark.com/polarexpress/index.php?option=com_registrationpro&view=event&Itemid=53&did=1

where the last value (did) will be different depending upon what folks want to register for.

I created a crude form:

http://www.hmmclark.com/polarexpress/index.php?option=com_chronocontact&Itemid=53

but can't get it to pass that last value correctly.

Sorry for being hopelessly dumb but I can't figure out what I'm doing wrong.

thank you,
Helen
GreyHead 26 Aug, 2010
Hi Helen,

Where are you creating the redirection URL?

I would change the submit buttons to read
<input type="submit" name="submit" value="Option 1" >
<input type="submit" name="submit" value="Option 2" >
<input type="submit" name="submit" value="Option 3" >

Then you can get the value after the form is submitted
<?php
$option = JRequest::getString('submit', '', 'post');
switch ($option( {
  case 'Option 1:
    $did = 1;
    break;
  case 'Option 2:
    $did = 2;
    break;
  case 'Option 3:
    $did = 3;
    break;
  default
    $did = 0;
    break;
}

Bob
hmmclark 26 Aug, 2010
Thank you for the quick response.

I was trying to use the redirect plugin but I think you are talking about just building it into the form, which sounds simpler.

However, since I am using the form wizard, I can't seem to find where change the names of the submit buttons. They've each been assigned a button_number name. I'll keep looking. I'm sure it is right under my nose.

Helen
hmmclark 26 Aug, 2010
I edited the button names but still can't pass the value through. I'm sure the problem is in the URL I'm using for the redirect.

Right now I'm using index.php?option=com_registrationpro&view=event (I figured out that the Itemid value wasn't needed) but don't know how to tell it to tack the $option value for did onto it.
GreyHead 26 Aug, 2010
Hi Helen,

You can edit the Form HTML by clicking the Form name link in the Forms Manager, then the Form Code tab and the [+/-] link to open the Form HTML box.

Add a hidden input to the Form HTML
<input type='hidden' name='did' value='' />


Change the OnSubmit before code code slightly
<?php
$option = JRequest::getString('submit', '', 'post');
switch ($option( {
  case 'Option 1:
    $did = 1;
    break;
  case 'Option 2:
    $did = 2;
    break;
  case 'Option 3:
    $did = 3;
    break;
  default
    $did = 0;
    break;
}
JRequest::setVar('did', $did);
?>
Then put did in the 'did' box in the ReDirect URL.

Bob
hmmclark 26 Aug, 2010
Thank you so much for your help. Are you really in Brittany? If yes, completely jealous even though it is a lovely day here in Vermont.

This is (I hope) my last stupid question ... how do I "put did in the 'did' box in the ReDirect URL"? I tried a bunch of different ways

index.php?option=com_registrationpro&view=event&did
index.php?option=com_registrationpro&view=event&did=did
index.php?option=com_registrationpro&view=event&did="did"
index.php?option=com_registrationpro&view=event&did="$did"

but haven't found the right way to get it on there.

thank you again,
h.
GreyHead 26 Aug, 2010
Hi Helen,

Yes I really am in Brittany - about as close to Vermont as you can get without getting your feet wet. And today it's been tipping down with rain here.

I hurried and made a few mistakes with the earlier code :-( Here's a version with the typos fixed
<?php
$option = JRequest::getString('submit', '', 'post');
switch ($option) {
  case 'Option 1':
    $did = 1;
    break;
  case 'Option 2':
    $did = 2;
    break;
  case 'Option 3':
    $did = 3;
    break;
  default:
    $did = 0;
    break;
}
JRequest::setVar('did', $did, 'post');
?>

Put this in the ReDirect Plugin 'Extra Code' tab and delete the old code from the OnSubmit Before box (it seems that doesn't get executed early enough).

Complete the Plugin general tab as it is in the image.

Put the url you want to redirect to into the Target URL box - but just the root like http://www.hmmclark.com

Remember to enable the plugin on the Form Plugins tab.

Bob
hmmclark 26 Aug, 2010
Ah, at least it is sunny here for a change.

Getting awfully close ... except it picks up the did value before the extra values. As a result it displays the right page, but with an error message at top.

Definitely not quitting my day job any time soon.

h.
GreyHead 26 Aug, 2010
Hi Helen,

The order of the parameters in the URL should make no difference. What is the error you see?

Bob
hmmclark 26 Aug, 2010
This is the URL that comes out:

http://www.hmmclark.com/polarexpress/index.php?did=1&option=com_registrationpro&view=event

The page displays somewhat normally but with an informational message at the top:

$_POST: Array ( [did] => [submit] => Option 2 [297f689d6a6e4d9461f8fe8bdaa83190] => 1 [1cf1] => 28d695a674521352ad6a4b01633d8f64 [chronoformname] => Purchaseoptions )

If you refresh the URL at this point, it comes back looking perfectly normal. So I guess it isn't exactly an error but it will sure scare off anyone wanting to register for the event.

I thought I might have inadvertently turned on some sort of debugging option. I checked under the "General" tab for the form and it is set to NO for debugging.

We may both be about to file this under "no good deed goes unpunished".

h.
GreyHead 26 Aug, 2010
Hi Helen,

There's an old bug in the plugin code. There are fixed versions in the forums here or you can open up components/com_chronocontact/plugins.redirect.php and comment out this line (it's around line 234)
        $doc =& JFactory::getDocument();
        $doc->addStyleDeclaration("div.debug {border:1px solid red; padding:3px; margin-bottom:3px;}");
        //$mainframe->enqueuemessage('$_POST: '.print_r($_POST, true)); // <-- comment this line
        $messages = array();

Bob
hmmclark 27 Aug, 2010
Works brilliantly! Thank you so much.

h.
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger