By: h3ll
Date: 2011-01-17
Time: 12:41
|
Show/Hide template data depending on value
Hi there,
just read the manuals about conditional displaying data. Is it possible to show/hide some template data depending on some value?
Concrete example:
i have a docx template for serial letter printing.for some of those letters an extra page must be included depending on some value inside my block.
hope its understandable ;)
thanks in advance
|
By: Skrol29
Date: 2011-01-17
Time: 15:06
|
Re: Show/Hide template data depending on value
Hi,
Yes you can hide parts of the document using conditional blocks.
But you have to know that pages are not managed as a localized entity in the source of the Word document.
Page breaks are made with a new paragraph having a style which has the attribute {fo:break-before="page"}.
So, in order to define a TBS block over a whole page, you have to make it start with the first paragraph and going up to the last paragraph of the page. (your page can have several paragraphs depending on what you've written into).
You can also try with Word sections.
|
By: h3ll
Date: 2011-01-17
Time: 15:12
|
Re: Show/Hide template data depending on value
hm ok...just to get it right
my template is some sort of
[d;block begin....]
<TEMPLATE DATA>
<PAGE_BREAK>
<TEMPLATE_DATA>
[d;block=end...]
i tried like this before without success:
[d;block begin....]
[e;block begin...;when [d.field] == "somevalue"]
<TEMPLATE DATA>
[e;block=end...]
<PAGE_BREAK>
<TEMPLATE_DATA>
[d;block=end...]
|
By: Skrol29
Date: 2011-01-17
Time: 18:14
|
Re: Show/Hide template data depending on value
Sorry there is a mistake in my previous message:
> Page breaks are made with a new paragraph having a style which has the attribute {fo:break-before="page"}.
This of for OpenOffice. For Ms Word: page breaks are made with <w:br w:type="page"/> which takes place into a paragraph like this : <w:p><w:r> <w:br w:type="page"/> </w:r></w:p>
> i tried like this before without success:
It seems that your block "e" is a kind of TBS sub-block.
Your problem may be in the way your are managing this block.
Can you describe what you're trying to obtain and who you're merging your blocks ?
|
By: h3ll
Date: 2011-01-18
Time: 08:03
|
Re: Show/Hide template data depending on value
hi,
i´ll try to explain. i retrieve some data from the database. a page gets generated for each of these records. for some of these records an extra page must be printed, depending on some value in these records. at first i added just one block to merge the data into and all worked fine apart from the fact that the conditional part was printed for each record also. (sure, no condition yet). then i browsed the manual and tried to implement a second block, encapsulating the conditional template (like briefly described in my previous message)
regards
|
By: Skrol29
Date: 2011-01-18
Time: 14:22
|
Re: Show/Hide template data depending on value
Hi,
First you can try without the page break, and define the conditional part with "block=begin" and "block=end" using [onshow] tags.
Like in the demo example, use a specific paragraph for embedding the opening and closing tags. The specific paragraphs will be deleted when merged thanks to parameter "comm".
Like this:
[d;block=begin...]
... ¶
[onshow.block=begin;when [d.field]=='somevalue';comm=w:p] ¶
...¶
[onshow.block=end;comm=w:p] ¶
... ¶
[d;block=end...]
|
Then you can place your page breaks wisely the get the final effect:
[d;block=begin...]
... ¶
[onshow.block=begin;when [d.field]=='somevalue';comm=w:p] ¶
---- page break -----
...¶
[onshow.block=end;comm=w:p] ¶
---- page break -----
... ¶
[d;block=end...]
|
|
By: h3ll
Date: 2011-01-18
Time: 15:17
|
Re: Show/Hide template data depending on value
Great, it works now =)
(i replaced the '.' with ';' to get it working)
[d;block=begin;comm=w:p]
[onshow;block=begin;when [d.Field] != ‘’;comm=w:p]
...
|
but you did it again template master, thanks mate =)
|
By: h3ll
Date: 2011-01-19
Time: 12:08
|
Re: Show/Hide template data depending on value
Sorry me again and i need to revert my post from yesterday.
The solution works only if the recordset contains just one record. If i try to merge with more than one record, i get a TBS Error:
TinyButStrong Error : can't found the end of the tag '[onshow;block=begi...'.
TinyButStrong Error in block's definition [onshow...]: at least one tag corresponding to end is not found. Check opening tags, closing tags and embedding levels.
TinyButStrong Error : can't found the end of the tag '[onshow;block=begi...'.
TinyButStrong Error Show() Method: The output is cancelled by the OpenTBS plugin because at least one error has occured.
|
|
By: Skrol29
Date: 2011-01-20
Time: 11:15
|
Re: Show/Hide template data depending on value
This is strange, this error usually happens when the TBS tags are broken with invisible XML.
I suggest that you check the XML contents of your template using the DEBUG mode of OpenTBS.
I you don't succeed, you can send to me the template and I'll have a look.
|
By: Skrol29
Date: 2011-01-20
Time: 16:41
|
Re: Show/Hide template data depending on value
Hi H3ll,
Thanks for the file you sent to me.
The template source seems correct.
I thing the problem comes from a value of [d.Field] (in the snippet from above) can contains characters like ; or ' (simple quote), or " (double quotes) which may break the syntax of the [onshow] tags.
This can happen because [onshow] tags are merged after [d.Field] tags.
The best solution is to make an extra column in your data source which is numerical and contains 0 if [Field] is equal to '', and 1 otherwise.
Then [onshow;block=begin;when [d.Field] != ‘’;comm=w:p] |
will become [onshow;block=begin;when [d.Field2]=1;comm=w:p] |
and your problem will be gone because there is no buggy characters.
|
By: h3ll
Date: 2011-01-24
Time: 12:49
|
Re: Show/Hide template data depending on value
Hi, and big thanks for helping me with this. I added an extra column in the resultset as suggested and it works fine. Although this solution feels a bit "workaroundy". Perhaps some improvement space for further versions? =)
Thanks anyway and keep up the good work
|
|
Posting in progress.
Please wait...
|