• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: URL variable

URL variable 9 years 8 months ago #32249

  • andrea74
  • andrea74's Avatar
  • OFFLINE
  • Junior Boarder
  • Posts: 22
  • Thank you received: 1
Hello, I would like to capture a variable passed by URL and show it in a textbox but also like a simple text before the form.
I'm able to show it in the textbox thanks to this tutorial https://www.rsjoomla.com/support/documentation/rsform-pro/frequently-asked-questions/how-do-i-pass-a-parameter-through-the-url-and-how-can-i-catch-it-.html but I don't know to show it like a simple text: I tried to use "Free Text" field adding the code
//<code> echo $_GET['myvar'] //</code>

in "Text box" without success.
Thank you.
The administrator has disabled public write access.

URL variable 9 years 8 months ago #32279

  • bogdan.tataru
  • bogdan.tataru's Avatar
  • OFFLINE
  • Gold Boarder
  • Posts: 174
  • Thank you received: 40
In order to display the value from the value from a URL parameter in your freetext component of your form please follow these steps:

1. Head to Components > RSForm!Pro > Manage Forms > select your form
2. Add a free text component with the following text value "#$#" (or any other unique value)
3. While editing the form head to Properties tab and add the following code into the "Script called on form display" within the PHP Scripts tab:

$myparameter_value = JRequest::getVar('url_parameter');
if($myparameter_value!=''){
$formLayout = str_replace('#$#', $myparameter_value, $formLayout);
}else{
$formLayout = str_replace('#$#', '', $formLayout);
}

Where the 'url_parameter' is the parameter used in the URL in orde to show the simple text before the form.
My help is not official customer support. To receive assistance, submit a ticket by clicking here
The administrator has disabled public write access.
The following user(s) said Thank You: andrea74

URL variable 9 years 7 months ago #32381

This worked terrific and I modified it for my use to show current my URL:
$myparameter_value = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
if($myparameter_value!=''){
$formLayout = str_replace('myURL', $myparameter_value, $formLayout);
}else{
$formLayout = str_replace('myURL', '', $formLayout);
}

NOW, how can I save that URL to the form data on submit as well, not just display it. How can I go about doing this?

My end goal is to have a general website feedback form on all my pages of the site. When the user submits a feedback form, I want to capture the current URL. I would prefer this field be hidden.

Any help is greatly appreciated, thank you!
The administrator has disabled public write access.

URL variable 9 years 7 months ago #32396

  • adrianp
  • adrianp's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 631
  • Thank you received: 146
Hello,

You can capture the current URL within a hidden field as instructed here.
This is not official customer support. To receive your support, submit a support ticket here.
The administrator has disabled public write access.

URL variable 7 years 10 months ago #37036

Does this still work in the latest RS Form Pro ?

This my url:

index.php?option=com_rsform&view=rsform&formId=8&form[Name]=MyName&form[Event]=MySeminar

What do I have to use as 'url_parameter' ?

$myparameter_value = JRequest::getVar('Name'); or $myparameter_value = JRequest::getVar('[Name]'); or $myparameter_value = JRequest::getVar('form[Name]'); ???

None of them seem to work...
The administrator has disabled public write access.

URL variable 7 years 10 months ago #37048

  • bogdan.tataru
  • bogdan.tataru's Avatar
  • OFFLINE
  • Gold Boarder
  • Posts: 174
  • Thank you received: 40
Please note that JRequest::getVar() is no longer used, you should use JFactory::getApplication()->input->get() instead. Example:

$myparameter_value = JFactory::getApplication()->input->get('Name');
My help is not official customer support. To receive assistance, submit a ticket by clicking here
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!