Categories > OpenTBS with ODS >

Shorter Variables

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: handbuch
Date: 2010-11-23
Time: 11:24

Shorter Variables

Hi,

I have a array with all my data. Lets say they containt Lastname, DaysWorked. So now , DaysWorked, it justa number. Very small, like 23, oder 11. I now want to make a List in ODT on which the number is on the right side of the document, like setting a tab very close, then i could write easyly all my number in there. But since that space then si very small, i cant put my variable [a_sub1.DaysWorked] there. I have to make the space a lot bigger, so my variable doesnt appear on the next line, but when i generate the document then, the number is on the wrong place. since it is a lot smaller.

Now i would like to set [a_sub1.Titel_DE] to $x. so i can write $x in my document. I didnt get that str replace thing working.

Thansk a lot :)
By: Skrol29
Date: 2010-11-23
Time: 11:50

Re: Shorter Variables

Hi,

Here is the tip:
Insert a, OpenOffice comment where you want the small text to be placed.  
In the comment, put the TBS fields with a parameter "comm", like this:
[a_sub1.Titel_DE;comm=office:annotation]

Parameter comm will extend the bounds of the TBS field up to the specified XML entity. Then the XML entity will be completely replaced by the field's value.
By: handbuch
Date: 2010-11-23
Time: 14:19

Re: Shorter Variables

Whats an Open Office Comment? I just want a small variable which i can use in the document. the x would be a comment? Comment like in programming? What wouldi  hve to write in the document template with you example?
By: Skrol29
Date: 2010-11-23
Time: 15:03

Re: Shorter Variables

> Whats an Open Office Comment?

See the OpenOffice menu: Insert/Comment
A comment takes no place in the document. Using the "comm" tip, the comment will be replaced with your merged value using the text makeup where the comment tag has been placed in.

> Now i would like to set [a_sub1.Titel_DE] to $x. so i can write $x in my document.

Can you explain with more details?
By: handbuch
Date: 2010-11-24
Time: 08:25

Re: Shorter Variables

I see that with the comment, i'll try that. Ignore that with $x.

Thanks
By: handbuch
Date: 2010-11-25
Time: 15:06

Re: Shorter Variables

SO ijust have to write [a_sub1.Titel_DE;comm=office:annotation] in the comment? doesnt matter what i write in comment? if yes, then im doing somthing wrong.
By: Skrol29
Date: 2010-11-25
Time: 16:28

Re: Shorter Variables

Hi,

The comment have to contain this TBS field, and may contain other free text that are not TBS fields.
The point is that parameter "comm" will extend the TBS fields bounds (i.e. on the left and on the right) up to the bounds of the comment, including the bounds of the comment. So the whole comment will be replaced by the field's value to merge.

I think I made a little mistake about your field's name, it should be
[a_sub1.DaysWorked;comm=office:annotation]
By: Anonymous
Date: 2010-11-25
Time: 22:12

Re: Shorter Variables

whats the office:annotation?

my vars were just examples. So if i have a var called Title_DE. and i want to put that with a comment in my document, i have to write?
By: Anonymous
Date: 2010-11-26
Time: 09:54

Re: Shorter Variables

oh and another question if i have like:

[a;block=begin;sub1]
[a_sub1;block=begin]
[a_sub1.Titel_DE]        [a_sub1.PriceMain]
[a_sub1;block=end]
[a;block=end]

the [a_sub1;block=end] gets printed as a space. how can i make it not intepretable? can you give me some example with the comm tag? a workign example which i can take a look at :) please
By: Skrol29
Date: 2010-11-26
Time: 10:44

Re: Shorter Variables

Hi,

> the [a_sub1;block=end] gets printed as a space.

I think it's not printed as a space. It's probably the new line that makes this behavior, or another rupture in the text layout. But not TBS.

> whats the office:annotation?

If you read the manual, you'll see that parameter "comm" indicates the name of an XML/HTML entity. Thus, <office:annotation> is the XML entity for comments in OpenOffice documents.

> So if i have a var called Title_DE. and i want to put that with a comment in my document, i have to write?

Global PHP variables can be merged automatically with [onload] or [onshow] TBS fields.
So it could be [onshow.DaysWorked;comm=office:annotation]

The demo for the comment tip can be downloaded here:
http://dl.free.fr/getfile.pl?file=/BqtKxQdK
Click on "Télécharger ce fichier"
By: Anonymous
Date: 2010-11-29
Time: 16:45

Re: Shorter Variables

okay thanks a lot! I'll read the manual better about the comm para. And thansk very much for the demo! Thanks, have a nice day :)
By: Anonymous
Date: 2010-11-30
Time: 09:49

Re: Shorter Variables

Hi, me again. Can you please check my template?

Here is my template: http://uploaded.to/file/yzg5k9

why doesnt ir work? Cant i use comments in a loop?

normaly the variables looks liek the same in the comment without onload. but it doesnt work either.

and [a_sub1;block=end][a;block=end] get intepretet as a space, mybe because the line break, how can i get rid of this?
By: Skrol29
Date: 2010-11-30
Time: 10:36

Re: Shorter Variables

Hi Handbuch,

Yes you can use comments in a loop.

