Page Blocks

Hosting sponsored by:

Point In Space

 

API: Gui

Filename:
fwpGui_menuHText.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_hTextMenu (Tag)

Description

Creates a horizontal 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_hTextMenu:
  -menu=menuName or literal array,
  -tween=string,
  -left=string,
  -right=string,
  -paramsStd=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 site 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_main.cnfg.

-tween - required : a string of characters to be displayed between each menu item

-left - optional : a string of characters to be displayed at the left of the entire menu

-right - optional : a string of characters to be displayed at the right of the entire menu

-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 horizontal menus, this is unused, but is required (even if set to 0) so the same config file can be used for horizontal and vertical menus (see fwpGui_menuVText)

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 is accomplished with a CSS span class name of fwptxtmenuhilite.

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

Examples

<p>[fwpGui_htextmenu:
  -menu = 'colors',
  -tween = ' | ',
  -left = '[ ',
  -right = ' ]']</p>

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

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

<p>[fwpGui_htextmenu:
  -menu = 'colors',
  -tween = '  ',
  -left = ' ',
  -right = ' ',
  -paramsStd = 'p1,p2']</p>

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

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

Sample Configuration File:

/demo/demos.lasso```Introduction```0```page
/demo/valuelists.lasso```ValueLists```0```page
/demo/menus.lasso```Menus```0```page
/demo/stylize.lasso```Stylize Text```0```page

Source Code

View in separate window

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

    {fileName=        fwpGui_menuHText.ctag }
    {rsrcType=        tag }
    {rsrcName=        fwpGui_htextmenu }
    {rsrcHTTP=        www.pageblocks.org/refc/fwpGui_htextmenu }

    {lassoVrsnMin=    8.1.0 }
    {lassoVrsnMax=    8.5.3 }

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

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

    {maintvsrn=        1.3 }
    {maintrelease=    5.3.0 }
    {maintdate=        2007-08-09 }
    {maintauthor=    Greg Willits }
    {maintnotes=    added fwptxtmenuhilitelink class }

    {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_htextmenu', -priority='replace',
    -optional='menu',
    -optional='tween',
    -optional='left',
    -optional='right',
    -optional='paramsGet',
    -optional='paramsFile',
    -optional='paramsFldrs';

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

    local:
        'menuConfigSource'    = @local:'menu',
        'menuFill'            = @local:'tween',
        'menuBorderLeft'    = @local:'left',
        'menuBorderRight'    = @local:'right',
        '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;

    if: #paramsViaGet;
        #paramsViaGet = (fwpCnfg_splitComma: #paramsViaGet);
    /if;

    if: #currentPage >> fw_kURLparamsChar;
        local:'currentPage'=((response_filepath)->split: fw_kURLparamsChar)->last;
    /if;

    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 is already an array then we have direct config info

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

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

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

        #menuConfigData = #menuConfigSource;

    /if;


//    start building the menu

    (#menuMarkup) += (#menuBorderLeft);

    iterate: #menuConfigData, #menuConfigLine;

        local:'menuConfigItems' = #menuConfigLine->split:'```';
        local:
            'menuItemLink'        = #menuConfigItems->get:1,
            'menuItemTitle'        = #menuConfigItems->get:2,
            'menuItemMatchBy'    = #menuConfigItems->get:(#menuConfigItems->size);
        local:'menuURLItems'    = (#menuItemLink->(split:'/'));
        local:'menuLinkPage'    = (#menuURLItems->last);
        local:'menuLinkPath'    = (#menuItemLink);
        #menuLinkPath->(removeTrailing:#menuLinkPage);

        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>';
            #menuMarkup += #menuFill;

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

    /iterate;

    #menuMarkup->(removeTrailing:#menuFill);

    (#menuMarkup) += (#menuBorderRight);

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

    return: @#menuMarkup;

/define_tag;
?>

© 2002-2012, pageblocks.org