Link | QueryString |
Author | Shelane French |
Category | Link |
Version | 8.5.x |
License | Public Domain |
Posted | 11 Mar 2014 |
Updated | 11 Mar 2014 |
More by this author... |
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.
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
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;
No comments
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft