How can I add a section in the Admin Menu?

Solved NodeBB Development
  • Hey guys, looked at the documentation briefly and didn't see any ways to add a section
    to the Administration Menu.

    Something like this:
    lf5llfT[1].png

  • To do this you want to:

    First, add

    <!-- IF custom_menu.length -->
      <div class="sidebar-nav">
        <ul class="nav nav-list">
          <li class="nav-header"><i class="fa fa-fw fa-th"></i>Your List Category</li>
          <!-- BEGIN custom_menu -->
          <li>
            <a href="{relative_path}/admin{custom_menu.route}">
            <!-- IF custom_menu.icon -->
            <i class="fa {custom_menu.icon}"></i>
            <!-- ENDIF custom_menu.icon -->
            {custom_menu.name}
            </a>
          </li>
        <!-- END custom_menu -->
        </ul>
      </div>
    <!-- ENDIF custom_menu.length -->
    

    to /src/views/admin/partials/menu.tpl.

    Then, add

    custom_menu: results.custom_header.custom_menu,
    

    to

    var data = {
      relative_path: nconf.get('relative_path'),
      configJSON: JSON.stringify(results.config),
      user: userData,
      userJSON: JSON.stringify(userData).replace(/'/g, "\\'"),
      plugins: results.custom_header.plugins,
      authentication: results.custom_header.authentication,
      scripts: results.scripts,
      'cache-buster': meta.config['cache-buster'] ? 'v=' + meta.config['cache-buster'] : '',
      env: process.env.NODE_ENV ? true : false,
    };
    

    (around line 100) in /src/middleware/admin.js.

    As for the plugin: I've created a quick and dirty example you can have a look at over at GitHub.

    In a nutshell, the same aproach as you would add a normal "Installed Plugins" entry, with the exception that you define your own array that is passed to the template, hence the need to change two core files. 🙂

  • I know this is an old topic, but I just ran into this today and wanted to add an admin nav section in the minimally invasive way possible. This technique worked for me and I'm wondering if anybody has any thoughts about this being a good or bad approach to quickly adding a custom admin navigation menu from a plugin. Any critiques appreciated!

    plugin/static/js/admin/custommenu.js:

    var adminInitialized = false;
    
    $(window).on('action:ajaxify.start', function(data) {
    	if (!adminInitialized) {
    
    		$('ul#main-menu').append('\
    		<li class="dropdown menu-item">\
    			<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Custom Menu</a>\
    			<ul class="dropdown-menu" role="menu">\
    				<li><a href="/admin/my-custom-route">Custom Route</a></li>\
    			</ul>\
    		</li>');
    
    		adminInitialized = true;
    	}
    });
    

    plugin.json:

    "acpScripts": [
    	"static/js/admin/custommenu.js"
    ]
    
  • This post is deleted!

Suggested Topics


  • 0 Votes
    1 Posts
    134 Views

    Re: Creating multiple Node BB Admins but with limited access to ACP

    @PitaJ , how can we create multiple admins? Can we assign a user as admin in Dashboard, please let me know.

  • 1 Votes
    3 Posts
    308 Views

    @julian thank you for your answare, it's also gonna help me. but i meand in my question to docs about the modules. for example, i'll use the composer module:

    require(['composer/formatting'], function (f) { });

    or the topics module:

    require(['forum/topic'], function (t) { });

    and i want to learn their methods and properties.

  • 0 Votes
    1 Posts
    1k Views

    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(https://i.imgur.com/liB8eUb.png) no-repeat 10px center; } ul.categories [data-cid="3"]::before { content: "Blocks"; background: #1e1f33 url(https://i.imgur.com/eSUaQuV.png) 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
    1 Posts
    202 Views

    As the title says, I'm trying to make it so only admins/mods can upload or adjust the cover images for people's profiles. I've looked around the various hooks and what not, but I'm at a loss of how to achieve this.

    I was originally thinking I could edit the function of the upload/edit buttons and check if the person has the required permissions; but I cannot seem to find where their functionality is actually defined.

  • 0 Votes
    9 Posts
    1k Views

    Thank you, I didn't try that approach, instead, I realized I can change the settings directly from the code. So I'm baking in my settings into my plugin and setting them in the init.