Categories > [old] TbsOoo & TinyDoc >

remove unused block and newline

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: jef
Date: 2012-01-31
Time: 14:24

remove unused block and newline

until recently, i used odf-xslt, which did the job as it should be, but recently i discovered this shinny package, and i must say, i am overwhelmed. it even works with M$ files. My main usage is for template documents to be processed on a server , with data filled in from a database. i have 1 question : i need to remove some blocks, but the hard and soft returns are left in place, is there a way to remove these as well or in an extra step ?

By: Skrol29
Date: 2012-01-31
Time: 16:15

Re: remove unused block and newline

Hi Jef,

It is possible to remove blocks using conditional display (see TBS manual).
Do you have an example of what you're trying to do ?
By: jef
Date: 2012-01-31
Time: 16:21

Re: remove unused block and newline

well, i have a document with several addressing parts, but only 1 must be filled in.

<hr>
[to.bedrijf]<sr>
[to.adres]<sr>
[to.postcode]<tab>    [to.gemeente]<sr>
[to.land]<hr>
So if the 'to' array is empty, i just want the whole block to disappear, back to the first <hr>
By the way, i am very exited by this nice piece of software!
By: Skrol29
Date: 2012-01-31
Time: 17:01

Re: remove unused block and newline

It's quite easy to add a conditional block at this place in your template.

> So if the 'to' array is empty

Can you precise what is the data structure when 'to' is empty. And are you using MergeBlock() or MergeField()?

What are entities <sr> and <hr>?
By: jef
Date: 2012-01-31
Time: 17:17

Re: remove unused block and newline

<hr> i meant hard return , the data structure is just $data_ar = array() and i am using MergeField

jef
By: Skrol29
Date: 2012-01-31
Time: 21:26

Re: remove unused block and newline

Is "hard return" a new paragraph ?
By: jef
Date: 2012-01-31
Time: 21:40

Re: remove unused block and newline

yep, hard return (enter), new paragraph, soft return (shift + enter ), new line

jef
By: Skrol29
Date: 2012-01-31
Time: 21:58

Re: remove unused block and newline

Ok, so the inner XML of the OFT content is something like:

<text:p>
  [to.bedrijf] <text:line-break/>
  [to.adres] <text:line-break/>
  [to.postcode] <text:tab/> [to.gemeente] <text:line-break/>
  [to.land]
</text:p>

You can use parameter "magnet" to delete a block when a value is en empty string. Also use parameter "noerr" to avoid TBS error message when a item is missing.
So you piece of template can be like this:
<text:p>
  [to.bedrijf;noerr;magnet=text:p] <text:line-break/>
  [to.adres] <text:line-break/>
  [to.postcode] <text:tab/> [to.gemeente] <text:line-break/>
  [to.land]
</text:p>

The visible way would be:
  [to.bedrijf;noerr;magnet=text:p]
  [to.adres]
  [to.postcode] [to.gemeente]
  [to.land]
By: jef
Date: 2012-01-31
Time: 22:11

Re: remove unused block and newline

thanks for the help,

this mean  i can completely replace my current solution (using odf-xslt, which was also nice at the time) with TBS.  this was the exact thing i was looking for .

jef
By: jef
Date: 2012-01-31
Time: 22:41

Re: remove unused block and newline

just want to let you know, i process a calc template file with a table 3x1000, just 0,09 seconds to create the file. Amazing fast, if you ask me. At 10000 rows, i approach a second.