Changing template file with a plugin...
-
So, I've been wanting to change something on my nodebb forum for some time, but don't want to merge and mess with the lavender theme, can I create a plugin with a template file in that changes the topic.tpl topic-footer to how I want it, then if there's an update to the official lavender, I can move it over manually and carry on as normal? It may even be possible with javascript, but I basically want usernames on the left, it's a basic thing really which shouldn't be on the right. I may even want to include usernames under the avatar, similar to how groups currently work. Which would be easier?
-
Sure it's possible
So in a nutshell, plugins overwrite theme templates which overwrite base templates.
See https://github.com/NodeBB/nodebb-plugin-kitchen-sink/blob/master/plugin.json#L31
You don't need to do anything else besides that really, so lets say you want to overwrite home.tpl, just add a folder called
templates/home.tpl
and voila -
@psychobunny Would I then need to add the entire contents of the original home.tpl? Or just what I want to alter?
Thinking about it, I'm thinking it may be easier to add the username under the avatar, find the avatar div, then add what I need to after it. A bit like this...
-
Would I then need to add the entire contents of the original home.tpl?
yup. But solves this problem:
but don't want to merge and mess with the lavender theme
EDIT: What you have going down there actually looks pretty good (and tbh I have no idea why we don't do this). How about you make the change to Lav, post up a PR with a demo link and lets see what happens, maybe it will become official
-
@psychobunny Doing that under the username is a lot easier to implement, I just don't know the best way to handle long usernames, I could break them with word wrap, but you would then be known as
psychobunn y
I don't want to drop the font size much more either, going from 85% with
<small>
down to 80% fits your username in, but I'm sure longer names exist.Suggestions whilst I work on this would be great,
-
That's actually probably why that never ended up working out in the design
-
I would really hate if my name was
psychobun...
-
@psychobunny what about just
psycho...
-
-
@psychobunny create another admin group called
nny
. -
lmao
@baris knows he can get away with merging the PR without finding a solution to the ellipsis
because I'm the only one out of the three that's affected by it, therefore I have to fix it
EDIT: This is how it would look like in Pewter
-
.username { font-size: 80%; }
-