Topic prefix

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

Moderators: Alexander Halser, Tim Green

Topic prefix

Unread postby John Johann » Fri Aug 30, 2019 6:03 am

Hi,
Is there a global variable for the Miscellaneous Option "Prefix" that can be automatically added to the topic ID?
Thanks
John Johann
 
Posts: 164
Joined: Mon Aug 21, 2017 7:35 pm

Re: Topic prefix

Unread postby Tim Green » Fri Aug 30, 2019 8:20 am

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.
User avatar
Tim Green
Site Admin
 
Posts: 20935
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany

Re: Topic prefix

Unread postby John Johann » Fri Aug 30, 2019 9:20 am

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.
John Johann
 
Posts: 164
Joined: Mon Aug 21, 2017 7:35 pm

Re: Topic prefix

Unread postby Tim Green » Fri Aug 30, 2019 4:00 pm

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.
User avatar
Tim Green
Site Admin
 
Posts: 20935
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany

Re: Topic prefix

Unread postby Simon_Dismore » Fri Aug 30, 2019 5:20 pm

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_).
Simon_Dismore
 
Posts: 131
Joined: Thu Jul 13, 2017 2:57 pm

Re: Topic prefix

Unread postby John Johann » Sat Aug 31, 2019 11:47 am

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.
John Johann
 
Posts: 164
Joined: Mon Aug 21, 2017 7:35 pm

Re: Topic prefix

Unread postby Simon_Dismore » Sat Aug 31, 2019 2:50 pm

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.
Simon_Dismore
 
Posts: 131
Joined: Thu Jul 13, 2017 2:57 pm


Return to Help & Manual 7 Forum

Who is online

Users browsing this forum: No registered users and 3 guests