Skip to main content
Participant
May 10, 2021
Answered

Displaying Author Name from Topic Properties

  • May 10, 2021
  • 2 replies
  • 216 views

Hi all,

 

I am new to Robohelp. I am using 2020 version and currently collaborating with my colleagues to develop knowledge bank. I want to use the Master Page and display the topic author (set in the topic properties) on the header of the page.

Has someone done that before? 

 

Thanks 

Yoel

    This topic has been closed for replies.
    Correct answer Amebr

    I hacked a thing together that will theoretically work.

     

    1. In the master page, switch to code view.

    2. Add the following to the head section:

    <script>// wait for the dom to load
    document.addEventListener("DOMContentLoaded", function() {
    	// grab the content of the rh-authors meta tag (change the name of the tag if you want to grab the value
    	//of a different meta tag
    	let m = document.querySelector('meta[name="rh-authors"]').content;
    	// stick it in the element with the id "author"
    	document.getElementById("author").innerHTML = m;
    } );
    </script>

    3. Where you want the author name to appear, insert:

    <span id="author"></span>

    Notes:

    * Make sure the span is empty. We'll plug in the name using a script.

    * You don't have to use a span tag. For example, you could just insert an empty p tag and give it the id="author" instead.  The script doesn't care what element you use, only what the id is. However, be aware the script will replace whatever content is inside that element, so you should make sure it's empty. 

     

    In the output, the values from the meta tag should be written in by the script as the page is loaded. You will need to make sure an author is added for every topic, though.

    2 replies

    AmebrCommunity ExpertCorrect answer
    Community Expert
    May 11, 2021

    I hacked a thing together that will theoretically work.

     

    1. In the master page, switch to code view.

    2. Add the following to the head section:

    <script>// wait for the dom to load
    document.addEventListener("DOMContentLoaded", function() {
    	// grab the content of the rh-authors meta tag (change the name of the tag if you want to grab the value
    	//of a different meta tag
    	let m = document.querySelector('meta[name="rh-authors"]').content;
    	// stick it in the element with the id "author"
    	document.getElementById("author").innerHTML = m;
    } );
    </script>

    3. Where you want the author name to appear, insert:

    <span id="author"></span>

    Notes:

    * Make sure the span is empty. We'll plug in the name using a script.

    * You don't have to use a span tag. For example, you could just insert an empty p tag and give it the id="author" instead.  The script doesn't care what element you use, only what the id is. However, be aware the script will replace whatever content is inside that element, so you should make sure it's empty. 

     

    In the output, the values from the meta tag should be written in by the script as the page is loaded. You will need to make sure an author is added for every topic, though.

    ysusantoAuthor
    Participant
    May 11, 2021

    That works. Thanks so much.

     

    Peter Grainge
    Community Expert
    Community Expert
    May 10, 2021

    If they have, they haven't posted it here in the last twenty years or so. 🙂

    ________________________________________________________
    See www.grainge.org for free Authoring and RoboHelp Information

    Use the menu (bottom right) to mark the Best Answer or Highlight particularly useful replies. Found the answer elsewhere? Share it here.