This article is sourced from a post on the official Flarum forum. It has been tested and works on CV 7.4.0; test it yourself on other versions.
To add a separate background to each category on the category page, it is not difficult. However, there is one issue: if you use this, you can no longer use tag descriptions.
Modify the following file:
vendor/flarum/flarum-ext-tags/js/forum/dist/extensions.js
Change the following:
return m(
'li',
{ className: 'TagTile ' + (tag.color() ? 'colored' : ''),
style: { backgroundColor: tag.color() } },
m(
'a',
{ className: 'TagTile-info', href: app.route.tag(tag), config: m.route },
m(
'h3',
{ className: 'TagTile-name' },
tag.name()
),
m(
'p',
{ className: 'TagTile-description' },
tag.description()
),
to:
return m(
'li',
{ className: 'TagTile ' + (tag.description() ? 'colored' : ''),
style: { background: tag.description() } },
m(
'a',
{ className: 'TagTile-info', href: app.route.tag(tag), config: m.route },
m(
'h3',
{ className: 'TagTile-name' },
tag.name()
),
Then go to Admin — Appearance — Custom Styles and add:
.SelectTagListItem-description {
display: none;
}
Usage: In the admin panel, go to Category Settings and enter the following in the description of each node:
url(http://xxx.com/xxx.jpg)
Replace http://xxx.com/xxx.jpg with the background image you want for each node.
The final result is shown below:
