Open widget to a specific article or category

Some customers like to be able to open the widget directly to a specific article or category. The steps for each are quite similar.

To open the widget to a specific article, you'll need to use two methods:

  • _ko19.openArticle('article-identifier'); -- this loads the specific article you want into the widget. For the article-identifier, you can use one of two options:
    • The article's relative permalink (for example, for this article, it would be open-widget-to-a-specific-article)
    • The article's ID (found by opening the article in edit mode: the ID is the number that comes after /aid/ in the URL)
  • _ko19.open(); --this call opens the widget

Using only the openArticle method will prime the widget to open to a specific article the next time it's opened by your user.

Similarly, to open the widget to a specific category, you'll need to use two methods:

  • _ko19.openCategory('category-identifier'); -- this loads the specific article you want into the widget. For the category-identifier, you can use one of two options:
    • The category's relative permalink (for example, for the Widget 2.0 category, it would be widget-20)
    • The category's ID (found by opening the category in edit mode: the ID is the number that comes after /cid/ in the URL)
  • _ko19.open(); --this call opens the widget

A good way to use these methods is on a specific hyperlink in your documentation, to open the widget to a specific article. In this case, you'll insert a hyperlink with an empty URL, and add two onclick events--one for each of the methods above.

So, for example, this link opens the widget directly to the article you're reading right now. Here's the code for it:

<a href="#" name="" onclick="_ko19.openArticle('open-widget-to-a-specific-article'); _ko19.open();return false;" title="Open widget to a specific article or category">Open widget directly to an article</a>

So, for example, this link opens the widget directly to the Widget 2.0 category you're reading right now. Here's the code for it:

<a href="#" name="" onclick="_ko19.openCategory('widget-20'); _ko19.open();return false;" title="Widget 2.0">opens the widget directly to the Widget 2.0 category</a>

Scrolling behavior

For the hyperlinks, you can have different scrolling behavior on the main page when the link is clicked by formatting the link differently:

  • Use an href="#" by itself to force the main page to scroll to the top when the widget is opened, as in this link opens the widget directly to the article you're reading right now.
    <a href="#" name="" onclick="_ko19.openArticle('open-widget-to-a-specific-article'); _ko19.open();" title="Open widget to a specific article or category">Open widget directly to an article</a>
  • Use an href="#" with a return false; at the end of the onclick to prevent the scroll (as used in the examples above)
  • You can also use href="javascript:void(0);" to achieve the no-scroll behavior:
    <a href="javascript:void(0);" name="" onclick="_ko19.openArticle('open-widget-to-a-specific-article'); _ko19.open();" title="Open widget to a specific article or category">Open widget directly to an article</a>