[rp_grid]

Description

Link: [rp_grid]
Author: Randy Phillips
Category: Output
Version: 8.x
License: Public Domain
Posted: Jan. 24, 2006
Updated: Nov. 07, 2008
More by this author...

This tag is useful for displaying database query results or arrays from left to right in a HTML table grid. Just populate an array from a record set, specify the number of cells needed in each table row and rp_grid does the rest.

Parameters

-cell_content array, required The content that is to appear in each cell
-cell_count integer, required The number of cells to display in each table row
-width integer, optional Table Width. Defaults to 100% when not specified
-border integer, optional Table Border. Defaults to 0 when not specified
-cellpadding integer, optional Table cellpadding. Defaults to 2 when not specified
-cellspacing integer, optional Table cellscpasing. Defaults to 2 when not specified
-tablestyle string, optional The string name of the style to be applied to the table (if needed)
-cellstyle string, optional The string name of the style to be applied to the table cells (if needed)
-encodenone boolean, optional Use -encodenone to display table. Remove to display raw html.

Sample Usage

[rp_grid: 
  -cell_content=$my_array,
  -cell_count = 3,
  -border = 0,
  -width= 500,
  -cellpadding = 2,
  -cellspacing = 1,
  -tablestyle = 'mytablestyle',
  -cellstyle = 'mycellstyle',
  -encodenone]
						

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
<?LassoSCript
			
define_tag: 'grid', -namespace='rp_',

			-required='cell_content', -type=(array),
			-required='cell_count',
			-optional='width',
			-optional='border',
			-optional='cellpadding',
			-optional='cellspacing',
			-optional='tablestyle',
			-optional='cellstyle';
			
			if: !(local_defined:'width');
				local:'width' = '100%';
			/if;
			
			if: !(local_defined:'border');
				local:'border' = '0';
			/if;
			
			if: !(local_defined:'cellspacing');
				local:'cellspacing' = '2';
			/if;
			
			if: !(local_defined:'cellpadding');
				local:'cellpadding' = '2';
			/if;		
	
						
			// this math calculates how many extra table cells will be needed
			// when the #cell_content array size is not evenly divisible by #cell_count
			
			local:'mod' = #cell_content->size % #cell_count;
			local:'empty_cells' = #cell_count - #mod;
			local:'output' = (string);
			
			// begin building output here
			
			#output = '<table border="' + #border + '" cellpadding="' + #cellpadding + '" cellspacing="' + #cellspacing + '" width="' + #width + '"';
			
			
			// add stylesheet to table if specified here
			
			if: (local_defined:'tablestyle'); 
				#output +=  ' class="' + #tablestyle + '"'; 
			/if;
				
			#output += '>';
			
			#output += '<tr>';
						
			iterate: #cell_content, (local:'str');
				
				#output += '<td'; 
					
			// add stylesheet to cells if specified here
			
			if: (local_defined:'cellstyle'); 
				#output +=  ' class="' + #cellstyle + '"'; 
			/if;
				
			#output += '>' + #str + '</td>';
				
			if:(loop_count) % #cell_count == 0; 
				
			#output += '</tr><tr>';
			
			/if;
						
			/iterate;
				
							
			if: #empty_cells != #cell_count;
			
				loop: #empty_cells; 
				
					#output += '<td> </td>'; 
				
				/loop;
				
			#output += '</tr>';
			
			/if;		
				
			#output += '</table>';
			
			return: #output;
			
/define_tag;

?>

 

Comments

none

Email:


Password:



Newest

Most Popular

Support tagSwap.net