In this tutorial i'll list & explan about some very common & usefull print_xxxxx functions that are builtin into vbulletin system. those can make you life much easier when trying to customize the admincp config screens.
note that desspite the fact a detailed description & params list for all of these functions can be found inside /includes/adminfunctions.php file that bundled in your copy of vbulletin, i think having a quick quide on this can be good & can bring knowledge to those who are not familer with those functions.
so lets start:
print_table_break() parameters: can have optional 2 parameters in it:
param1 string Code to be inserted between the two tables
param2 string Width for the new table - default = '90%'
description: Prints out a closing table tag and opens another for page layout purposes. whenever you add new controls to existing admincp screen, use this function first.
code & screenshot of how this looks: not needed - just a spacer between 2 tables blocks.
print_table_header('title header') parameters: 1 required, all the rest are optional:
param1 string Title for the row
param2 integer Number of columns to span
param3 boolean Whether or not to htmlspecialchars the title
param4 string Name for <a name=""> anchor tag
param5 string Alignment for the title (center / left / right)
param6 boolean Whether or not to show the help button in the row
description: Makes a column-spanning bar with a named <A> and a title, then reinitialises the background class counter.
code & screenshot of how this looks: You must first be a
registered member to view any code.
print_input_row('title','name','value') parameters: 2 required, all the rest are optional:
param1 string Title for row
param2 string Name for input field
param3 string Value for input field
param4 boolean Whether or not to htmlspecialchars the input field value
param5 integer Size for input field
param6 integer Max length for input field
param7 string Text direction for input field
param8 mixed If specified, overrides the default CSS class for the input field
description: Prints a row containing an <input type="text" />
code & screenshot of how this looks: You must first be a
registered member to view any code.
print_yes_no_row('title','name','value') parameters: 2 required, all the rest are optional:
param1 string Title for row
param2 string Name for radio buttons
param3 string Selected button's value
param4 string Optional Javascript code to run when radio buttons are clicked - example: ' onclick="do_something()"'
description: Prints a row containing 'yes', 'no' <input type="radio" / > buttons
code & screenshot of how this looks: You must first be a
registered member to view any code.
print_cp_header() parameters: all are optional:
param1 string The page title
param2 string Javascript functions to be run on page start - for example "alert('moo'); alert('baa');"
param3 string Code to be inserted into the <head> of the page
param4 integer Width in pixels of page margins (default = 0)
param5 string HTML attributes for <body> tag - for example 'bgcolor="red" text="orange"'
description: prints admincp page header
code & screenshot of how this looks: You must first be a
registered member to view any code.
- starts admincp standart header, no screenshot needed.
Realted function:
print_cp_footer() - same, just for footer (NO params are required)
print_form_header() parameters: all are optional:
param1 string PHP script to which the form will submit (ommit file suffix)
param2 string 'do' action for target script
param3 boolean Whether or not to include an encoding type for the form (for file uploads)
param4 boolean Whether or not to add a <table> to give the form structure
param5 string Name for the form - <form name="$name" ... >
param6 string Width for the <table> - default = '90%'
param7 string Value for 'target' attribute of form
param8 boolean Whether or not to place a <br /> before the opening form tag
param9 string Form method (GET / POST)
description: prints form tags (action target) - in case you have custom script target to process this form, be sure to put it here (param1).
code & screenshot of how this looks: You must first be a
registered member to view any code.
no screenshot needed
that's it for those common functions. again there are few more out there, you can check the file for complete listing & declaration of them.
now some practical example: remember that it is handy to use vars for these controls that are built in into vbulletin. for example, if i were to add any new option for "per user" (lets assume for example called "my_field"), i would first add an extra filed under "user" table named "my_field" (via phpmyadmin for example), then would use for var name 'user[my_field]' for example: place line like:
You must first be a
registered member to view any code.
into "useradmin_edit_column1" hook.
in addition don't forget to add code that saves it using vbulletin engine: just add line like:
You must first be a
registered member to view any code.
into "userdata_start" hook.
that's it for this tutorial - hope you find it usefull enough for those who need quick start quide into admincp functions :classic: