Embedding Discourse Category not Topic

Hello all!

I run a community driven open source project and our Discourse forum is the heart of the community.

I am working on a website to host collaborative open source projects and I would like each project page to have a discourse discussion section similar to how @eviltrout has an embedded discourse comments section on his blog:

Instead of just embedding a single topic as a comments section, I would like to embed a category so that there can be multiple discussions going simultaneously.

So here’s my question: Is it possible to embed a discourse category instead of a topic and where do I start?

Thanks for your time! Love everything about discourse.

1 Like

It’s our goal on this year RGSoC to create more widgets for embedding, like a latest posts widget, etc.

Wish for us to be selected :wink:

15 Likes

I’m happy to work on coding it myself…is there a place to start? Should I build off of the existing embedding widget?

1 Like

Have you did it ? i would also enjoy that kind of widget :slight_smile: i’m searching to embed category also.

Unfortunately we weren’t selected to this year RGSoC. So the project is on hold.

1 Like

Ohhh, so i have to learn rss feed in order to get the same result :thinking:?

There isn’t much to learn in RSS, it’s just a XML document you can parse.

Maybe you can create a mockup of exactly what you want to achieve?

1 Like

Thanks you are you able to help?

Oh I see what you want now.

On the backend code responsible for the page located at dev.culibo.com/planning you must call the endpoint http://forum.culibo.com/c/Femme-Enceinte/latest.json which will respond with a JSON containing all the latest posts in the category.

Use this data to construct the HTML you want on the page.

3 Likes

Thanks you, i will try it. :smiley:

So i tryed it, and i got this result :frowning:

latestjson

“L’URL ou ressources demandée n’a pas été retrouvé” : mean The requested url was not found.

Could you please tell me, what latest.json consist of ?
Is ‘latest’ the correct name for the file of is it just a way of speaking?

Oops I forgot the list part of the URL, should be http://forum.culibo.com/c/Femme-Enceinte/l/latest.json

2 Likes

So we managed to acces a json page when going on the folowing url:

http://forum.culibo.com/c/Femme-Enceinte/l/latest.json


On our side, we use PHP and we use those fonction:

$allTopicsList = file_get_contents(‘https://forum.culibo.com/c/Femme-Enceinte/l/latest.json’);
var_dump($allTopicsList);
And File_get_content is returning NULL.

Reminder: our discourse’s url is: https://forum.culibo.com/
Our website url is: https://dev.culibo.com/planning

Update: we also tryed 2 other methods:

  • First div is the result of (JQUERY) load method.
  • Seconde div is Ajax requested (JS).
  • Third is the result of file_get_content (PHP)

Here is the code :

<div id="iframeLike"></div>
       <div id="iframeLikeII"></div>
       <div id="iframeLikeIII"><?= $allTopicsList ?></div>

       <script>
           $(function()
           {
               $("#iframeLike").load("<?= $forumURL ?>");

               $.ajax({
                   url: "<?= $forumURL ?>", // target
                   type: "GET", // HTTP request type
                   cache: false, // clearing the cache
                   dataType: "json", // type of the data to send
                   success: function(retrievedJsonData, statut) {
                       console.log(retrievedJsonData);
                       $("#iframeLikeII").text(retrievedJsonData);
                   },
                   error: function(resultat, statut, erreur) {
                       console.log(resultat);
                   }
               });
           });
       </script>

None of the 3 ways gives an answer, and here is the console message we have:

It means Multiorigines request had been bloqued ( Cross origin request ) The policy do not allow to consult the distant ressources on (https://URL.com) reason is CORS request failed