Jump to content

Table in plugin settings page


Runar

Recommended Posts

Posted

I tried to use the Table helper (\IPS\Helpers\Table) in the settings page for plugin, but I can’t find a way to combine it with the way settings.php work (where everything is a form?).

Is there a better way to build and display a table than lots of $form->addHtml()?

Posted
14 minutes ago, Adriano Faria said:

Why would you need to display a table on settings?

Let’s say my plugin allows admins to create badges (with custom text and color) that may be added to a user and displayed below their username. I need a way to display all these badges in the plugin settings page, for admins to manage them.

I have made it work, but wanted simply to ask if there was a better way than building the table manually.

Posted

If you have a truly advanced page you need to create, you might be better served by adding an entirely new page/tab somewhere in the AdminCP through a hook. i.e. hook into the Members > Profile page to add a new tab, and show your table on this new tab (which is not restricted in the same way the generic settings.php is designed). Just an alternate thought.

Posted
3 hours ago, bfarber said:

If you have a truly advanced page you need to create, you might be better served by adding an entirely new page/tab somewhere in the AdminCP through a hook. i.e. hook into the Members > Profile page to add a new tab, and show your table on this new tab (which is not restricted in the same way the generic settings.php is designed). Just an alternate thought.

Thank you for your reply! I will look into your suggestion.

What would be the best way/practice to redirect admins to this new page? Inform them when they download the plugin, or is there a way to redirect to the new page when they click the edit plugin button?

Posted
18 minutes ago, Runar said:

Thank you for your reply! I will look into your suggestion.

What would be the best way/practice to redirect admins to this new page? Inform them when they download the plugin, or is there a way to redirect to the new page when they click the edit plugin button?

Probably not the best approach, but you could still use the settings.php file and include a redirect 🙂

//<?php

\IPS\Output::i()->redirect( '...');

 

Posted

Great suggestion, @Daniel F 😄

I’m attempting to hook into the Members > Profile page as suggested by @bfarber, but I’m stuck trying to add a new tab. The parent function sets $this->tabs to a blank array, resetting my custom tabs. I’m also unable to add the tab after the parent function runs, as the parent function doesn’t return anything, but outputs the content directly.

Also, is it possible to add a completely new admin page with plugins? Which class would I need to extend?

Posted

You can add a link to the menu by overriding \IPS\Dispatcher\Admin::buildMenu(), and then you can add the page controller code by hooking on to pretty much any admin controller that you feel is appropriate. So you might link to app=core&module=membersettings&controller=profiles&do=YOURNEWMETHOD, then hook on to \IPS\core\modules\admin\membersettings\profiles to add the new method.

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...