API: Str
Filename:
fwpStr_getLeft.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
Retrieves the leftmost N characters from a string as specified. Using the -smart option, the string is truncated at the last space in the string (and therefore maybe shorter than the specified length).
[fwpStr_getLeft: -str=string, -get=integer, -smart]
-str - required : a string
-get - required : the length to return
-smart - optional : shortens the string back the last space to prevent cutting whole words
[fwpStr_getLeft: -str=(field:'description'), -get='50'] [fwpStr_getLeft: -str=(field:'description'), -get='50', -smart]
<?lassoscript
//............................................................................
//
// pageblocks: (c) 2002-2007 http://www.pageblocks.org/
//
//............................................................................
/*
{fileName= fwpStr_getLeft.ctag }
{rsrcType= tag }
{rsrcName= fwpStr_getLeft }
{rsrcHTTP= www.pageblocks.org/refc/fwpStr_getLeft }
{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 returns the right 'len' chars of string 'str'.
If -smart is specified then it returns a max of 'len chars
with an intelligent cutoff at whole words. }
{maintvsrn= 1.0 }
{maintrelease= 5.0.0 }
{maintdate= 2006-01-16 }
{maintauthor= Greg Willits }
{maintnotes= initial release }
*/
//.............................................................................
define_tag:'fwpStr_getLeft', -priority='replace',
-required='str',
-required='get';
local:
'fw_get' = #get,
'fw_str' = #str;
if: #fw_get > #fw_str->size;
#fw_get = #fw_str->size;
/if;
if: (params->(find:'-smart')->size) > 0;
return:(string_removetrailing:
#fw_str->(substring:1,#fw_get),
-pattern = ' ' + (#fw_str->(substring:1,#fw_get))->(split:' ')->last);
else;
return:#fw_str->(substring:1,#fw_get);
/if;
/define_tag;
?>
© 2002-2010, pageblocks.org