Skip to content

Instantly share code, notes, and snippets.

@Spellhammer
Last active August 15, 2022 10:30
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Spellhammer/3e18a7d6f67e3c75516e3f127a802b44 to your computer and use it in GitHub Desktop.
Save Spellhammer/3e18a7d6f67e3c75516e3f127a802b44 to your computer and use it in GitHub Desktop.
Check for presence of URL parameter condition for Oxygen
if( function_exists('oxygen_vsb_register_condition') ) {
global $oxy_condition_operators;
// Condition to check if a URL parameter is present.
oxygen_vsb_register_condition('URL Param Exists', array('options'=>array(), 'custom'=>true), array('--'), 'oxy_url_param_exists_callback', 'Other');
function oxy_url_param_exists_callback($value, $operator) {
if( isset($_GET[$value]) && $_GET[$value] ) {
return true;
} else {
return false;
}
}
// Condition to check if a URL parameter is NOT present.
oxygen_vsb_register_condition('URL Param Does Not Exist', array('options'=>array(), 'custom'=>true), array('--'), 'oxy_url_param_not_exists_callback', 'Other');
function oxy_url_param_not_exists_callback($value, $operator) {
if( isset($_GET[$value]) && $_GET[$value] ) {
return false;
} else {
return true;
}
}
}
@MarcBollmann
Copy link

MarcBollmann commented Nov 18, 2021

For anyone who needs to check for a key equals value condition here is a useful helper function which you can add into your snippets and then use it with oxygen -> dynamic data -> php return value

function url_param_key_equals_value($key, $value)
{
	foreach($_GET as $keyObj => $valueObj)
		{  
			if($keyObj == $key) {
				if($valueObj == $value) {
					return 'true';
				}
			}
		}
    return 'false';
}

image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment