Forums

Redirect User - to use Relative URL

hooi 24 Apr, 2011
Hi,

When using the "Redirect User" action, when setting the Target URL, can i use relative URL instead of absolute URL address?

I have a Chronoforms registration form eg. http://www.my_domain.com/registration.html, when a user has filled in the form, clicking on the "Next" button brings the user to another form for them to choose payment method, eg. http://www.my_domain.com/registration2.html. This registration2.html is just an article layout showing different payment options.

Therefore instead of specifying the full absolute url, i want to use relative url. This is because i'm currently developing the application on a temporary server, so when it's time to move to the live server, i won't have to make any changes if i can use relative url.

Thanks...

Best regards,
Hooi
GreyHead 24 Apr, 2011
Hi Hooi,

If you set a value in the form data before the ReDirect User action that will over-ride the Target URL in the ReDirect action (the ReDirect URL action does just this).

We can use this for a workaround. Add a Custom Code action and put in it
<?php
$relative_url = 'index.php';
$uri =& JFactory::getURI();
$form->data['redirect_url'] = $uri->base().$relative_url;
?>
Not tested and may need debugging.

The reason that you can't use a 'bare' relative url is that we validate the URL and trigger a debug message if it is invalid. I think a better answer than the workaround would be to add some more functionality to the the ReDirect User including a something like a #root# placeholder.

Bob
hooi 24 Apr, 2011
Hi Bob,

Thank you for your quick reply.

I've tested the code but it's not showing the page that i want to get directed to.

Your suggestion of a placeholder sounds good. i hoope that it becomes available in the next release. :wink:

Thanks.

Best regards,
Hooi
GreyHead 24 Apr, 2011
Hi Hooi,

I've tested the code but it's not showing the page that i want to get directed to.


What is it showing please?

Bob
hooi 24 Apr, 2011
Hi Bob,

It is bringing up the index page 'index.php'.
GreyHead 24 Apr, 2011
Hi Hooi,

Just checking. Have you changed this line to the url you want to redirect to?
$relative_url = 'index.php';

Bob
hooi 25 Apr, 2011
Thank you so much Bob! It's working now. 🙂
This topic is locked and no more replies can be posted.