How to add topics_list template for widget?
-
Hey guys!
I trying modify widget and add setting to add custom html in topic Title.
To do it I added this changes in this files:
1. https://github.com/NodeBB/nodebb-theme-harmony/blob/main/library.js#L80
{ name: 'Main post title', template: 'topic.tpl', location: 'mainpost-title', },
2. https://github.com/DevSources/nodebb-theme-harmony-v3/blob/main/templates/topic.tpl#L11
{{{ if widgets.mainpost-title.length }}} <span data-widget-area="mainpost-title"> {{{each widgets.mainpost-title}}} {{widgets.mainpost-title.html}} {{{end}}} </span> {{{ end }}}
This is works and I can add a custom html in
mainpost-title
and view it on/topic
page. But I want to show a custom element from /topic titles and on two more pages/recent
and/category
.To do it I need modify this file
topics_list.tpl
and add previous code with{{{ if widgets.mainpost-title.length }}}
nodebb-theme-harmony/templates/partials/topics_list.tpl at main 路 NodeBB/nodebb-theme-harmony
Harmony theme for NodeBB v3.0+. Contribute to NodeBB/nodebb-theme-harmony development by creating an account on GitHub.
GitHub (github.com)
But I don't understant how to add this page template
templates/partials/topics_list.tpl
in this settings https://github.com/NodeBB/nodebb-theme-harmony/blob/main/library.js#L63I trying add this template
topics_list.tpl
to setting in this file, but it's not work'categories.tpl', 'category.tpl', 'topic.tpl', 'users.tpl', 'unread.tpl', 'recent.tpl', 'popular.tpl', 'top.tpl', 'tags.tpl', 'tag.tpl', 'login.tpl', 'register.tpl', 'partials/topics_list.tpl',
-
-
-
@baris it's possible to get
cid
andtid
on page/recent
and/category
via html widget? I trying this in html widget for page/recent.tpl
and/category.tpl
Topic ID: {./tid}, Category ID: {./cid}
and have this result:
/recent.tpl
Topic ID: , Category ID:
tid & cid empty/category.tpl
Topic ID: , Category ID: 3
tid emptyFor example what I mean...
-
Your html widget gets rendered server side once and then gets inserted into each topic on the topic list so it won't work like that.
You are better of overriding topics_list.tpl or using
filter:topics.get
hook in a plugin to modify the topic title. -
This settings for widgets not work on
/category
and/recent
pageSet the topic IDs you want to display this widget on (separated by commas) Set the category IDs you want to display this widget on (separated by commas)
-
-