Register Members List Search Today's Posts Mark Forums Read

Reply
 
Article Options
Create pages for the AdminCP
Dream
Join Date: Oct 2001
Posts: 2,251

Iím only happy when it rains Iím only happy when itís complicated And though I know you canít appreciate it Iím only happy when it rains You know I love it when the news is bad Why it feels so good to feel so sad Iím only happy when it rains

by Dream Dream is offline 15 Jun 2005
Rating: (2 votes - 5.00 average)

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) thread.


Basic AdminCP page code:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


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.

You can use can_administer() to check for admin permissions, 'canadminstyles' in this case:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

(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


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Creating a redirection message: example image

In this example the page will be redirected to Google in 10 seconds.

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.




Creating a table:
example

The standard table has 2 columns.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

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


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

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


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Text area example


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Yes / No radios example


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Yes / No / other radios example


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

"Yes" radio example


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Multiple radios example


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Select example


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Single checkbox example


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Password example


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Date example


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.



Other functions to use inside tables:

Description row example


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Two cell row example


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Horizontal rule row example


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Get next alternating row class (alt1/alt2)


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.



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

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Submit only

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.








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...
Attached Images
File Type: gif print_input_row.gif (1.2 KB, 810 views)
File Type: gif print_submit_row.gif (2.0 KB, 399 views)
File Type: gif print_yes_no_row.gif (1.4 KB, 503 views)
File Type: gif print_description_row.gif (2.4 KB, 635 views)
File Type: gif print_label_row.gif (1.1 KB, 585 views)
File Type: gif print_select_row.gif (1.5 KB, 388 views)
File Type: gif print_textarea_row.gif (2.4 KB, 435 views)
File Type: gif print_cp_message.gif (8.3 KB, 1105 views)
File Type: gif print_cp_message_redir.gif (5.2 KB, 882 views)
File Type: gif table_complete.gif (3.0 KB, 402 views)

Last edited by Dream; 25 Jun 2005 at 19:25..
Views: 20147
Reply With Quote
Comments
  #2  
Old 15 Jun 2005, 09:17
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Thanks,

Just 1 comment, "ignore_user_abort(true);" is not needed/wanted for most scripts.
__________________
Marco van Herwaarden
Ex vBulletin.org Coordinator
Reply With Quote
  #3  
Old 15 Jun 2005, 18:25
Dream's Avatar
Dream Dream is offline
 
Join Date: Oct 2001
Originally Posted by MarcoH64
Thanks,

Just 1 comment, "ignore_user_abort(true);" is not needed/wanted for most scripts.
what does it do?
Reply With Quote
  #4  
Old 15 Jun 2005, 18:36
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Real name: Andreas
Originally Posted by Dream
what does it do?
http://www.php.net/manual/en/functio...user-abort.php

In other words: If this is set to true the script will continue to run until it's normal end even if the user gets disconnected (network outage, hit stop in browser, etc.)
Reply With Quote
  #5  
Old 18 Jun 2005, 05:48
Ron1n Ron1n is offline
 
Join Date: Jun 2004
whats the diff between print_cp_message and print_stop_message?
Reply With Quote
  #6  
Old 18 Jun 2005, 18:41
Dream's Avatar
Dream Dream is offline
 
Join Date: Oct 2001
print_stop_message is just to get an error phrase name as parameter and call print_cp_message

from admincp/adminfunctions.php (3.5 beta 2)

Halts execution and shows a message based upon a parsed phrase

After the first parameter, this function can take any number of additional
parameters, in order to replace {1}, {2}, {3},... {n} variable place holders
within the given phrase text. The parsed phrase is then passed to print_cp_message()

Note that a redirect can be performed if CP_REDIRECT is defined with a URL

* phrasename string Name of phrase (from the Error phrase group)
* param_2 string 1st variable replacement {1}
* param_3 string 2nd variable replacement {2}
* param_n string Nth variable replacement {n}

function print_stop_message( phrasename )

these images have nothing to do with this post
Attached Images
File Type: gif print_checkbox_row.gif (886 Bytes, 168 views)
File Type: gif print_hr_row.gif (457 Bytes, 357 views)
File Type: gif print_password_row.gif (813 Bytes, 100 views)
File Type: gif print_radio_row.gif (1.2 KB, 152 views)
File Type: gif print_time_row.gif (1.9 KB, 203 views)
File Type: gif print_yes_no_other_row.gif (1.5 KB, 157 views)
File Type: gif print_yes_row.gif (911 Bytes, 127 views)
File Type: gif empty_form.gif (7.1 KB, 586 views)
File Type: gif table.gif (3.1 KB, 592 views)

Last edited by Dream; 20 Jun 2005 at 02:33.
Reply With Quote
  #7  
Old 14 Feb 2006, 15:06
Rich's Avatar
Rich Rich is offline
 
Join Date: Mar 2004
Real name: Rich
Edit: Figured it out.
__________________
Rich

Swapped 2 sites to Xenforo since vBulletin left me hanging for so long with the vB4 - PHP5 compatibility issues. Running PHP 5.5 with Xenforo with NO issues.

Last edited by Rich; 14 Feb 2006 at 16:35.
Reply With Quote
  #8  
Old 27 Feb 2006, 11:12
jim6763nva's Avatar
jim6763nva jim6763nva is offline
 
Join Date: Oct 2005
Real name: Jim
Thank you very much

Dream,

Thank you very much for taking the time to put this tutorial together! This is a huge help to getting started making custom pages for the admincp. Hopefully you will continue adding more information to this.

Kudos!

Jim
Reply With Quote
  #9  
Old 31 Mar 2006, 11:21
Antivirus's Avatar
Antivirus Antivirus is offline
 
Join Date: Sep 2004
Dream, this is a huge help, thanks! I am stumped however, on how to include 1 or more wysiwyg inputs in an admincp page. I know this is an unusual request, but for my next hack, it's required to enter content this way. Can you add this info to the tutorial please, or possibly write another tutorial dedicated to the wysiwyg?
__________________
Please feel free to PM me about custom work, installations, and upgrades!

Eclipse Records - Streetcult Street Team

Last edited by Antivirus; 31 Mar 2006 at 11:23.
Reply With Quote
  #10  
Old 31 Mar 2006, 18:40
Reven Reven is offline
 
Join Date: Aug 2005
Real name: Sean
It's great, but a lot of the links to the example images are being parsed as off-site links, such as http://attachment.php?attachmentid=whatever, instead of http://www.vbulletin.org/forum/attac...entid=whatever. Really annoying. Other than that, a great tutorial, which I will surely use at some point.
Reply With Quote
  #11  
Old 01 Apr 2006, 17:29
hangoutforums hangoutforums is offline
 
Join Date: Jan 2006
Real name: Ben
to view the examples you can just view the attachments at the bottom of dream's post.

This is a really useful tutorial, thanks
Reply With Quote
  #12  
Old 02 May 2006, 23:16
antialiasis's Avatar
antialiasis antialiasis is offline
 
Join Date: Jan 2006
Does anybody have a guide like this for making Mod CP pages? I'm a bit confused...
__________________
Featured hacks:
3.6:
NoSpam! - get rid of those spambots for good!
Import News from a Forum - have unread announcements appear at the top of every page of your forum to get members to read them!
3.5:
NoSpam! - the 3.5 version
Personal Notepad - allow your members to store private notes in their User CP
Reply With Quote
  #13  
Old 20 May 2006, 20:22
melefire's Avatar
melefire melefire is offline
 
Join Date: Dec 2005
thanks, very useful
Reply With Quote
  #14  
Old 20 May 2006, 21:07
-=Sniper=-'s Avatar
-=Sniper=- -=Sniper=- is offline
 
Join Date: May 2002
excellent, try to keep it updated
Reply With Quote
  #15  
Old 22 May 2006, 18:18
rogersnm's Avatar
rogersnm rogersnm is offline
 
Join Date: Apr 2006
Location: Cyberspace, UK
Real name: Nick Rogers
Hey can anybody answer this?

http://www.vbulletin.org/forum/showthread.php?t=116382
Reply With Quote
Reply

Similar Article
Article Author Type Replies Last Post
GTCustom Pages - Create Custom Pages With Ease Princeton vBulletin 3.5 Add-ons 160 17 Jun 2010 23:40



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Article Options

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 06:58.

Layout Options | Width: Wide Color: