Page Blocks

Hosting sponsored by:

Point In Space

 

API: Str

Filename:
fwpStr_phoneUnpack.ctag

Released With:
5.0.0

Current Version:
1.0.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

fwpStr_phoneUnpack (Tag)

Description

This tag takes a packed phone number and formats it for display in one of several styles. The packed format looks like 0001112222333333, where:

000 = area code (A)
111 = prefix (P)
2222 = number (N)
333333 = extension (X)

Where there is no area code, the data should be padded with 000. There is no need to pad the extension.

Syntax

[fwpStr_phoneUnpack:string, -format='.|/|(']

Parameters & Member Tags

phoneNo (unnamed) - required : the phone number digit string

-format - optional : one of either a period, slash, or open parenthesis character to denote the formatting where:

  • period '.' yields 000.000.0000 x0000
  • slash '/' yields 000/000-0000 x0000
  • open paren '(' yields (000) 000-0000 x0000

Examples

[fwpStr_phoneUnpack:field:'homePh', -format='(']

Source Code

View in separate window

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

    {fileName=        fwpStr_phoneUnpack.ctag }
    {rsrcType=        tag }
    {rsrcName=        fwpStr_phoneUnpack }
    {rsrcHTTP=        http://www.pageblocks.org/refc/fwpStr_phoneUnpack }

    {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=            takes a packed phone number string and creates
                    separate variables for each component }

    {maintvsrn=        1.0 }
    {maintrelease=    5.0.0 }
    {maintdate=        2006-01-16 }
    {maintauthor=    Greg Willits }
    {maintnotes=    initial release
                    completely replaces prior phoneUnpack tag 
                    which has been renamed phoneFormat }

*/
//............................................................................
//
//    packed format should be 0001112222333333
//    where:    000 = area code     'pha'
//            111 = prefix        'php'
//            2222 = number        'phn'
//            333333 = extension    'phx'
//    where there is no area code, the data should be padded with 000
//    there is no need to pad the extension
//.............................................................................

define_tag:'fwpStr_phoneUnpack', -priority='replace',
    -required='phone',
    -optional='varNm';

//    allowed both inputs to phone can come from field or whatever
//    allow a single input is the var name of the phone data

    if: !(local_defined:'varNm');
        local:'fw_phRaw' = @(var:#phone);
        local:'fw_phVar' = local:'phone';
    else;
        local:'fw_phRaw' = @(local:'phone');
        local:'fw_phVar' = @local:'varNm';
    /if;

    if: !var_defined:(#fw_phVar + 'a');
        var:(#fw_phVar + 'a') = (fwpStr_phoneGetPHA: #fw_phRaw);
        var:(#fw_phVar + 'p') = (fwpStr_phoneGetPHP: #fw_phRaw);
        var:(#fw_phVar + 'n') = (fwpStr_phoneGetPHN: #fw_phRaw);
    /if;

    if: #fw_phRaw->size > 10;
        var:(#fw_phVar + 'x') = (fwpStr_phoneGetPHX: #fw_phRaw);
    else;
        var:(#fw_phVar + 'x') = (string);
    /if;

/define_tag;
?>

© 2002-2012, pageblocks.org