Here is what you have to do in order to have your template working:

1) In the OpenOffice comment, replace [onload.a_sub1.Titel_DE;comm=office:annotation] with [a_sub1.Titel_DE;comm=office:annotation]
The [onload] suffix is for automatic fields. The field [onload.a_sub1.Titel_DE] can be merged only if you have a global variable such as $a_sub1['Titel_DE'].

2) Cut the string "[a_sub1.Titel_DE;comm=office:annotation]" from the OpenOffice comment (Ctrl+X) ; then paste the string in code editor (like notepade), then re-paste it in the OpenOffice comment.
Why doing this? This operation will delete the several formats than have been applied in this text snippet. Because, if your run merge in the debug mode (see debug mode in the manual) then you can discover that this piece of text has been spitted by OpenOffice with several internal formats. This is probably because you've changed the styles or the format of this snippet several times but not regularly on the entire piece of text.

By: Anonymous
Date: 2010-11-30
Time: 11:51

Re: Shorter Variables

uh yeah. nice. that works! :)and now im also rid of the problem with the line brake. :) Thanks a lot! i'll further test it rigth now! :) but a question is left. so, if i put anythign in a comment, i cant style it?

so, the main problem is. i want to generate a table, but then i cant put the end tags of the loops into the table too, have to close the loops after the table. how do i do that without getting a space?
By: Skrol29
Date: 2010-11-30
Time: 15:29

Re: Shorter Variables

> if i put anythign in a comment, i cant style it?

You can put styles anywhere in the comment, even over the TBS field. But just don't split any TBS field in two with styles.

>have to close the loops after the table. how do i do that without getting a space?

OpenOffice seems to not allows texts collapsed to tables. Its always split a paragraph in two when you insert a table.
Like:
<text:p>Here is a table:</text:p>
<table:table>
  <table:table-row>...</table:table-row>
  <table:table-row>...</table:table-row>
</table:table>
<text:p>Text continue here.</text:p>
But they are several ways to wedge the bound of a TBS block on an XML table element.
- Use the TBS relative syntax for blocks. Think you can define a block upon several XML elements. For example : "block=text:p+table:table"
or
- Use the "comm" parameter to extend the bound of your "block=end" TBS tag upon the paragraph it is writen in. For example: [a;block=end;comm=text:p]

For information:
An OpenOffice table element is defined with tags <table:table>.
An OpenOffice paragraph element is defined with tags <text:p>
By: Anonymous
Date: 2010-11-30
Time: 16:55

Re: Shorter Variables

okay thanks, i'll try that out tomorrow. You brougth me a lot further. thanks :)

And also, is there something like an if i can use in the template?  and ifi have a table with 2 rows and i repeat it, can i prevent it from gettin breaked at the end of a document? so the first row is not on site 1 and the second on site 2?

thanks a lot
By: Anonymous
Date: 2010-12-01
Time: 08:38

Re: Shorter Variables

Oh and another question, can i somehow directly export the document as a pdf, like saying to the opentbs, save it as pdf isntead of odt? Didnt foudn it, but maybe, somehow its possible.

[a;block=begin;sub1]
[a_sub1;block=text:p]
[a_sub1.Titel_DE]
[a_sub1;block=end]
[a;block=end]


should that be right? how do i combine text:p with begin? i dont see the text in the manual. TitleDE would be in a table.
By: Anonymous
Date: 2010-12-01
Time: 11:20

Re: Shorter Variables

Oh and another question, can i somehow directly export the document as a pdf, like saying to the opentbs, save it as pdf isntead of odt? Didnt foudn it, but maybe, somehow its possible.

Oh and also, am i rigth with that?

[a;block=begin;sub1]
    [a_sub1;block=begin;sub2]
        [sub1_sub2;block=begin]
            [sub1_sub2.Titel_DE]
        [sub1_sub2;block=end]
    [a_sub1;block=end]
[a;block=end]


my array looksl ike:  array[0][goods][0][Title_DE]
By: Skrol29
Date: 2010-12-02
Time: 10:49

Re: Shorter Variables

> is there something like an if i can use in the template?

See parameters "if/then/else" for fields, "when/default" for blocks.

> ifi have a table with 2 rows and i repeat it, can i prevent it from gettin breaked at the end of a document?

That is an option for the table that you can tune in OpenOffice.

> can i somehow directly export the document as a pd

OpenTbs cannot do that. For now, you have to open the ODT file with an OpenOffice and use the command in menus to manually convert the file in PDF.

> how do i combine text:p with begin?

It depends of what you're trying to do.
[a_sub1;block=text:p] will define the block to be bounds on the paragraph. Thus the next one [sub1_sub2;block=end] has no meaning.
You may need [a_sub1;block=begin;comm=text:p]


> Oh and also, am i rigth with that? my array looksl ike:  array[0][goods][0][Title_DE]

I've never tried direct-sub-blocs of direct-sub-blocks but I'm afraid it may not work. You'd better re-format your data array.

By: Anonymous
Date: 2010-12-02
Time: 12:55

Re: Shorter Variables

Okay thanks a lot! yeah, i also thougth rearrange my array. thanks! have a nice weekend :)