Custom Fields in Templates

Using them, Making them , Finding them

Custom Fields in Templates

Postby Marion Deckert » Sun May 03, 2009 3:03 am

I take the following steps to create and use a custom field in a template but it is never successful:

1) Open a new text document
2) Click FILE -> PROPERTIES and change the name of 'Info 1' to 'Test #'
3) Type 'Test #' on line one of the document
4) Click INSERT -> FIELD -> OTHER -> CUSTOM -> TEST # -> INSERT -> CLOSE
5) A gray field area appears in the document. Test it by changing the File Properties. It works.
6) Click FILE -> TEMPLATES -> SAVE. Name the Template 'TestTemplate'.
7) Close all documents
8) Click FILE -> NEW -> TEMPLATES AND DOCUMENTS -> TESTTEMPLATE -> OPEN
9) Click FILE -> PROPERTIES and insert various values in 'Test #'

The value in "File Properties" does not appear in the marked field (gray area) in the document, or if some value does appear it can not be changed by changing the value in File Properties. I have tried this in many settings and many ways. The Custom Field I create always works when I create the template but then fails to work when I use the template to create a new document.

Marion Deckert
OOo 3.0.X on Mac OSx other
Marion Deckert
 
Posts: 6
Joined: Sun May 03, 2009 2:44 am

Re: Custom Fields in Templates

Postby acknak » Sun May 03, 2009 5:27 am

Is it necessary to use the File > Properties fields?

If you need a field to be set by the user that's different for each document, then you can just use the Insert > Fields > Other > Variables > User Field. You don't need to use the File > Properties fields at all. If you create an "Input Field" for it, then the user will be prompted when creating a new document from the template.

If you really need the setting to be part of the document metadata (the File > Properties data), then you can display that in the document using the Insert > Fields > Other > DocInformation > Custom field.
AOO4/LO5 • Linux • Fedora 23
User avatar
acknak
Moderator
 
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: Custom Fields in Templates

Postby Marion Deckert » Thu May 07, 2009 3:09 am

aknack,
Thanks much for the reply. Unfortunately, I am still in the dark. You will have to hold my hand.
I want to have a template with a field that contains an assignment number so that every time I create a file from the template I can put the current assignment number in the field and it will appear in the header of every page of the assignment.

I take your advice. Insert > Fields > Other > Variables > User Fields. But now I am lost. I assume I need to name the field so I name it "assignment". I choose 'General' as the format. I insert and close. Then I use the template to start a document. In the filed is a '0'. I do not want a number to be in the field, I want to insert a number. Furthermore I am not prompted to fill the field. Help.

Marion Deckert
OOo 3.0.X on Mac OSx other
Marion Deckert
 
Posts: 6
Joined: Sun May 03, 2009 2:44 am

Re: Custom Fields in Templates

Postby acknak » Thu May 07, 2009 5:40 pm

Give this sample a try--is this what you're after?

The sample demonstrates two ways to prompt the user for information. The "Input Field" pops up a window when you open the template, asking for the assignment name. Since the name you enter goes into the document header, it will appear on each page.

Also in the header is a "Placeholder" field. This doesn't ask for a value, but it stands out to remind the user to click it and replace it with the appropriate text.

There's a date field there too, just for fun.

BTW, you really don't need anything special to display something on every page. Anything you type in the document header will appear on each page. The only thing the fields do is prompt you to enter the information. You could just type "dummy" text in the template and replace it by normal typing.

Just save the file somewhere you can find it again, then File > Open it in OOo.

If you want some help to create your own template, or modify this one, just ask.
Attachments
assignment_sample.ott
(7.86 KiB) Downloaded 687 times
AOO4/LO5 • Linux • Fedora 23
User avatar
acknak
Moderator
 
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: Custom Fields in Templates

Postby Marion Deckert » Fri May 08, 2009 4:24 pm

acknak,
Thanks a bunch. I finally got it. I was trying to use the 'variable' type rather than the 'function' type.
Now I have one problem left. I have been trying to get the date into my header and it always comes up in the short form. I want the long form. I assume that I need to go to System Preferences > International > Formats > Customize > Long From. However, whenever I do this it automatically changes back to the short form as soon as I close the window. I can not figure out how to get the long form in my date field.

Marion Deckert
OOo 3.0.X on Mac OSx other
Marion Deckert
 
Posts: 6
Joined: Sun May 03, 2009 2:44 am

Re: Custom Fields in Templates

Postby acknak » Fri May 08, 2009 5:10 pm

I think you want to insert the date as a field, as in the attached sample. Every field in the document has a format which is used to display the field value. You can set the format when you create the field, or you can double-click on an existing field to change its format.

Unfortunately, there's no way to change the default date format. OOo has a "factory default" for each locale ("mm/dd/yy" for US English), and if you want something else, you have to change the format for each instance manually.
AOO4/LO5 • Linux • Fedora 23
User avatar
acknak
Moderator
 
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3


Return to Templates

Who is online

Users browsing this forum: No registered users and 2 guests