Bar_Smith
(Bar Smith)
March 23, 2018, 2:17am
1
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:
It’s been possible to embed comments from a Discourse forum on to other sites for a while now, but the only publishing software we supported was Wordpress. Many people, myself included, don’t use Wordpress to run their sites. This very blog is a...
Reading time: 14 mins 🕑
Likes: 7 ❤
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
Falco
(Falco)
March 23, 2018, 4:08am
2
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
15 Likes
Bar_Smith
(Bar Smith)
March 23, 2018, 4:24pm
3
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
TeoWneD
(TeoWNeD)
September 28, 2018, 9:12am
4
Have you did it ? i would also enjoy that kind of widget i’m searching to embed category also.
Falco
(Falco)
October 1, 2018, 1:33pm
5
Unfortunately we weren’t selected to this year RGSoC. So the project is on hold.
1 Like
TeoWneD
(TeoWNeD)
October 1, 2018, 3:07pm
6
Ohhh, so i have to learn rss feed in order to get the same result ?
Falco
(Falco)
October 1, 2018, 3:14pm
7
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
TeoWneD
(TeoWNeD)
October 1, 2018, 3:24pm
8
I will start by giving a bit of our context:
we provide specific food planning for specific profile:
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.JPG1914x1080 250 KB
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.JPG1923x1069 216 KB
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?
Falco
(Falco)
October 1, 2018, 3:30pm
9
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
TeoWneD
(TeoWNeD)
October 2, 2018, 8:40am
10
Thanks you, i will try it.
So i tryed it, and i got this result
“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?
Falco
(Falco)
October 3, 2018, 1:23pm
11
Oops I forgot the list part of the URL, should be http://forum.culibo.com/c/Femme-Enceinte/l/latest.json
2 Likes
TeoWneD
(TeoWNeD)
October 3, 2018, 2:26pm
13
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