Page Blocks

Hosting sponsored by:

Point In Space

 

API: Gui

Filename:
fwpGui_menuVText.ctag

Released With:
5.0.0

Current Version:
1.1.0

Status: Active

Min Lasso Tested: 8.1.0

Max Lasso Tested: 8.5.3

Related:

Still don't get it?

Check out the talk list archives, or join and ask your questions.

Documentation Error or Request?

Email documentation corrections or comments

API Reference

fwpGui_vTextMenu (Tag)

Description

Creates a vertical text menu from either a structured config file, or an array which is structured identical to the config file format.

Highlighting of the current menu item is handled with a CSS span class name of fwptxtmenuhilite.

Syntax

[fwpGui_vtextmenu:
  -menu = menuName or literal array,
  -left = string,
  -fill = string,
  -paramsGET = string,
  -paramsFile = string,
  -paramsFldrs = string]

Menu Configuration File Format

The configuration file goes in the site or module /configs/ folder. The configuration file name must begin with mnuText_ which is then followed by the menuName and extension for a complete file name which might look like mnuText_colors.cnfg.

Each file has one line per menu item in the following fomat:

filePath```nameString```indent```highlight

Parameters & Member Tags

Tag Parameters:

-menu - required : accepts either the menuName portion of a configuration file name which will be in the global or local configs folder, or the complete root absolute file pathname to a file anywhere Lasso's file tags are configured to access. The menuName portion of the configuration file would be main from the file mnuText_name.cnfg' which must be located in a /configs/ folder.

-left - optional : a string of characters to be displayed at the left of each menu item after any applicable indenting

-fill - optional : a string of characters to use for each indent position. The default is a single non-breaking space per position to yield the appearance of indenting. If a fill character is specified, the indent is filled with this character pattern per position.

-paramsGET - optional : a string of comma separated names of variables to add to the link URL as standard URL GET form paramaters

-paramsFile - optional : a string of comma separated names of variables to add to the link URL in a modified format as created by the fwpPage_urlParamsFile tag

-paramsFldrs - optional : a string of comma separated names of variables to add to the link URL in a modified format as created by the fwpPage_urlParamsFldrs tag

Config File Parameters:

filepath - the menu item's link pathname

nameString - the string to display as the menu item's text

indent - for vertical menus this is the number of repetitions of either a default non-breaking space or a specified 'fill' character string.

highlight - a choice of none|page|path to select whether the menu item is highlighted based on the currentpage name, path name, or not at all. Highlighting of the current menu item is handled with a CSS span class name of fwptxtmenuhilite.

Configuration files may have blank lines and lines starting with # or // for commenting.

Examples

<p>[fwpGui_vtextmenu:
  -menu = 'colors2',
  -left = ' ',
  -fill = '::']</p>

To include parameters in the URL to pass to the link page:

[var:'p1'='fakedata']
[var:'p2'='fakedata']

<p>[fwpGui_vtextmenu:
  -menu = 'colors',
  -left = '::: ',
  -paramsFile = 'p1, p2']</p>

Menus can be defined on the fly by submitting an array rather than the name of a configuration file:

<p>[fwpGui_vtextmenu:
  -menu = (array: 
    '/demo/menus.lasso```Menu```0```none\r',
    '/demo/menus.lasso```From```0```none\r',
    '/demo/menus.lasso```An Array```0```none\r'),
  -left = '::: ']</p>
<p>[fwpGui_vtextmenu:
  -menu = 'shapes',
  -left = ' ']</p>

Sample Configuration File:

/demo/menus.lasso```Simple Shapes```0```none
/demo/menus.lasso```Square```4```none
/demo/menus.lasso```Circle```4```none
/demo/menus.lasso```Rectangle```4```none
/demo/menus.lasso```Complex Shapes```0```none
/demo/menus.lasso```Two Dimensional```4```none
/demo/menus.lasso```Trapezoid```8```none
/demo/menus.lasso```Ellipsis```8```none
/demo/menus.lasso```Three Dimensional```4```none
/demo/menus.lasso```Sphere```8```none
/demo/menus.lasso```Cylinder```8```none
/demo/menus.lasso```Pyramid```8```none

See also the /demo/menus page for more examples.

Source Code

View in separate window

<?lassoscript
//............................................................................
//
//    pageblocks: (c) 2002-2007 http://www.pageblocks.org/
//
//............................................................................
/*

    {fileName=        fwpGui_menuVText.ctag }
    {rsrcType=        tag }
    {rsrcName=        fwpGui_vtextmenu }
    {rsrcHTTP=        www.pageblocks.org/refc/fwpGui_vtextmenu }

    {lassoVrsnMin=    8.1.0 }
    {lassoVrsnMax=    8.5.3 }

    {author=        Greg Willits }
    {authorEmail=    subscribe to pbTalk at www.pageblocks.org/talk/ }

    {desc=            Creates a vertical text menu from either
                    a structured config file (mnuText_), or an array which
                    is structured identical to the config file format. }

    {maintvsrn=        1.2 }
    {maintrelease=    5.2.0 }
    {maintdate=        2007-06-09 }
    {maintauthor=    Greg Willits }
    {maintnotes=    added process to menuItemTitle to allow for MVS,
                     changed internal vars names for better readability }

    {maintvsrn=        1.1 }
    {maintrelease=    5.1.0 }
    {maintdate=        2006-05-26 }
    {maintauthor=    Greg Willits }
    {maintnotes=    converted timers to fwp_timer ctype }

    {maintvrsn=        1.0 }
    {maintrelease=    5.0.0 }
    {maintdate=        2006-01-16 }
    {maintauthor=    Greg Willits }
    {maintnotes=    initial release }

*/
//............................................................................

