XF 2.1 Add FA icons to Categories?

gogo

Well-known member
I searched a bit on the Internet and found the following code to be added to extra.less that's supposed to work.

Code:
.node.node--forum.node--id1 i:before{content:'\f5d0';}

where 1 is the node number of the first category.

However, no icons appears.

What's the proper codes then?
 
You may also need to add read or unread command in this code if above not solved your problem
Your code should be like that
.node--forum.node--id127.node--unread .node-icon i:before { content: "\f3a5"; } .node--forum.node--id127.node--read .node-icon i:before { content: "\f3a5"; }
 
Less:
.m-nodeIcons(@node-id; @icon; @faType: false) {
    .node--id@{node-id} {
        .node-icon i {
            &:before {
                & when (@faType = Brands) {
                    .m-faBase('Brands');
                }

                .node--forum&,
                .node--category& {
                    content: "\@{icon}";
                    color: @xf-nodeIconReadColor;
                    
                    .node--unread& {
                        content: "\@{icon}";
                        color: @xf-nodeIconUnreadColor;
                    }
                }

                .node--page& {
                    content: "\@{icon}";
                    color: @xf-nodeIconUnreadColor;
                }

                .node--link& {
                    content: "\@{icon}";
                    color: @xf-nodeIconUnreadColor;
                }
            }
        }
    }
}
.m-nodeIcons(2, f3a5);
.m-nodeIcons(3, f3a5);
You can use it. Result:
1589558830998.webp
 
Can be done using less and the grayscale property

I don't have my computer to test it yet. But does it work on categories, i.e. 'General', in your case?

//Tested. Not working on Category titles.

I need to add icons before Categories:

IMG_20200516_064931.webp
 
Last edited:
You may also need to add read or unread command in this code if above not solved your problem
Your code should be like that
.node--forum.node--id127.node--unread .node-icon i:before { content: "\f3a5"; } .node--forum.node--id127.node--read .node-icon i:before { content: "\f3a5"; }
Unfortunately this only works for forums but not categories.
 
Less:
.m-categoryIcon (@categoryid, @icon, @fa-type: false)
{
    .block {
        &--category.block--category@{categoryid} {
            .block-header {
                 a:before {
                     & when (@fa-type = false) {
                         .m-faBase();
                     }
                     & when (@fa-type = Brands) {
                         .m-faBase("Brands");
                     }
                     margin-right: 5px;
                     content: "\@{icon}";
                }
            }
        }
    }
}
.m-categoryIcon(1, f042);
you can use this code
 
You can use svg images.
I am using this code in extra.less
Just change path to your image and number for category

Less:
.block.block--category.block--category505 .block-header
{
        background-image: url('folder/example.svg');
        background-repeat: no-repeat;
        background-attachment: scroll;
        background-position: left center;
        background-clip: border-box;
        background-origin: padding-box;
        background-size: 45px;
}
 
Well, if you need an image and replace the section, then you can resort to what is described in the topic.
 
Finally I used the following codes:

Code:
.block.block--category.block--category1  .block-header:before {
    .m-faBase();
    content: '\f599';
    padding-right: 5px;
}

Please let me know if this is outdated or there's a better version. Thanks!
 
Top Bottom