Skip to content

Instantly share code, notes, and snippets.

@hans2103
Created July 22, 2013 10:40
Show Gist options
  • Save hans2103/6052941 to your computer and use it in GitHub Desktop.
Save hans2103/6052941 to your computer and use it in GitHub Desktop.
This piece of code can be used in Joomla extension RSForms! Pro. This piece of code will dynamical check a radio button depending on the last part of the URL you visit. Place this snippet in the field "items" of a Form Field type = "Radio Group". Example according to this snippet: visit URL http://example.com/path/to/last/element/product1 and it…
//<code>
$url = $_SERVER["REQUEST_URI"];
$tokens = explode('/', strtok($url, '?'));
$last_element = end(array_values($tokens));
$le = $last_element;
switch ($le) {
case 'product1':
$items = "item1[c]\nitem2\nitem3\nitem4\nitem5";
break;
case 'product2':
$items = "item1\nitem2[c]\nitem3\nitem4\nitem5";
break;
default:
$items = "item1\nitem2\nitem3\nitem4\nitem5";
break;
}
return $items;
//</code>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment