Board Logo

Substitutions in menu items structure
tigra - 11/20/2003 at 10:17 PM

It is possible to reduce the size and make maintenance of menu items structure of Tigra Menu (all versions) easier by using javascript variable for repeating text. For example original structure is:

var MENU_ITEMS0 = [
['Description', 'http://www.softcomplex.com/products/tigra_menu_gold/docs/#description', {'tw':'_top'}],
['Features', 'http://www.softcomplex.com/products/tigra_menu_gold/docs/#features', {'tw':'_top'}],
['Compatibility List', 'http://www.softcomplex.com/products/tigra_menu_gold/docs/#compatibility', {'tw':'_top'}],
['Files', 'http://www.softcomplex.com/products/tigra_menu_gold/docs/#files', {'tw':'_top'}],
['Building menu hierarchy', 'http://www.softcomplex.com/products/tigra_menu_gold/docs/#items', {'tw':'_top'},
['Item caption', 'http://www.softcomplex.com/products/tigra_menu_gold/docs/#items_caption', {'tw':'_top'}],
['Item link', 'http://www.softcomplex.com/products/tigra_menu_gold/docs/#items_link', {'tw':'_top'}],
['Submenu block items ', 'http://www.softcomplex.com/products/tigra_menu_gold/docs/#items_subitems', {'tw':'_top'}]
];

we can replace repeating {'tw':'_top'} by JavaScript varialbe containing this structure:

var tw = {'tw':'_top'};
var MENU_ITEMS0 = [
['Description', 'http://www.softcomplex.com/products/tigra_menu_gold/docs/#description', tw],
['Features', 'http://www.softcomplex.com/products/tigra_menu_gold/docs/#features', tw],
['Compatibility List', 'http://www.softcomplex.com/products/tigra_menu_gold/docs/#compatibility', tw],
['Files', 'http://www.softcomplex.com/products/tigra_menu_gold/docs/#files', tw],
['Building menu hierarchy', 'http://www.softcomplex.com/products/tigra_menu_gold/docs/#items', tw,
['Item caption', 'http://www.softcomplex.com/products/tigra_menu_gold/docs/#items_caption', tw],
['Item link', 'http://www.softcomplex.com/products/tigra_menu_gold/docs/#items_link', tw],
['Submenu block items ', 'http://www.softcomplex.com/products/tigra_menu_gold/docs/#items_subitems', tw]
];

or we can even go further:

var tw = {'tw':'_top'};
var dc = 'http://www.softcomplex.com/products/tigra_menu_gold/docs/';
var MENU_ITEMS0 = [
['Description', dc + '#description', tw],
['Features', dc + '#features', tw],
['Compatibility List', dc + '#compatibility', tw],
['Files', dc + '#files', tw],
['Building menu hierarchy', dc + '#items', tw,
['Item caption', dc + '#items_caption', tw],
['Item link', dc + '/#items_link', tw],
['Submenu block items ', dc + '#items_subitems', tw]
];

now note that having the same result we significantly reduced the size of the structure. And you can adjust multiple items at once editing only one variable. You can have as many different substitutions as you wish.


Softcomplex: http://www.softcomplex.com/
Back to forum: http://www.softcomplex.com/forum/