Confirmation page

From FacileWiki

Quite often on filling in a form you will want to send a user to a success or confirmation page, this could be a standard page you have for you website or a form. This is easy enough to achieve using one of the four standard redirect functions contained in the FF piece library (see Understanding Pieces and Scripts for more info), here are the examples from the library...

Contents

Basic redirection (ff_redirect)

Basic redirection routine supporting multiple targets and methods.

Call:
 
ff_redirect($url [, $target='self' , $method='post'])

    $url    = The url to redirect to including the parameters appended.

    $target = 'top', 'parent', 'self' or 'blank'

              'top'    = redirect to the top browser window
              'parent' = redirect to the parent frame
              'self'   = redirect in the same frame (the default)
              'blank'  = redirect to a new browser window 
                         (blank works with post method only)

    $method = 'post' or 'get'. The default is 'post'.

    Example:

       ff_redirect(
          'http://mysite.net/index.php?option=xxx&Itemid=33',
          'top'
       );

Redirect to same form (ff_redirectSelf)

Redirects to the same form.

Call: 

    ff_redirectSelf($params = '');

Example:

    ff_redirectSelf('&ff_param_email='.urlencode($email));

Redirect to other form (ff_redirectForm)

Redirects to another facile form.

Call: 

    ff_redirectForm($name, $params = '');

Example:

    ff_redirectForm(
        $this, 
       'SecondForm', 
       '&ff_param_email='.urlencode($email)
    );

Redirect to other page (ff_redirectPage)

Redirects to another joomla/mambo page.

Call: 

    ff_redirectPage($params = '');

Example:

    ff_redirectPage(
        'index.php?option=com_content&task=blogsection&id=0&Itemid=39'
    );

Practical usage

All of the above pieces are used within the begin submit of your form, to trigger them you will have to submit the form, in the script tab of your submit button select the library type, from the list choose "ff_validate_submit" and save.

Next you need to setup the submit code, click edit form and select the submit pieces tab, then choose the custom radio button. As all of the redirect functions belong to the piece library they have to be initialized before they can be used, you do this by placing the following code at the top of the begin submit code...

//Load standard ff library functions
$this->execPieceByName('ff_InitLib');

You will need to use this peice of code whenever you use functions from the piece library, this is not exclusive to the submit section of the form.

Below are four practical examples using the redirect functions above...

Basic redirection example

The first example below would be used if you had a form containing your confirmation page, the second would be used if you had a standard confirmation page set as static content.

//Load standard ff library functions
$this->execPieceByName('ff_InitLib');

//redirect to a form
ff_redirect('{mossite}/index.php?option=com_facileforms&Itemid=1&ff_page=1','self');
//Load standard ff library functions
$this->execPieceByName('ff_InitLib');

//redirect to a joomla/mambo page
ff_redirect('{mossite}/index.php?option=com_content&task=view&id=1&Itemid=1','self');

Redirect to same form example

The example below would be used if you have your confirmation on page two of the same form.

//Load standard ff library functions
$this->execPieceByName('ff_InitLib');

//redirect to page 2
ff_redirectSelf('&ff_page=2');

Redirect to other form example

The example below would be used if the confirmation was contained in a new form.

//Load standard ff library functions
$this->execPieceByName('ff_InitLib');

//redirect to new form
ff_redirectForm($this, 'Confirmation_form', '&ff_page=1');

Redirect to other page example

The example below would be used to redirect to another page such as a static content page containing the confirmation.

//Load standard ff library functions
$this->execPieceByName('ff_InitLib');

//redirect to another page
ff_redirectPage('{mossite}/index.php?option=com_content&task=view&id=1&Itemid=1');

I hope you find this brief explanation of redirects and confirmation useful.

--Boldee 01:56, 31 January 2009 (CET)

| Terms of Use | Privacy | Sitemap |
Editing tools
Personal tools