Using Dynamic Content in articles

5 Comments

  • Don
    Comment actions Permalink

    This will be a very neat feature. In our guides sometimes multiple articles share the same first 3 or 4 steps. It would be nice to update them all at once.

    2
  • David Bjorgen
    Comment actions Permalink

    Aswin, this is how we dynamically display the current year in the footer of our Help Center.

    Include the following code in your script.js file (it's jQuery, but plain Javascript code can be substituted):

    $('.copyrightYear').html(new Date().getFullYear());

    Then include the following HTML code in your footer.hbs file (or wherever you want to display the current year):

    <span>&copy; <span class="copyrightYear"></span> Your Company Name</span>

     

    1
  • David Bjorgen
    Comment actions Permalink

    Don, you can use Javascript to prepend content to the beginning of your article. It's not optimal since it inserts the content after the page loads, but it allows you to change the content all at once.

    In your article, create an element and give it a unique ID or class name, like so: <div class="article-intro-steps"></div>.

    Then in your script.js file, include something like the following (it's jQuery, but plain Javascript code can be substituted):

    $('.article-intro-steps').prepend('<div>Step 1: Step one goes here.</div><div>Step 2: Step two goes here.</div><div>Step 3: Step 3 goes here.</div>');

    Then when you need to change the content, hop into the script.js file and change the prepended HTML code.

    1
  • Aswin Kannan
    Comment actions Permalink

    Thank you, David. That is just a random example I gave. But we have a lot of other instances where the Dynamic Content would be super helpful.

    1
  • Don
    Comment actions Permalink

    Thanks for your help David. I agree with Aswin, dynamic content would be super helpful. My use case may be a little different then Ashwin's.

     

    We have different set of articles, each product requires a different set of starter instructions for Step 1, 2, and 3.

    Example:

    Product 1 articles share: Steps 1, 2, and 3

    Product 2 articles share: Steps A, B, and C

     

    Cons:

    • This will require us to constantly update the script.js file. Not all of our writers are equipped to do that. 
    • Script.js file could be really big in order to accommodate different starter sets.
    • Can't upload new image steps to Script.js
    1

Please sign in to leave a comment.

Powered by Zendesk