Sidebar: Jquery called in the Custom HTML page?

Technical Support
  • I would like to move the Categories page to this Jquery sidebar menu: MMenu or Simple Menu

    Can i do that in the custom HTML page? Trying to avoid a plugin or template change if possible... Putting nodebb widget space into one is harder than i thought. 😄

  • You can, but there is already a slide menu on mobile so you might run into issues there. Also, it might be slower than using a widget/plugin because you need to grab the data from the server and parse it into html.

    I changed the navigation option for categories to have a route of "#" and an id of "catmenu" to stop it from going to the categories page, then I loaded one the scripts and append the data from the categories api to the menu.

    (This should get you started, I'll add some more comments later, but must sleep now. 💤 )

    <div class="sidebar left" style="position:fixed;top: 0;left: 0;bottom: 0;width: 270px;background: #448AFF;z-index:1051;"></div>
    <script>
    require(['https://cdnjs.cloudflare.com/ajax/libs/jquery-sidebar/3.3.2/jquery.sidebar.min.js'], function () {
        $(".sidebar.left").sidebar().trigger("sidebar:close");
    
        $.getJSON('/api/categories', function(data){
            data.categories.forEach(function(category){
                $('.sidebar.left').append('<p><a href="/category/' + category.slug + '">' + category.name + '<a></p>');
            });
        });
    
        $('body').on('click', '#catmenu', function(e){
            $(".sidebar.left").trigger("sidebar:toggle");
            return false;
        });
    });
    </script>
  • Hey, thanks! Thats a real leg up on the work ahead. 😄

  • interesting, jquery install is demanding node 0.10.40 while the existing node is 0.10.37. Updating going to cause any incompatibilities with nodebb?


Suggested Topics


  • 1 Votes
    7 Posts
    110 Views

    @baris It works! Brilliant. I wasn't expecting it to be that easy 😁

  • 1 Votes
    1 Posts
    118 Views

    1st of all i'm new to Nginx, and this is the 1st time i'm really setting up NodeBB. So pls forgive me when i'm asking basic dummy questions.

    Basically followed this
    https://docs.nodebb.org/installing/os/ubuntu/
    using Ubunt 20. So far so good with the installation.

    The folder structure looks like this in the server:

    /home/user/abcde/index.html /root/nodebb (This might be a mistake but ...)

    Eventually index.html will have a hyperlink which links to the NodeBB forum.

    Right now the /etc/nginx/nginx.conf has a block like this, and index.html does load fine in browser

    server { server_name mysite.com; location / { root /home/user/abcde; } }

    My question is: how to modify nginx.conf so it can load the NodeBB as well ?
    Again the final goal is ppl can access NodeBB from its link from index.html.

    Thanks very much for your help !

  • 0 Votes
    4 Posts
    267 Views

    You can run git cherry-pick 74aa12c95b2acd3dab01b283c33eb24a358411aa to get it.

  • custom javascript error

    Technical Support
    0 Votes
    3 Posts
    212 Views

    Just a correction: it's not that you don't need the <script> - it's just illegal unless you're writing something like jsx. When run this will immediatly cause Uncaught SyntaxError: Unexpected token '<' - because everything you put in custom Javascript is already put into a <script> tag.
    If you want to include another script either use some kind of imports (for example es modules) that works inside JS, or put the <script src=""> tag in custom header instead.

  • Adding html to pages

    Moved Technical Support
    0 Votes
    7 Posts
    3k Views

    nodebb hosting service