So you already know how to Create Custom Pages in the AdminCP for that awesome hack you're working on, but your pages are either very long and you're too lazy to hit that scroll wheel to get to the bottom, or (like myself) you love clicking on collapsible tables and making things disappear and reappear upon your command. The following tuitorial (hopefully) should help you achieve this.
First off, if you're not already familiar with Dream's tuitorial on how to Create Custom Pages in the AdminCP, please get familiar with it, as this tuitorial assumes you already know how to do everything he explains therein.
Basically what we need to do is create three new functions to handle collapsible tables on custom pages within the AdminCP:
print_claps_table_header
print_claps_submit_row
print_claps_table_footer
The above functions are almost identical to the original functions written by Jelsoft, except for the fact that the code needed to handle collapsible tables has been added.
These functions need to be written into a file which we will call "antivirus_adminfunctions.php" so we can call them from our custom AdminCP page. The first function "print_claps_table_header" is the most important, containing the bulk of the code for collapsing the table as well as the all-important $collapseid parameter which we will need to assign giving each collapsible table it's own unique tag.
PHP Code:
function print_claps_table_header($title, $collapseid = '', $colspan = 2, $htmlise = false, $align = 'center')
{
global $bgcounter, $stylevar, $vbulletin;
The second function "print_claps_submit_row" is only used if you require a submit button for your form. Almost nothing has changed other than the call to the function "print_claps_table_footer" way at the bottom...
Third, we'll need the new "print_claps_table_footer" function which closes the <tbody> tag which was opened within the "print_claps_table_header" function above...
PHP Code:
function print_claps_table_footer($colspan = 2, $rowhtml = '', $tooltip = '', $echoform = true)
{
global $tableadded, $vbulletin;
Last thing, make sure you have both "cp_collapse.gif" and "cp_collapse_collapsed.gif" residing within your CP Style directory (i.e: forumroot/cpstyles/xxx) where cpstylename is the name of the folder for your cpstyle. You probably already have the first in there by default, however you may need to make the latter image.
Now that we have our functions within the new "antivirus_adminfunctions.php" script, place this file within your forum/includes/ directory and we'll call it later in our custom AdminCP script.
Now, when creating your new page in the AdminCP, aside from all the usual bluff, you have to require our new functions for the back-end, like this:
Now, everything else you would normally do is the same, except for the tables you're printing to the browser which you want to collapse, and in this case, you would use the following:
instead of function "print_table_header", use the new "print_claps_table_header" but DON'T FORGET to assign the new parameter $collapseid to a unique value (such as 'foo' for this table, like so:
instead of function "print_submit_row", use the new "print_claps_submit_row" function (it's got no new parameters).
and instead of function "print_table_footer", use the new "print_claps_table_footer" function (it's got no new parameters).
Now, your tables which have used the new functions should be able to collapse as long as you use a unique $collapseid for each table group. You can also make more than one table collapse individually on the same page so long as each table you define in your script has a unique $collapseid
Thanks to SirAdrian, alan@cit and Paul M for helping me figure this out \m/