From: Adrian F. <adr...@gm...> - 2010-03-01 20:51:19
|
Is there a way to truncate/limit the char size of a query result? For example I'd like to extract only the first 30 chars of the 'description' field from the page "Spain": {{#show: Spain| ?description}} Maybe something like this ? {{#show: Spain| ?description | charlimit=30}} thanks, Adrian |
From: <zal...@on...> - 2010-03-01 20:59:31
|
Hi Adrian, you can do this when you use an template as result printer. Assuming that {{{6}}} contains your text, then {{#ifexpr: {{#len:{{{6|}}}}} > 500 | {{#sub:{{{6|}}}|0|500}} ... | {{{6|}}} }} outputs only up to 500 chars of the text. We use it e.g. on our events page for limiting the description of the events. See http://smwforum.ontoprise.com/smwforum/index.php/Events Regards, Philipp Adrian Fritsch <adr...@gm...> hat am 1. März 2010 um 21:51 geschrieben: > Is there a way to truncate/limit the char size of a query result? > For example I'd like to extract only the first 30 chars of the 'description' > field from the page "Spain": > > {{#show: Spain| ?description}} > > Maybe something like this ? > {{#show: Spain| ?description | charlimit=30}} > > thanks, > Adrian > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Semediawiki-user mailing list > Sem...@li... > https://lists.sourceforge.net/lists/listinfo/semediawiki-user |
From: Bob M. <unc...@gm...> - 2010-03-01 21:01:54
|
I guess you just wrap your #show: in http://www.mediawiki.org/wiki/Extension:StringFunctions#.23sub: - if you are only showing one property and it has only one value (arraymap otherwise) With #ask: you could put the sub call in a template and use format=template. However, that doesn't help if you're using maps or graphs or some other output format you can't easily replicate with your own template. On Mon, Mar 1, 2010 at 8:51 PM, Adrian Fritsch <adr...@gm...> wrote: > Is there a way to truncate/limit the char size of a query result? > For example I'd like to extract only the first 30 chars of the 'description' > field from the page "Spain": > > {{#show: Spain| ?description}} > > Maybe something like this ? > {{#show: Spain| ?description | charlimit=30}} > > thanks, > Adrian > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Semediawiki-user mailing list > Sem...@li... > https://lists.sourceforge.net/lists/listinfo/semediawiki-user > -- http://darwintunes.org - a test-tube for cultural evolution http://evolectronica.com - survival of the funkiest http://compare-stuff.com - confused? you will be! http://twitter.com/darwintunes http://twitter.com/bobmaccallum |
From: Adrian F. <adr...@gm...> - 2010-03-01 23:10:18
|
Thanks Bob, Plilipp These are good solutions. Adrian On Mon, Mar 1, 2010 at 4:01 PM, Bob MacCallum <unc...@gm...> wrote: > I guess you just wrap your #show: in > http://www.mediawiki.org/wiki/Extension:StringFunctions#.23sub: - if > you are only showing one property and it has only one value (arraymap > otherwise) > > With #ask: you could put the sub call in a template and use > format=template. However, that doesn't help if you're using maps or > graphs or some other output format you can't easily replicate with > your own template. > > On Mon, Mar 1, 2010 at 8:51 PM, Adrian Fritsch <adr...@gm...> wrote: > > Is there a way to truncate/limit the char size of a query result? > > For example I'd like to extract only the first 30 chars of the > 'description' > > field from the page "Spain": > > > > {{#show: Spain| ?description}} > > > > Maybe something like this ? > > {{#show: Spain| ?description | charlimit=30}} > > > > thanks, > > Adrian > > > ------------------------------------------------------------------------------ > > Download Intel® Parallel Studio Eval > > Try the new software tools for yourself. Speed compiling, find bugs > > proactively, and fine-tune applications for parallel performance. > > See why Intel Parallel Studio got high marks during beta. > > http://p.sf.net/sfu/intel-sw-dev > > _______________________________________________ > > Semediawiki-user mailing list > > Sem...@li... > > https://lists.sourceforge.net/lists/listinfo/semediawiki-user > > > > > > -- > http://darwintunes.org - a test-tube for cultural evolution > http://evolectronica.com - survival of the funkiest > http://compare-stuff.com - confused? you will be! > http://twitter.com/darwintunes > http://twitter.com/bobmaccallum > |