How to use a placeholder in a template

I’m creating a template where in some parts I have text like
“Document xxx … in this document xxx …”
that is, with a variable part that I wish to input once in a new document and from then on being referred anywhere else in the document (with a field name?).

Looks quite simple to me at first sight, but I am a bit confused by “placeholders”, which seem to be what I need, for a single use, but I don’t know how to instantiate them more than once - like a referenced text in first page header and in a different default page header.

Placeholders are just dummy text which will be replaced by your real text by overtyping. This is definitively not what you are looking for.

You didn’t describe the characteristics of your “xxx” variable data. I’ll then assume they are some intrinsic properties of the document.

You can define them as Custom Properties in File>Properties. Each property has a name and a (typed) value. Each property creates a field.

This field is available for Insert>Cross-reference in DocInformation tab, Type Custom (expandable list).

You mention a template. If all your documents share the same properties (but obviously not their values), you can define the properties themselves in the .ott document with dummy value (such as a reminder to change it).

When you instantiate the template, the properties set is transferred into the newly created real .odtdocument and detached from the template. From now on, the properties set is specific to your document, with its own values. Even if the template is modified, the properties set will not be impacted (just like template initial text). Only styles are updated.

What I describe here is guaranteed to work with .odt, not with .doc(x). Since you did not mention OS name, LO version and save format, I give you a standard answer.

Thank you for the comprehensive answer, my original question was actually incomplete - I had the feeling I was just missing a basic guide.
The Custom Properties are a good solution, for the parts where my template is about a most generic document format, and I want to add a document description (to be recalled in the same doc) and a document ID/code (still to be mentioned many times, as in headers/footers).
Use of Placeholders looked to me a good solution for some parts, like when I want to customize a single instance of text. However, it didn’t work as expected: I insert placeholders in the .ott, but when I click on the in the .odt I have no dialog to insert text, nothing special except selecting them and replacing like any ordinary text.
The note about .odt/.doc(x) is interesting, as I will work with ODT but eventually will share the document as DOCX; but as it will happen when my fields are assigned, I hope this won’t pose any problem.
The running OS is Windows, LO version is still 7.6.7.2 (I had too many compatibility issues with later versions, at this location).

You can use placeholders but you need to wrap them in a bookmark. Include a space each side of the placeholder in the bookmark or it will fail when you add the actual text. You need to remember to update the fields, Tools > Update > Update all
PlaceholderInsideBookmark.odt (30.2 KB)

The Writer Guide? Download from English documentation | LibreOffice Documentation - LibreOffice User Guides

Description is a “standard” property in Description tab. It is called Comments but has the same purpose. It can be inserted in the document via usual cross-reference (or field) in the DocInformation tab.

The ID/Code is more difficult. There a dropdown selector in Description with an Identifier choice but I don’t know how to retrieve it in a field. Perhaps a partial implementation. Consequently, define it as a custom property.

Regarding properties vs. placeholder:

  • properties are initialised by File>Properties and can be reused many times in the document
  • placeholders have no intrinsic value (they show at most a reminder text) and must be replaced individually by significant text; each occurrence is independent from any other

Good to know, I’ll look at that.

The Writer Guide? Definitively not.
First, if I search text for “placeholder” has no useful results.
Second, if I click on Help in the Fields dialog, interestingly enough it founds something. Directs me to a page where it states that a placeholder inserts a… placeholder. I mean, an English dictionary is more helpful than that.

Don’t disregard the Writer Guide. It is not perfect indeed, but not that bad. I started with it and learnt many interesting things. It rather describes the implemented application than being a tutorial on the art of writing with a document processor (I mean no introduction on semantic styling; for that read Bruce Byfield’s book available at the same URL). You have to practice and simultaneously try to abstract what is the chore of “literary” creative process.

As a matter of fact, built-in help is more practical when you need concise spot-help about parameters for a feature. But there are also unfortunately tautologies like your example of placeholder = placeholder. Since not all translations are equally good, it is sometimes worth to have a look at English built-in help in an attempt to disambiguate terms (but requires knowledge of typographical vocabulary though recent releases replaced specialised words by common ones which, alas, are less precise and accurate thus causing possible misunderstanding).