Show preview / summary of article

4 Commentaires

  • Trapta Singh
    Community Moderator

    Hi @Ron de Vries,

    As long as your article or HC is public, I think it's quite possible to do so. You can simply add an id or class to the paragraph then using API you can get the article body. From that, you can choose the <p> element and use it.

    Thanks

    0
  • Ron de Vries

    Hi Trapta Singh

    Thanks! I actually have some JQuery that adds a css class when <p> contains a specific word or phrase (see below). Using API it would be possible to pick up this class and the body of the <div> class blockquote-important in your opinion? Is there any documentation on this as far as you know? 

    Cheers!

    $(document).ready(function() {
    // add css class
    $("p:contains('Important:')").addClass('blockquote-important');
    0
  • Trapta Singh
    Community Moderator

    Ron de Vries,

    I am not sure about the documentation but here I wrote a code roughly to achieve what you want. Try giving it a shot.

    $.get(ARTICLE_API, function(data) { // Replace ARTICLE_API with you article api url
    var articleBody = data.article.body;
    var parser = new DOMParser();
    var doc = parser.parseFromString(articleBody, 'text/html');
    console.log( $(doc).find('.blockquote-important').html() );
    });

    Thanks

    0
  • Ron de Vries

    Hi Trapta Singh

    Many thanks! We'll try and get this working using your examples as well. I will conduct with our Developer. If we get it working I will update this post. 

    Have a great day!

    0

Vous devez vous connecter pour laisser un commentaire.

Réalisé par Zendesk