Topic prefix

Please post all questions and comments regarding Help & Manual 7 here.

Moderators: Alexander Halser, Tim Green

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

Topic prefix

Unread post by John Johann »

Hi,
Is there a global variable for the Miscellaneous Option "Prefix" that can be automatically added to the topic ID?
Thanks
User avatar
Tim Green
Site Admin
Posts: 23155
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Topic prefix

Unread post by Tim Green »

Hi John,

This isn't available in Help+Manual itself but you can do this with the Toolbox power tools utility included with the Premium Pack add-on:

http://www.it-authoring.com/info/pp3hel ... fixes.html

https://www.helpandmanual.com/products_hm_pluspack.html
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: Topic prefix

Unread post by John Johann »

Hi Tim,
Thanks -- I'm not trying to set it -- I do that manually -- I want to get the value which I set myself out of the prefix field for use somewhere else.
User avatar
Tim Green
Site Admin
Posts: 23155
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Topic prefix

Unread post by Tim Green »

John Johann wrote:Thanks -- I'm not trying to set it -- I do that manually -- I want to get the value which I set myself out of the prefix field for use somewhere else.
There's no explicit interface or variable for that. The only way to get that would be to parse the XML of the .hmxp file and get it from there. :?
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.
Simon_Dismore
Posts: 205
Joined: Thu Jul 13, 2017 2:57 pm

Re: Topic prefix

Unread post by Simon_Dismore »

John Johann wrote:I want to get the value which I set myself out of the prefix field for use somewhere else.
If you want it at run-time in CHM or WebHelp you might get it from the document URL:

Code: Select all

document.URL.substring(1+document.URL.lastIndexOf('/')).split('_')[0]
This assumes you are not on index.html, and that your prefix ends with a unique symbol (underscore is recommended, e.g. HM_).
John Johann
Posts: 305
Joined: Mon Aug 21, 2017 7:35 pm

Re: Topic prefix

Unread post by John Johann »

Thanks.
I have a CHM template which I use in a run-time merged set-up. The first topic in each child is a centred image which the user can click on to get to the intro. The image e.g. ABC_image.png is identified by the abbreviation of the child project. I was hoping to automate the "ABC_" with a nice little variable. The Miscellaneous options prefix field itself doesn't allow me to define a user-defined variable.
Simon_Dismore
Posts: 205
Joined: Thu Jul 13, 2017 2:57 pm

Re: Topic prefix

Unread post by Simon_Dismore »

John Johann wrote:Thanks.
I have a CHM template which I use in a run-time merged set-up. The first topic in each child is a centred image which the user can click on to get to the intro. The image e.g. ABC_image.png is identified by the abbreviation of the child project. I was hoping to automate the "ABC_" with a nice little variable. The Miscellaneous options prefix field itself doesn't allow me to define a user-defined variable.
I just tried this in the browser and you can script it:

Code: Select all

// quick hack, should be all on one line - use variables to clean this up for production
document.getElementById("myID").src = document.getElementById("myID").src.split('_')[0] + document.URL.substring(1+document.URL.lastIndexOf('/')).split('_')[0] + "_" + document.getElementById("myID").src.split('_')[1]
Assuming:
  • image has id='myID'
  • image src filename as used in H+M source code begins with underscore, so will be published as e.g. src='/path/to/_myimage.png'
  • image path does not contain underscores, e.g. src='/path_to/_myimage.png' wouldn't work because code will split it at the underscore between 'path' and 'to'
  • prefix for project ends with underscore, e.g. 'abc_' so topics will be published as e.g. 'https://mysite.com/help/abc_mytopic.html'
  • you want to prepend the prefix to the src filename, e.g. to make src='/path/to/abc_myimage.png'
Feels a bit fragile to me. Would be better to have an official solution that works across all the publishing formats.
John Johann
Posts: 305
Joined: Mon Aug 21, 2017 7:35 pm

Re: Topic prefix

Unread post by John Johann »

I was looking into this again and found that I can automate the image in the CHM.
To do so, I defined another variable with the same content as the topicprefix in the Miscellaneous options.
Some inline html code with the image source --> <img src="<%T_PREFIX%>option_cover_800.png" width=...
outputs the image from the baggage as desired.

For PDF output, I have a separate topic where I would like to achieve the same. Html code isn't going to work there of course. Simply changing the image src to the variable doesn't work either.

Code: Select all

     <para styleclass="Normal"><image src="ABC_option_cover.png" scale="-100.00%" width="2013" height="1995"></image></para>
     <para styleclass="Normal"><image src="&lt;%T_OPTION_COVER%&gt;" scale="-100.00%" width="2013" height="1995"></image></para>
Any suggestions?
User avatar
Tim Green
Site Admin
Posts: 23155
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Topic prefix

Unread post by Tim Green »

Hi John,

You can't set the image source with a variable at the moment. That would involve resolving the variable at edit time to display the image in the editor and that isn't currently supported. The only option here for PDF would be to use conditional text tags and a choice of different images. That's a little clunky because then you always see all the images in the editor, but I'm afraid that's the only way to do it at the moment. :?
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: Topic prefix

Unread post by John Johann »

Hi Tim,
Thanks for the answer.
I don't actually need to see the image -- I can't see it in the HTML variant either. I'd be happy enough if the variable for the image is resolved on publishing the PDF the same as when it is just inserted in a text.
Post Reply