define_tag:'fwpGui_vtextmenu', -priority='replace',
    -optional='menu',
    -optional='left',
    -optional='fill',
    -optional='paramsGet',
    -optional='paramsFile',
    -optional='paramsFldrs';

    $fw_debugTimers ? $fw_timer->(start:'menuTagVtext');

    local:
        'menuConfigSource'    = @local:'menu',
        'menuBorderLeft'    = @local:'left',
        'menuFill'            = @local:'fill',
        'paramsViaGet'        = local:'paramsGet',
        'paramsViaFile'        = local:'paramsFile',
        'paramsViaFldrs'    = local:'paramsFldrs',
        'linkPath'            = string,
        'linkFile'            = string,
        'thisParam'            = string,
        'menuConfigData'    = string,
        'menuConfigLine'    = string,
        'menuMarkup'        = string,
        'menuItemIndx'        = 0,
        'currentPage'         = ((response_filepath)->split:'/')->last,
        'currentPath'         = (response_filepath) - #currentPage;

    !(#menuFill)
        ? #menuFill = '&nbsp;';

    #paramsViaGet
        ? #paramsViaGet = (fwpCnfg_splitComma: #paramsViaGet);

    #currentPage >> fw_kURLparamsChar
        ? #currentPage = ((response_filepath)->split: fw_kURLparamsChar)->last;

    if: #currentPath >> '/-/';
        #currentPath = #currentPath->(split:'/-/')->get:1;
        #currentPath += '/';
    /if;

//    if menuConfigSource is a string then it`s a file name to be loaded

    if: (#menuConfigSource->type == 'string') || (#menuConfigSource->type == 'bytes');

        #menuConfigData = (fwpCnfg_loadLines: ('mnuText_' + #menuConfigSource + fw_kCnfgExt));

//    if menuConfigSource is already an array then we have direct config info

    else: #menuConfigSource->type == 'array';

        #menuConfigData = #menuConfigSource;

    /if;


//    start building the menu

    iterate: #menuConfigData, #menuConfigLine;

        if: 
            (#menuConfigLine->(beginswith:'#') == true) || 
            (#menuConfigLine == '');

        else;

            local:'menuConfigItems' = #menuConfigLine->split:'```';
            local:
                'menuItemLink'        = #menuConfigItems->get:1,
                'menuItemTitle'        = #menuConfigItems->get:2,
                'menuItemIndent'    = #menuConfigItems->get:3,
                'menuItemMatchBy'    = #menuConfigItems->get:4;

            local:'menuURLItems'    = (#menuItemLink->(split:'/'));
            local:'menuLinkPage'    = (#menuURLItems->last);
            local:'menuLinkPath'    = (#menuItemLink);
            #menuLinkPath->(removeTrailing:#menuLinkPage);

            (#menuMarkup) += (#menuFill * integer:#menuItemIndent);
            (#menuMarkup) += (#menuBorderLeft);

            if: #paramsViaGet->type == 'array';

                (#menuItemLink) += '?';
                iterate: #paramsViaGet, #thisParam;
                    if: #thisParam >> '=';
                        (#menuItemLink) += ((#thisParam->split:'=')->get:1) + '=' + ((#thisParam->split:'=')->get:2) + '&amp;';
                    else;
                        (#menuItemLink) += #thisParam + '=' + (var:#thisParam) + '&amp;';
                    /if;
                /iterate;
                #menuItemLink->(removeTrailing:'&amp;');

            else: #paramsViaFile;

                #linkFile = (#menuItemLink->split:'/')->last;
                #linkPath = #menuItemLink - #linkFile;
                (#menuItemLink) = (fwpPage_urlParamsFile: -folder=#linkPath, -page=#linkFile, -vars=#paramsViaFile);

            else: #paramsViaFldrs;

                #linkFile = (#menuItemLink->split:'/')->last;
                #linkPath = #menuItemLink - #linkFile;
                (#menuItemLink) = (fwpPage_urlParamsFldrs: -folder=#linkPath, -page=#linkFile, -vars=#paramsViaFldrs);

            /if;

            if: 
                ((#menuItemMatchBy == 'path') && (#currentPath->beginswith:#menuLinkPath)) ||
                ((#menuItemMatchBy == 'page') && (#currentPage == #menuLinkPage));

                #menuMarkup += '<span class="fwptxtmenuhilite"><a class="fwptxtmenuhilitelink" href="';
                #menuMarkup += #menuItemLink;
                #menuMarkup += '">';
                #menuItemTitle->beginsWith:'['
                    ? #menuMarkup += (process:#menuItemTitle)
                    | #menuMarkup += #menuItemTitle;
                #menuMarkup += '</a></span><br />';

            else;

                #menuMarkup += '<a href="';
                #menuMarkup += #menuItemLink;
                #menuMarkup += '">';
                #menuItemTitle->beginsWith:'['
                    ? #menuMarkup += (process:#menuItemTitle)
                    | #menuMarkup += #menuItemTitle;
                #menuMarkup += '</a><br />';

            /if;
        /if;

    /iterate;

    $fw_debugTimers ? $fw_timer->(stop:'menuTagVtext');

    return: @#menuMarkup;

/define_tag;
?>


© 2002-2012, pageblocks.org