How can i add a class to the body ?

NodeBB Development
  • Hi !

    I'm currently trying to make a PR to implement a feature, i've created a field bodyClass into the Category settings and now i don't find how i can inject it into the body class when i'm into the topic list and reading a topic.

    I've found that buildBodyClass is related to the URL, but i don't find how to use my custom attribute 😕

    There is any documentation about the source code?

  • You can use, or filter:middleware.render and modify bodyClass keep in mind the topic page already has a body class that also contains the category, so for example this page has this class. skin-noskin page-topic page-topic-11761 page-topic-how-can-i-add-a-class-to-the-body page-topic-category-3 page-topic-category-nodebb-development

  • Oh! I haven't noticed this change, this is awesome 👍

Suggested Topics

  • 0 Votes
    1 Posts

    Hello 😄

    Im a newbie with css so i found this code in the NodeBB Forum

    ul.categories [data-cid="1"]::before { content: "Neuigkeiten"; background: #1e1f33 url( no-repeat 10px center; } ul.categories [data-cid="3"]::before { content: "Blocks"; background: #1e1f33 url( no-repeat 10px center; } ul.categories [data-cid="1"]::before, ul.categories [data-cid="3"]::before { color: #fff; display: block; position: relative; height: 40px; line-height: 40px; font-size: 15px; border-bottom: 1px #0c2b51 solid; text-align: left; padding-left: 70px; font-style: normal; text-transform: uppercase; margin-bottom: 20px; font-family: "Roboto","Helvetica Neue",Helvetica,Arial,sans-serif; border-radius: 5px; margin-left: 10px; }

    I am also shown a category above as you can see here

    alt text

    But my question now is how do I get more category sections? In CSS as I see it there are 2 categories defined or do I see it wrong?

    can you help me?

    MfG Funkel

  • 0 Votes
    6 Posts

    Thank you for your reply, and sorry for lack of information. → success to show nodebb. → return 404 on parent site(my case is wordpress on nginx). → return misconfigured csrf error on nodebb. → return /nodebbcategories not found on nodebb.

    I reloaded nginx.
    I setup and restart nodebb each time.

    nginx -t → syntax and test is successful.

    now I am trying below

  • 0 Votes
    5 Posts

    @pitaj yeah. It's starting work

  • 0 Votes
    6 Posts

    I think you're right... in the case of an anonymous function, the function itself would be in memory too.

    Then in that case, it's probably just easier to set up cron in general 😝

  • How to add a new route

    NodeBB Development
    0 Votes
    9 Posts

    It is working now! Thanks guys! It was the variable name top. I changed it to _top and it works perfectly