Categories > TinyButStrong general >

ope=replace=

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: TomH
Date: 2013-01-10
Time: 18:30

ope=replace=

Hello,
I am trying to remove breaks from mysql field before displaying the block - without using an ondata function
I tried use the plus plugin to replace <br /> with a space

[blk.counterparts;magnet=field;ope=replace='<br />':' ';]
and
[blk.counterparts;magnet=field;ope=replace=<br />: ;]


Neither is working.

Any help would be appreciated

Thanks
TomH
By: Sarah
Date: 2013-01-11
Time: 00:02

Re: ope=replace=

Looking at the examples (http://www.tinybutstrong.com/plugins/plus/doc/test.php), it looks like you might want to try [blk.counterparts;magnet=field;ope=replace=<br />:_] (that's an underscore - looks like it might be an alias for space in the Plus plugin)

You might also want to check for other <br /> permutations? (<BR>,<br>,<br/>,<BR/>,etc)

It might be worth having an ondata function, if this isn't the only thing you need to check for, or maybe just use PHP to strip the html out before it hits TBS?

Just my two cents.
By: TomH
Date: 2013-01-11
Time: 01:54

Re: ope=replace=

Thanks for adding your thoughts - I could not get that to work however

For fun ;) I decided to use php to process the db result array - rather than load up TBS with processing via an ondata function (as I wasn't already doing an ondata for this block)

FWIW, here's what worked...
    foreach($result AS $key=>$val){
    $result[$key][clean_counterparts] = str_replace("\r\n"," ",$result[$key][counterparts]);   
    }

I did try using \r\n in the [ ... ;ope=replace=\r\n: ;] and  [ ... ;ope=replace=\r\n:_;]  but no joy there either

Again, thanks for your thoughts
TomH
By: David
Date: 2013-01-14
Time: 02:23

Re: ope=replace=

I think perhaps you need:
foreach($result AS $key=>$val){
$result[$key][] = str_replace("\r\n"," ",$val);
}
also I think that you want quotes, preferably single though double will work around clean_counterparts unless I am misunderstanding what you're trying to do

David
By: Anonymous
Date: 2013-01-14
Time: 03:27

Re: ope=replace=

Using result[key][]= does not create the synthetic db field name to be used in the TBS block
i.e. [blk.clean_counterparts;]

Thanks for TBS every day
TomH