Lasso Soft Inc. > Home

[QueryString]

LinkQueryString
AuthorShelane French
CategoryLink
Version8.5.x
LicensePublic Domain
Posted11 Mar 2014
Updated11 Mar 2014
More by this author...

Description

Define a QueryString that you can build on and then output with your links. You can add an additional item at the time of output that won't be built into the existing object.

Sample Usage

var('query_string' = QueryString);
$query_string->add('sort=price');
$query_string->add('city=Livermore');
$query_string->output('skip=' + $skip++);

outputs: ?sort=price&city=Livermore&skip=0

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.

define_type('QueryString', -prototype);

local('query_string' = string);
 
define_tag('add', -req='incoming');
    if(#incoming->isA('array'));
        iterate(#incoming, local('loop_value'));
            self->build(#loop_value);
        /iterate;
    else;
        self->build(#incoming);
    /if;
/define_tag;
 
define_tag('build', -req='param_item');
    if(#param_item->isA('pair'));
        self->'query_string'->Append('&' + #param_item->first + '=' + #param_item->second);
    else;
        !#param_item->BeginsWith('&') ? self->'query_string'->Append('&');
        self->'query_string'->Append(#param_item);
    /if;
/define_tag;
 
define_tag('output', -opt='incoming', -type=string);
    local('output' = self->'query_string');
    if(local_defined('incoming') && #incoming->size);
        !#incoming->BeginsWith('&') ? #output->append('&');
        #output->append(#incoming);
    /if;
    if(#output != '');
        #output->RemoveLeading('&');
        return('?' + encode_URL(#output));
    /if;
/define_tag;
 
define_tag('onCreate', -opt='incoming');
    if(local_defined('incoming') && #incoming->size);
        self->add(#incoming);
    /if;
/define_tag;

/define_type;

Comments

No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft