# Embedding Discourse Category not Topic

**URL:** https://meta.discourse.org/t/embedding-discourse-category-not-topic/83615
**Category:** Feature
**Created:** [March 23, 2018, 2:17am UTC](https://meta.discourse.org/t/embedding-discourse-category-not-topic/83615 "2018-03-23T02:17:46Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![Bar\_Smith](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bar_smith/32/92338_2.png) [@Bar\_Smith](https://meta.discourse.org/u/Bar_Smith)
#### Post date: [March 23, 2018, 2:17am UTC](https://meta.discourse.org/t/embedding-discourse-category-not-topic/83615/1 "2018-03-23T02:17:46Z")

</div>

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:

[https://fishtank.eviltrout.com/t/embedding-discourse-in-static-sites/87](https://fishtank.eviltrout.com/t/embedding-discourse-in-static-sites/87)

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.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [March 23, 2018, 4:08am UTC](https://meta.discourse.org/t/embedding-discourse-category-not-topic/83615/2 "2018-03-23T04:08:21Z")

</div>

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 😉

---

<div class="post-metadata">

### Author: ![Bar\_Smith](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bar_smith/32/92338_2.png) [@Bar\_Smith](https://meta.discourse.org/u/Bar_Smith)
#### Post date: [March 23, 2018, 4:24pm UTC](https://meta.discourse.org/t/embedding-discourse-category-not-topic/83615/3 "2018-03-23T16:24:01Z")

</div>

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

---

<div class="post-metadata">

### Author: ![TeoWneD](https://avatars.discourse-cdn.com/v4/letter/t/c67d28/32.png) [@TeoWneD](https://meta.discourse.org/u/TeoWneD)
#### Post date: [September 28, 2018, 9:12am UTC](https://meta.discourse.org/t/embedding-discourse-category-not-topic/83615/4 "2018-09-28T09:12:32Z")

</div>

> [@Falco](#):
>
> It’s our goal on this year RGSoC to create more widgets for embedding, like a latest posts widget, etc.

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

> [@Bar\_Smith](#):
>
> 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.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [October 1, 2018, 1:33pm UTC](https://meta.discourse.org/t/embedding-discourse-category-not-topic/83615/5 "2018-10-01T13:33:05Z")

</div>

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

---

<div class="post-metadata">

### Author: ![TeoWneD](https://avatars.discourse-cdn.com/v4/letter/t/c67d28/32.png) [@TeoWneD](https://meta.discourse.org/u/TeoWneD)
#### Post date: [October 1, 2018, 3:07pm UTC](https://meta.discourse.org/t/embedding-discourse-category-not-topic/83615/6 "2018-10-01T15:07:47Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [October 1, 2018, 3:14pm UTC](https://meta.discourse.org/t/embedding-discourse-category-not-topic/83615/7 "2018-10-01T15:14:22Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![TeoWneD](https://avatars.discourse-cdn.com/v4/letter/t/c67d28/32.png) [@TeoWneD](https://meta.discourse.org/u/TeoWneD)
#### Post date: [October 1, 2018, 3:24pm UTC](https://meta.discourse.org/t/embedding-discourse-category-not-topic/83615/8 "2018-10-01T15:24:48Z")

</div>

> [@Whitelist, allowed iframe](https://meta.discourse.org/t/whitelist-allowed-iframe/97738/12):
>
> I will start by giving a bit of our context:  
> we provide specific food planning for specific profile:
> 
> - example a pregnant woman
> 
> There is 2 way our user can access the forum. A regular one, where you click on the tab ‘forum’ and it redirect you to our forum. This way is actually working properly. ( see screeshot 1 )
> 
> [![12](https://global.discourse-cdn.com/meta/original/3X/a/6/a6ba6399b9622f5f6eaf3529d0605dd72ed9c98c.jpeg)  
> 12.JPG1914x1080 250 KB  
> ](https://global.discourse-cdn.com/meta/original/3X/d/d/ddaf51e34444c3c7308f791a10f8a8f7a8dd0806.jpeg)
> 
> Now the second way ( the reason why we looked for iframe etc )One of our user come on our website as example 1 ( pregnant woman ) under her planning, she will see the pregnant woman category from forum.  
> Why we wanted iframe first ? to embed category like this
> 
> [![azeae](https://global.discourse-cdn.com/meta/original/3X/4/9/494e99657be9e60462ca1aa9adf8e11da6819bf4.jpeg)  
> azeae.JPG1923x1069 216 KB  
> ](https://global.discourse-cdn.com/meta/original/3X/4/8/481673df189c58b641979e982fd8d0d19b7f792a.jpeg)
> 
> If we could have the corresponding forum category embeded under our planning would be the exact behaviour that we are looking for

Thanks you are you able to help?

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [October 1, 2018, 3:30pm UTC](https://meta.discourse.org/t/embedding-discourse-category-not-topic/83615/9 "2018-10-01T15:30:01Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![TeoWneD](https://avatars.discourse-cdn.com/v4/letter/t/c67d28/32.png) [@TeoWneD](https://meta.discourse.org/u/TeoWneD)
#### Post date: [October 2, 2018, 8:40am UTC](https://meta.discourse.org/t/embedding-discourse-category-not-topic/83615/10 "2018-10-02T08:40:50Z")

</div>

Thanks you, i will try it. 😃

So i tryed it, and i got this result ☹

 ![latestjson](https://global.discourse-cdn.com/meta/original/3X/d/9/d9fc6eea7366b9adc917e073962a96c05d608363.jpeg)

_“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?

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [October 3, 2018, 1:23pm UTC](https://meta.discourse.org/t/embedding-discourse-category-not-topic/83615/11 "2018-10-03T13:23:15Z")

</div>

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

---

<div class="post-metadata">

### Author: ![TeoWneD](https://avatars.discourse-cdn.com/v4/letter/t/c67d28/32.png) [@TeoWneD](https://meta.discourse.org/u/TeoWneD)
#### Post date: [October 3, 2018, 2:26pm UTC](https://meta.discourse.org/t/embedding-discourse-category-not-topic/83615/13 "2018-10-03T14:26:00Z")

</div>

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

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

 ![321654987](https://global.discourse-cdn.com/meta/original/3X/7/e/7e66407c559a7827f33b7203e060da1fe08cdeb8.jpeg)  
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](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/](https://forum.culibo.com/)  
Our website url is: [https://dev.culibo.com/planning](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:

 ![consoleMessage](https://global.discourse-cdn.com/meta/original/3X/c/5/c507f76eeb5b4c65cb6cf6a4ae8f3b94da11e690.jpeg)

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