• hi guys,

    recently I have tried to create a script that displays a random image in a folder as a header image. however, I cam across some problems.

    first we can add an image to the custom header like so:

    <img src=<!-- url image--> class='center'>

    then add css to custom css like so

    img.center {
        display: block;
        margin-left: auto;
        margin-right: auto

    however, i want to only show the image on a certain category. so I tried this for category 1:

    $(window).on('action:ajaxify.contentLoaded', function(){
      if (ajaxify.data && ajaxify.data.cid && ajaxify.data.cid === 1) {
            <!-- insert html image-->

    nothing happens.

    Can anybody guide me on how to display an header-image when in a certain category?

    Thank you,

  • NodeBB Admin

    What version of NodeBB and where did you place the custom javascript code?

    Maybe try

    $(window).on('action:ajaxify.end', function(){
      if (ajaxify.data && ajaxify.data.cid && parseInt(ajaxify.data.cid, 10) === 1) {
            <!-- insert html image-->
      } else {
           <!-- remove html image -->

    Put some console.logs in there to make sure the expected code is being executed.

Suggested Topics

| | |

© 2014 – 2022 NodeBB, Inc. — Made in Canada.