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

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

「いいね!」 3

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

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

This is great!

Is it possible to change its width?

「いいね!」 2

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

「いいね!」 2

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

「いいね!」 2

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

「いいね!」 2

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

Did you try using CSS like:

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

?

「いいね!」 2

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

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

「いいね!」 4

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

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

This would be good!

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

「いいね!」 2

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>
「いいね!」 6

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.

「いいね!」 4

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

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

I will take a look into this :eyes:

「いいね!」 4