Dream
15 Jun 2005, 08:19
I was going to spend some time researching this, so I figured I could help some people save time by writing it down.
This is not a full tutorial, more of a kick-off, and its aimed at developers.
How to add a link to the AdminCP left side navigation:
Please refer to KirbyDE's [How to] Add entries to AdminCP Navigation Menu (in 3.5) (http://www.vbulletin.org/forum/showthread.php?t=82698) thread.
Basic AdminCP page code:
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
This is the basic code. Its already password protected, so if you create a myscript.php with that code and upload to the "admincp" folder, you can call it from a browser and it will ask for the admin password.
You can use "ignore_user_abort(true);" as described in this post (http://www.vbulletin.org/forum/showpost.php?p=667189&postcount=4).
You can use can_administer() to check for admin permissions, 'canadminstyles' in this case:
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
(gonna add the permissions list here)
(to-do: describe print_cp_header() optional parameters title, onload, headinsert, marginwidth and bodyattributes defined in adminfunctions.php)
You can put anything you like inside the html page. vBulletin has a good number of standard functions that builds the html code for you. These functions can be found in "admincp/adminfunctions.php" (thanks Zero Tolerance for pointing it out). Im going to describe them in this how-to as time lets me.
Creating a message box with a "go back" link: example image (http://www.vbulletin.org/forum/attachment.php?attachmentid=27194)
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Creating a redirection message: example image (http://www.vbulletin.org/forum/attachment.php?attachmentid=27195)
In this example the page will be redirected to Google in 10 seconds.
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Creating a table: example (http://www.vbulletin.org/forum/attachment.php?attachmentid=27302)
The standard table has 2 columns.
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
An empty "print_table_footer" adds a "</form>" after closing the table.
Function "print_table_footer" parameters (from adminfunctions.php)
Prints a closing table tag and closes the form tag if it is open
* colspan integer Column span of the optional table row to be printed
* rowhtml string If specified, creates an additional table row with this code as its contents
* tooltip string Tooltip for optional table row
* echoform boolean Whether or not to close the <form> tag
function print_table_footer( colspan, rowhtml, tooltip, echoform )
Creating a form:
vBulletin has standard functions to build forms. You call "print_form_header()", which opens the form and table tags, call a few functions to build the form inputs, and then close the form with a submit button row.
An empty form example (http://www.vbulletin.org/forum/attachment.php?attachmentid=27301)
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Function "print_form_header" parameters (from adminfunctions.php)
Prints the standard form header, setting target script and action to perform
* phpscript string PHP script to which the form will submit (ommit file suffix)
* do string 'do' action for target script
* uploadform boolean Whether or not to include an encoding type for the form (for file uploads)
* addtable boolean Whether or not to add a <table> to give the form structure
* name string Name for the form - <form name="$name" ... >
* width string Width for the <table> - default = '90%'
* target string Value for 'target' attribute of form
* echobr boolean Whether or not to place a <br /> before the opening form tag
* method string Form method (GET / POST)
function print_form_header( phpscript, do, uploadform, addtable, name, width, target, echobr, method )
Input functions for a table:
Here I'll use common examples, but each function has a set of parameters that should be read in "admincp/adminfunctions.php" if you are going to use them.
Text input example (http://www.vbulletin.org/forum/attachment.php?attachmentid=27142)
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Text area example (http://attachment.php?attachmentid=27190)
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Yes / No radios example (http://www.vbulletin.org/forum/attachment.php?attachmentid=27144)
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Yes / No / other radios example (http://attachment.php?attachmentid=27275)
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
"Yes" radio example (http://attachment.php?attachmentid=27276)
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Multiple radios example (http://attachment.php?attachmentid=27273)
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Select example (http://attachment.php?attachmentid=27189)
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Single checkbox example (http://attachment.php?attachmentid=27270)
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Password example (http://attachment.php?attachmentid=27272)
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Date example (http://attachment.php?attachmentid=27274)
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Other functions to use inside tables:
Description row example (http://www.vbulletin.org/forum/attachment.php?attachmentid=27187)
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Two cell row example (http://www.vbulletin.org/forum/attachment.php?attachmentid=27188)
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Horizontal rule row example (http://www.vbulletin.org/forum/attachment.php?attachmentid=27271)
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Get next alternating row class (alt1/alt2)
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Submit / Reset buttons row:
This closes the form and table tags, so you don't have to use "print_table_footer" with it.
Submit and reset buttons example (http://attachment.php?attachmentid=27143)
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Submit only
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
seems I underestimated the ammount of work. should I bother finishing this? gotta work on this more later anyway.
trying to keep the second post for myself... nope automerges
not sure the best formatting... playing around...
This is not a full tutorial, more of a kick-off, and its aimed at developers.
How to add a link to the AdminCP left side navigation:
Please refer to KirbyDE's [How to] Add entries to AdminCP Navigation Menu (in 3.5) (http://www.vbulletin.org/forum/showthread.php?t=82698) thread.
Basic AdminCP page code:
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
This is the basic code. Its already password protected, so if you create a myscript.php with that code and upload to the "admincp" folder, you can call it from a browser and it will ask for the admin password.
You can use "ignore_user_abort(true);" as described in this post (http://www.vbulletin.org/forum/showpost.php?p=667189&postcount=4).
You can use can_administer() to check for admin permissions, 'canadminstyles' in this case:
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
(gonna add the permissions list here)
(to-do: describe print_cp_header() optional parameters title, onload, headinsert, marginwidth and bodyattributes defined in adminfunctions.php)
You can put anything you like inside the html page. vBulletin has a good number of standard functions that builds the html code for you. These functions can be found in "admincp/adminfunctions.php" (thanks Zero Tolerance for pointing it out). Im going to describe them in this how-to as time lets me.
Creating a message box with a "go back" link: example image (http://www.vbulletin.org/forum/attachment.php?attachmentid=27194)
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Creating a redirection message: example image (http://www.vbulletin.org/forum/attachment.php?attachmentid=27195)
In this example the page will be redirected to Google in 10 seconds.
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Creating a table: example (http://www.vbulletin.org/forum/attachment.php?attachmentid=27302)
The standard table has 2 columns.
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
An empty "print_table_footer" adds a "</form>" after closing the table.
Function "print_table_footer" parameters (from adminfunctions.php)
Prints a closing table tag and closes the form tag if it is open
* colspan integer Column span of the optional table row to be printed
* rowhtml string If specified, creates an additional table row with this code as its contents
* tooltip string Tooltip for optional table row
* echoform boolean Whether or not to close the <form> tag
function print_table_footer( colspan, rowhtml, tooltip, echoform )
Creating a form:
vBulletin has standard functions to build forms. You call "print_form_header()", which opens the form and table tags, call a few functions to build the form inputs, and then close the form with a submit button row.
An empty form example (http://www.vbulletin.org/forum/attachment.php?attachmentid=27301)
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Function "print_form_header" parameters (from adminfunctions.php)
Prints the standard form header, setting target script and action to perform
* phpscript string PHP script to which the form will submit (ommit file suffix)
* do string 'do' action for target script
* uploadform boolean Whether or not to include an encoding type for the form (for file uploads)
* addtable boolean Whether or not to add a <table> to give the form structure
* name string Name for the form - <form name="$name" ... >
* width string Width for the <table> - default = '90%'
* target string Value for 'target' attribute of form
* echobr boolean Whether or not to place a <br /> before the opening form tag
* method string Form method (GET / POST)
function print_form_header( phpscript, do, uploadform, addtable, name, width, target, echobr, method )
Input functions for a table:
Here I'll use common examples, but each function has a set of parameters that should be read in "admincp/adminfunctions.php" if you are going to use them.
Text input example (http://www.vbulletin.org/forum/attachment.php?attachmentid=27142)
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Text area example (http://attachment.php?attachmentid=27190)
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Yes / No radios example (http://www.vbulletin.org/forum/attachment.php?attachmentid=27144)
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Yes / No / other radios example (http://attachment.php?attachmentid=27275)
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
"Yes" radio example (http://attachment.php?attachmentid=27276)
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Multiple radios example (http://attachment.php?attachmentid=27273)
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Select example (http://attachment.php?attachmentid=27189)
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Single checkbox example (http://attachment.php?attachmentid=27270)
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Password example (http://attachment.php?attachmentid=27272)
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Date example (http://attachment.php?attachmentid=27274)
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Other functions to use inside tables:
Description row example (http://www.vbulletin.org/forum/attachment.php?attachmentid=27187)
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Two cell row example (http://www.vbulletin.org/forum/attachment.php?attachmentid=27188)
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Horizontal rule row example (http://www.vbulletin.org/forum/attachment.php?attachmentid=27271)
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Get next alternating row class (alt1/alt2)
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Submit / Reset buttons row:
This closes the form and table tags, so you don't have to use "print_table_footer" with it.
Submit and reset buttons example (http://attachment.php?attachmentid=27143)
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Submit only
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
seems I underestimated the ammount of work. should I bother finishing this? gotta work on this more later anyway.
trying to keep the second post for myself... nope automerges
not sure the best formatting... playing around...