Add a variable to every topic

Please post all questions on Help+Manual 8 here

Moderators: Alexander Halser, Tim Green

Post Reply
John Johann
Posts: 305
Joined: Mon Aug 21, 2017 7:35 pm

Add a variable to every topic

Unread post by John Johann »

Hi,
I need to add a topic-variable to each topic in a project with the contents of the <title>.
The variable is used multiple times within the topic for figure and image labels.
Previously the text was just entered as-is, but that is a pain when translating and is also not necessary.
I cannot use the topic-title variable as other projects link to this project and thus the topic-title of the linked project would overwrite the labels in the linked project.

Adding a variable to multiple topics can't be done from within HnM -- there is another topic in the forum mentioning regex for adding variables with static contents.

Does anyone have any other solutions for this sort of thing?

I have a little PowerShell script which works, but it borks the whitespace in the xml and makes a few other unwelcome formatting changes.
User avatar
Tim Green
Site Admin
Posts: 23181
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Add a variable to every topic

Unread post by Tim Green »

If you want to add anything to the content of lots of topics, use Notepad++ directly on the topic XML files. It won't mess with anything else in the file or change things like encoding or whitespace or line endings without you actually wanting to do it, as Microsoft tends to do.

If you want an even better solution, get the Regex Buddy and PowerGREP combo from JG Software. Regex Buddy helps you to build and test Regexes before using them and is also the best course in Regex you can find anywhere. PowerGREP is the best multi-file search and replace tool anywhere, on any platform, at any price. It may seem a little pricey, but if you do things like this even more than once you will feel that it has already paid for itself in a single afternoon. 8)
Regards,
Tim (EC Software Documentation & User Support)

Private support:
Please do not email or PM me with private support requests -- post to the forum directly.
John Johann
Posts: 305
Joined: Mon Aug 21, 2017 7:35 pm

Re: Add a variable to every topic

Unread post by John Johann »

Hi Tim,
I actually used Notepad++ to insert the topic-variable in each topic with a regular expression.

And after a little playing around, it is now as desired :-)
Post Reply