Embedding a list of Discourse Topics in another site

Hi,

I was wondering if there was a way to display the avatar of the latest post author, and the category of the posts, just like on the front page of the forum, instead of only the topic titles ?

3 Likes

If you pass template=complete there is a lot more info in the embed:

3 Likes

Wow, thanks, that’s… too many informations :laughing: Is there something in between, or should I hide the unnecessary informations with custom css ?

Besides, this displays the topic author, not the latest post author.

3 Likes

The complete template wraps all the information in containers as it’s expected that each site will customize it to match their own design with CSS.

3 Likes

This is great!

Is it possible to change its width?

2 Likes

It’s a fluid container, it will adapt to the width of the parent element.

2 Likes

On my site it doesn’t. It’s too wide for the div it’s in, unfortunately.

2 Likes

Double check the markup, hide and position the elements properly, it should work in any container:

2 Likes

Sadly that doesn’t work on my website. I think maybe the CSS stuff in the responsive framework is confusing it. Is there any way of changing the width (e.g. to be 90% of its current value, or even some number of pixels less wide)?

2 Likes

Did you try using CSS like:

d-topics-list iframe {
    padding: 0 5%;
}

?

2 Likes

That doesn’t work. If I edit the iframe tag in Chrome’s F12 console to include width="100%" it works fine though… is there any way of making that change?

2 Likes

I added an example of how to add custom css to the list on the OP.

4 Likes

Thanks. I tried this. It does make the embedded topics display in a grid format. Unfortunately the width of the grid (i.e. two topics) is still the same width as before - nowhere near 100%.

The CSS above (d-topics-list iframe) doesn’t change the iframe at all. If only it could change it to have “width: 100%”…

I’ve tried it in an otherwise blank HTML document and it still is narrow. Any more ideas? :slight_smile:

3 Likes

Loving this embed… :sparkling_heart:

Couple of issues, and a feature request…:

  • If I add the allow-create="true" and the category="4" parameters, when I click on the ‘+ Create new topic’ button the ‘Add new topic’ modal/pop-up doesn’t spin up. Is it supposed to?
  • If I add the allow-create="true" and the tags="random-tag" parameters, when I click on the ‘+ Create a new topic’ button I get taken to the list of topics filtered to random-tag - but the tag drop-down doesn’t display ‘random-tag’ and when I click ‘Add new topic’ the tag hasn’t been pre-filled
  • Can we get the first, say, 100 words of the post into the complete theme?
4 Likes

This would be good!

Also I’m still keen to sort out the width thing… :slight_smile:

2 Likes

The CSS needs adding to your site, rather than Discourse’s embedded, CSS. So you’d have something like this:

<html>
  <head>
    <script src="https://jonathan5-discourse.com/javascripts/embed-topics.js"> 
    </script>
    <style>
      d-topics-list iframe{
        width: 100%!important;
        }
    </style>
  </head>
  <body>
    <d-topics-list discourse-url="https://jonathan5-discourse.com" category="5" per-page="5"></d-topics-list>
  </body>
</html>
5 Likes

Thank you very much. That seems obvious now. I went from failing to style the iframe’s internal CSS (trying within my site) to failing to style the iframe itself (trying within Discourse). I’ll give this a go and report back!

Update: Your CSS worked - thank you very much.

3 Likes

I’ve just tried this out. In my case it’s category=5 as that’s the category number I’m embedding. It doesn’t show the popup, but opens a new tab with URL https://forum.example.com/new-topic?category_id=5. Maybe you’ve got a browser setting that blocks this sort of “popup”?

2 Likes

Thanks for confirming it’s working for you, @Jonathan5. I disabled the discourse-tag-sidebar theme component, and now the pop-up’s working :sunglasses:

3 Likes

I will take a look into this :eyes:

4 Likes