I developed a plugin that displays several records from DB for the user. It is working fine, but now I'm trying to implement check-boxes and Actions menu like Joomla 4 has on the Users-Manage screen. I used very naive approach: populated the same html for the dropdown menu, but it did not work (i.e. mouse click does not open the menu). I guess it is because header on my plugin page does not have:
<script src="/media/system/js/joomla-toolbar-button.min.js?6eb267679d65e41cc9fc4de7a56cf06e3b966e5b" type="module"></script>
Could you show example or recommend how to implement the button with dropdown menu in custom plugin in Joomla 4.4.5?
Edit: here is code that renders checkboxes and the Actions button:
<?php
\defined('_JEXEC') or die;
use Joomla\CMS\Factory;
print "<form action=\"/my-account/my-orders\" method=\"post\" name=\"adminForm\" id=\"adminForm\">\n";
print "<div class=\"page-header\"><h2 itemprop=\"name\">Orders History</h2></div>\n";
print "<br><div class=\"btn-toolbar d-flex\" role=\"toolbar\" id=\"toolbar\">\n";
print " <input class=\"button-status-group btn btn-action dropdown-toggle\" type=\"submit\" value=\"Actions\" />\n";
print "</div><br>\n";
print "<input type=\"hidden\" name=\"task\" value=\"\" />\n";
print "<input type=\"hidden\" name=\"boxchecked\" value=\"0\">\n";
print "<table class=\"filecabinet table-sortable\" id=\"licstbl\" border=\"0\" width =\"100%\" bordercolor=\"#000000\">\n";
print " <thead>\n";
print " <tr>\n";
print " <th> <input class=\"form-check-input\" autocomplete=\"off\" type=\"checkbox\" name=\"checkall-toggle\" value=\"\" title=\"\" onclick=\"Joomla.checkAll(this)\" /></th>\n";
print " <th>Date</th>\n";
print " </tr>\n";
print " </thead><tbody>\n";
$data = $this->rows;
for ($i=0, $n=(empty($data) ? 0 : count($data)); $i < $n; $i++)
{
$row = &$data[$i];
print " <tr class=\"row" . $i . "\">\n";
print " <td> <input class=\"form-check-input\" autocomplete=\"off\" type=\"checkbox\" id=\"cb0\" name=\"cid[]\" value=" . GetDisplaySpecial($row->license) . " onclick=\"Joomla.isChecked(this.checked);\" /> </td>\n";
print " <td>" . $row->date . "</td>\n";
print " </tr>\n";
}
print " </tbody>\n</table>\n";
print "</form>\n";
print "<div class=\"statusPanel\" />\n";
?>
The code above has 2 issues:
- when all checkboxes are unselected the Actions button is not disabled;
- Actions button does not render the dropdown menu.