[LI_URLRedirect]

Description

Link: [LI_URLRedirect]
Author: Eric Landmann
Category: Utility
Version: 8.x
License: Public Domain
Posted: Jun. 23, 2008
Updated: Jan. 01, 0001
More by this author...

Creates a URL redirect link of $xDebug =Y, otherwise redirects. Has the ability to pass error messages and parameters. This is useful for troubleshooting when you need to see the values being passed through an URL.

Parameters

none


Sample Usage

LI_URLRedirect: -Page='setup_editrecord.lasso',-ExParams=('DataType=Something'),-UseError='Y',-Error='1003',-Option='something', -UseArgs='Y';
						

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?Lassoscript
// Last modified 6/23/08 by ECL, Landmann InterActive
// For LDC 08 presentation

// Tagname			LI_URLRedirect
// Description		Creates a URL Redirect if live or a Link if $xDebug = 'Y'
// Author			Eric Landmann
// Date				6/23/2008
// Parameters		-Page		The page that is to be redirected to
//					-UseError	Whether or not to pass the error and option in the URL. Set to "Y" to pass.
//					-ExParams	Used to pass extra page parameters
//					-Error		The error code used
//					-Option		The error code option used
//					-UseArgs	Append the Client_POSTArgs if requested. Set to "Y" to pass.
// Usage			LI_URLRedirect: -Page='signup.lasso';
//					LI_URLRedirect: -Page='setup_editrecord.lasso',-ExParams=('DataType=Something'),-UseError='Y',-Error='1003',-Option='something', -UseArgs='Y';
//					LI_URLRedirect: -Page='setup_editrecord.lasso',-ExParams=('DataType=Something'),-UseError='Y',-Error='1003',-Option='something';
// Expected Output	If xDebug = Y, a link displays to be clicked on.
//					If xDebug != Y, a redirect to the page with the error and option passed
//					In both cases, Client_POSTArgs are passed.
// Dependencies		Expects to have $xDebug defined.
//					Looks for a possible definition of $vError and $vOption.
If: !(Lasso_TagExists:'LI_URLRedirect');
	Define_Tag: 'URLRedirect',
		-Required = 'Page',
		-Optional = 'ExParams',
		-Optional = 'UseError',
		-Optional = 'Error',
		-Optional = 'Option',
		-Namespace = 'LI_';
	
		Local:'Result' = string;
		Local:'URL' = string;
		Local:'ErrorOut' = string;
		Local:'OptionOut' = string;

		// Append the page and leading question mark
		#URL = ((#Page)'?');

		// Append on the Extra Params, if they exist
		If: (Local:'ExParams') != '';
			#URL += (#ExParams);
		/If;

		// Append the Error, but only if requested
		If: Local:('UseError') == 'Y';

			// Copy $vError to #Error, if #Error is not supplied to tag
			If: (Local:'Error') == '';
				#ErrorOut = (Var:'vError');
			Else;
				#ErrorOut = #Error;
			/If;
			// Copy $vOption to #Option, if #Option is not supplied to tag
			If: (Local:'Option') == '';
				#OptionOut = (Var:'vOption');
			Else;
				#OptionOut = #Option;
			/If;
			// Append the Error	
			If: #ErrorOut != '';
				#URL += ('&Error='(#ErrorOut));
			/If;
			// Append the Option
			If: #OptionOut != '';
				#URL += ('&Option='(#OptionOut));
			/If;
		/If;

		If: (Local:'UseArgs') == 'Y';
			// Append Client_PostArgs
			#URL += ('&'(Client_POSTArgs));
		/If;

		// Clean up the URL
		#URL->RemoveTrailing('&');
		#URL->(Replace: '?&', '?');

		If: $xDebug == 'Y';
			#Result = ('URLRedirect: <a href="'(#URL)'">'(#URL)'</a><br>\n');
		Else;
			Redirect_URL: #URL;
		/If;

		Return: Encode_Smart(#Result);

	/Define_Tag;

	Log_Critical: 'Custom Tag Loaded - LI_URLRedirect';

 /If;

?>

 

Comments

none

Email:


Password:



Newest

Most Popular