Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2024-09-06 15:24:51

Adams
Plugin Author
Registered: 2024-08-30
Posts: 38

admin side menu

Can I add a menu beside admin using plugins? I tested my first plugin, and I’m able to add it to admin, but I need it at the top level, which will have many other subs menus.

Offline

#2 2024-09-06 21:43:45

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,726
Website

Re: admin side menu

Have a look at the register_tab function but define your own $area rather than one of the existing ones.


TXP Builders – finely-crafted code, design and txp

Offline

#3 2024-09-07 04:48:52

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,445
Website GitHub

Re: admin side menu

Also check out smd_tabber. I haven’t touched the code in years so it might need updating to work with later PHP and Textpattern versions, but even if the plugin doesn’t work, the principles of its operation still apply so you could steal code from it.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Online

#4 2024-09-07 13:09:35

Adams
Plugin Author
Registered: 2024-08-30
Posts: 38

Re: admin side menu

But when I do register_tab(‘Customers’, $this->event, ‘Customer management’);
doesn’t show anywhere,
But shows when I do it like this register_tab(‘Admin’, $this->event, ‘Customer management’);
or register_tab(‘Extensions’, $this->event, ‘Customer management’);

Thank you

Offline

#5 2024-09-07 14:28:20

etc
Developer
Registered: 2010-11-11
Posts: 5,186
Website GitHub

Re: admin side menu

That’s a bit cumbersome, for security reasons. You need to add privs:

  add_privs('tab.test', '1,2,3,4,5');
  add_privs('subtest', '1,2,3,4,5');
  register_tab('test', 'subtest', 'Test');

And yet to somehow define tab_test string in your plugin.

Offline

#6 2024-09-07 22:22:42

Adams
Plugin Author
Registered: 2024-08-30
Posts: 38

Re: admin side menu

That is exactly what I needed, thank you. The issue is that the define part is not working but still shows tab_test.

if (!defined(‘tab_test’)) { define(‘tab_test’, ‘Customers’);
}

Offline

#7 2024-09-07 22:37:25

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,726
Website

Re: admin side menu

If you’re talking about the name of the tab in the menu, you need to set it as a language string.

You do that in the textpack part of the plugin template. I believe this kind of top-level string has to go in the string group admin-side. At least, if you look in the standard strings here, you’ll see the names of the built-in tabs, and if you scroll up a bit, you’ll see they’re in the set called admin-side.

It’d be something like this. Leave out the other languages if you don’t need them:

$plugin['textpack'] = <<< EOT
@admin-side
@language en
tab_test => Customers
@language de
tab_test => Kunden
EOT;

TXP Builders – finely-crafted code, design and txp

Offline

#8 2024-09-07 22:47:03

Adams
Plugin Author
Registered: 2024-08-30
Posts: 38

Re: admin side menu

Before I posted the issue, I added it to en-us.ini and en.ini I didn’t see any change even after I logged out, but your answer helped me 100% as before, I updated the language, and boom, it worked. I see Customer now.

THANK YOU

Offline

Board footer

Powered by FluxBB