[ul_taxonomy]

Description

Link: [ul_taxonomy]
Author: Brian Loomis
Category: Output
Version: 8.x
License: Public Domain
Posted: Jun. 27, 2008
Updated: Jun. 28, 2008
More by this author...
This tag is used to return an unordered list based off of the xs_cat tags so that css flyout menus, or javascript jQuery madness can be applied for ultimate styling and sliding pleasure. http://www.cssplay.co.uk/menus/ See Stuart Nichols stuff. Once you get this tag implemented with xs_cat you will see how easy it is to optimize dynamic css menus from your database content. You can also modify the SQL generation easily enough to show only subnodes etc.

Parameters

-recurse integer, required
-css_id string, required

Sample Usage

<?LassoScript
var('br'='<br />');
var('gv_error'='');
var('comp_sql'='');
!(lasso_tagexists: 'xs_cat') ?
library:'/components/inSite/category_ctags.inc';
var(
		'cattable_resources'='pages',

		);



define_tag(
	'taxonomy',
	-namespace='ul_',
	-req='css_id',  -type='string',
	-req='recurse', -type='integer',
	-priority='replace',
	-description='Returns nested unordered lists of elements of a taxonomy within the given path.'
);
local('out')='';
var('SQL'	=	xs_cat->(fullCatSQL(-cattable= $cattable_resources ,-xtraReturn=', node.lft, node.rgt, node.description, node.metatags, node.metadescription, node.title_tag ',-xtraWhere='', -depth=#recurse)));
				
				inline(-username='xxx',-password='yyy', -database='zzz',,-SQL=$SQL, -maxrecords='500');
				var('depth'= integer(column('depth')));
					var('c_depth'= integer(column('depth')));
				#out += '<ul id="' #css_id '">\n' ('\t' * ($depth )) 
									records;
						var('c_depth'= integer(column('depth')));
					 if: integer(column('depth'))==$depth;;
					#out += ('\t' * ($depth + 1)) '<li class="li_' $c_depth  '">' column('title')  '</li>\n';
	
					else: integer(column('depth'))>$depth;
					#out += ('\t' * ($depth + 1)) '<ul>\n' ('\t' * ($depth + 2)) '<li class="li_' $c_depth  '">' column('title')  '</li>\n';

					else: integer(column('depth')) < $depth;
					#out += ('\t' * ($depth ))  ('</ul>\n' * ($depth )) '</ul>\n<ul>\n' ('\t' * ($depth )) '<li class="li_' $c_depth  '">' column('title')  '</li>\n';

					else;
					
					/if;
					var('depth'= integer(column('depth')));
					/records;
					#out += '<ul>\n';
				/inline;	
				return: #out;
		
/define_tag;

encode_smart:(ul_taxonomy: -recurse=2, -css_id='calendar');

?>

gets you:

<ul id="calendar">
	<li class="li_0">Databases</li>
	<ul>
		<li class="li_1">PostGreSQL</li>
		<li class="li_1">MySQL</li>
		<li class="li_1">FileMaker</li>
	</ul>

</ul>
						

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
define_tag(
	'taxonomy',
	-namespace='ul_',
	-req='css_id',  -type='string',
	-req='recurse', -type='integer',
	-priority='replace',
	-description='Returns nested unordered lists of elements of a taxonomy within the given path.'
);
local('out')='';
var:'cattable_resources' = 'pages'; //name of your taxonomy database
var('SQL'	=	xs_cat->(fullCatSQL(-cattable= $cattable_resources ,-xtraReturn=', node.lft, node.rgt, node.description, node.metatags, node.metadescription, node.title_tag ',-xtraWhere='', -depth=#recurse)));
				
				inline(-username='xxx',-password='yyy', -database='zzz',-SQL=$SQL, -maxrecords='500');
				var('depth'= integer(column('depth')));
					var('c_depth'= integer(column('depth')));
				#out += '<ul id="' #css_id '">\n' ('\t' * ($depth )) ;//'<li class="li_' $c_depth  '">' column('title')  '</li>\n';
					records;
						var('c_depth'= integer(column('depth')));
					 if: integer(column('depth'))==$depth;;
					#out += ('\t' * ($depth + 1)) '<li class="li_' $c_depth  '">' column('title')  '</li>\n';
	
					else: integer(column('depth'))>$depth;
					#out += ('\t' * ($depth + 1)) '<ul>\n' ('\t' * ($depth + 2)) '<li class="li_' $c_depth  '">' column('title')  '</li>\n';

					else: integer(column('depth')) < $depth;
					#out += ('\t' * ($depth ))  ('</ul>\n' * ($depth )) '</ul>\n<ul>\n' ('\t' * ($depth )) '<li class="li_' $c_depth  '">' column('title')  '</li>\n';

					else;
					
					/if;
					var('depth'= integer(column('depth')));
					/records;
					#out += '<ul>\n';
				/inline;	
				return: #out;
		
/define_tag;

 

Related Tags



Comments

none

Email:


Password:



Newest

Most Popular

Support tagSwap.net