Why can't I modify the topic list template?


(Joe) #1

I’ve been trying to override templates over the past couple of days.

I have read:
How to customize Discourse templates
Overriding built-in templates (and stylesheets)
Q&A design (blank)

I’ve also looked at Sam’s theme
discourse-simple-theme/header.html at master · SamSaffron/discourse-simple-theme · GitHub

I am able to add elements to a template via a plugin outlet

as discussed here:
Adding plugin-outlets using a theme

Like so:

<script type="text/x-handlebars" data-template-name="/connectors/topic-above-post-stream/foobar">
    <div style="height: 200px; width: 200px;background: red"></div>
</script>

I am also able to override the topic template

like so:

<script type="text/x-handlebars" data-template-name="topic">

<div style="height: 200px; width: 200px;background: blue"></div>

<!-- rest of the template untouched -->
</script>


What I am not able to do is to override the topic list template. For example,

If I use this:

<script type="text/x-handlebars" data-template-name="list/topic-list-item.raw">

<div style="height: 200px; width: 200px;background: red"></div>
<!-- rest of the template unchaged -->
</script>

In either the header or </head> section under either common or desktop I don’t see any changes.

So what silly thing am I doing wrong to cause it not to work?


Topic List Previews
#2

I tried the override on the topic list template using my testing instance. This is what I see when I add that script along with the rest of the unchanged template to a theme component’s Common --> </ head> :

Not sure if that’s what you are wanting to see, but it definitely did something for me.


(Joe) #3

Awesome, thank you very much for the confirmation @bob77707 :wine_glass:

That is indeed what I wanted to see. Just a red box to indicate that the template is being overridden.

It’s something else on my end then. I will check further and update here if I find anything. :ok_hand:


(Joe) #4

It turns out this may be caused by a small bug in topic list previews plugin.

The plugin may be affecting the template for topic list items even when disabled in the admin.

But I could be very wrong here.

I rebuilt the app without the plugin to confirm and the code works fine and the template is overridden.

Either way, logged a bug report :wine_glass:

Thanks again @tshenry.