Page Blocks

Hosting sponsored by:

Point In Space

 

API: Cnfg

Filename:
fwpCnfg_loadProcess.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

fwpCnfg_loadProcess (Tag)

Description

Loads, or rather processes, a standard lasso library file. In cases where you have files you'd consider part of the site's or module's configuration, but it is easier to code the functions as executable LDML rather than plain text data, this tag can be used to load that file. Why not use a regular process tag? About the only reason is that this tag searches the /site/configs/ folder and the current /_resources/configs/ folder, and will use which ever one it finds. If both are found, both are processed, and the local file can be written to override anything in the global file.

Alternately, a full file pathname can be given to load a specific file not in the usual /configs/ folder. Although, if you know the file will never be in the /configs/ folders, you may as well use the standard process and include tags.

An example of this in use in the pageblock framework code is the {filevList_{name}.cnfg files}. They're grouped with the config files, yet these particular ones are written as executable LDML files. Using this tag abstracts the task of locating them, and allows them to be placed in either /configs/ folder.

Syntax

fwpCnfg_loadProcess: fileName;

Parameters & Member Tags

file (unnamed) = required : either a complete filename with extension or a full pathname. If a file name is specified without any path component, the tag will search the /site/configs/ folder and the current /_resources/configs/ folder. If a file with a path is specified, the complete virtual host root relative path must be specified, and the tag will load that one specific file. If files in both folders are found, both will be executed (allow the opportunity for the module to override the global file).

Examples

fwpCnfg_loadProcess:'custom.cnfg';

Source Code

View in separate window

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

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

    {lassoVrsnMin=    8.1.0 }
    {lassoVrsnMax=    8.5.3 }

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

    {desc=            This tag loads a file, and processes it`s contents }

    {maintvsrn=        1.1.0 }
    {maintrelease=    5.1.0 }
    {maintdate=        2006-05-30}
    {maintauthor=    Greg Willits }
    {maintnotes=    added tagTrace }

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

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

define_tag:'fwpCnfg_loadProcess', -priority='replace',
    -required='file',
    -optional='username',
    -optional='password';

    ($fw_debug >= fw_kChatty) ? $fw_tagTracer->(add:'fwpCnfg_loadProcess', -file = #file);

    local:
        'fileName'         = @#file,
        'fileData'         = string,
        'fileDataStr'    = string;

//    pull from cache if available
//    else pull from disk (and store to cache)

    #fileData = $fw_gConfigCache->(restore:#fileName);

    if: #fileData->size == 0;

//    load file data

        #fileData = (fwpCnfg_loadFile:
            -file        = #fileName,
            -username     = local:'username',
            -password     = local:'password');

//    store it to the cache

            $fw_gConfigCache->(add:
                -name  = #fileName,
                -value = #fileDataStr);

    /if;

    process: #fileData;

/define_tag;

?>

© 2002-2012, pageblocks.org