Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 3 Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Create pages for the AdminCP
Dream's Avatar
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

Show Printable Version Email this Page Subscription
Dream Dream is offline 06-14-2005, 10:00 PM

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:

PHP Code:
<?php
// ######################## SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
@
set_time_limit(0);
 
// #################### PRE-CACHE TEMPLATES AND DATA ######################
$phrasegroups = array('style');
$specialtemplates = array('products');
 
// ########################## REQUIRE BACK-END ############################
require_once('./global.php');
require_once(
DIR '/includes/adminfunctions_template.php');
 
print_cp_header();
 
 
 
 
 
 
 
 
 
print_cp_footer();
?>

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:

PHP Code:
 // ######################## CHECK ADMIN PERMISSIONS #######################
if (!can_administer('canadminstyles'))
{
    
print_cp_no_permission();

(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

PHP Code:
print_cp_message('This is a control panel message box.'); 
Creating a redirection message: example image

In this example the page will be redirected to Google in 10 seconds.
PHP Code:
print_cp_message('This is a control panel message box.''http://google.com'
10); 



Creating a table:
example

The standard table has 2 columns.

PHP Code:
print_table_start();
 
print_table_header("Table Title");
 
 echo 
'<tr><td class="alt1" colspan="2">table content</td></tr>';
 
 
print_table_footer(2''''0); 
An empty "print_table_footer" adds a "</form>" after closing the table.


Function "print_table_footer" parameters (from adminfunctions.php)

Quote:
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

PHP Code:
print_form_header('myscript');
print_table_header('Empty Form');

# table rows

print_submit_row("Submit!"); 
Function "print_form_header" parameters (from adminfunctions.php)

Quote:
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

PHP Code:
print_input_row('Type your name''inputname'); 
Text area example

PHP Code:
print_textarea_row('This is a textarea row''inputname'); 
Yes / No radios example

PHP Code:
print_yes_no_row('Should I finish this how-to''radioname'); 
Yes / No / other radios example

PHP Code:
print_yes_no_other_row('What you think''inputname''maybe'); 
"Yes" radio example

PHP Code:
print_yes_row('Want it''inputname''nah'0); 
Multiple radios example

PHP Code:
print_radio_row('This is a radio row''inputname', array( 'ya' => 'ya'
'nah' => 'nah' )); 
Select example

PHP Code:
print_select_row('This is a select row''inputname', array(
 
'value1' => 'option1''value2' => 'option2')); 
Single checkbox example

PHP Code:
print_checkbox_row('This is a checkbox row''inputname'); 
Password example

PHP Code:
print_password_row('This is a password row''inputname'); 
Date example

PHP Code:
print_time_row('Date'); 


Other functions to use inside tables:

Description row example

PHP Code:
print_description_row('This is a description row'02'thead'); 
Two cell row example

PHP Code:
print_label_row('Left cell content''Right cell content'); 
Horizontal rule row example

PHP Code:
print_hr_row(); 
Get next alternating row class (alt1/alt2)

PHP Code:
fetch_row_bgclass(); 


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
PHP Code:
print_submit_row("Submit!"); 
Submit only
PHP Code:
print_submit_row("Submit!"0); 







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, 0 views)
File Type: gif print_submit_row.gif (2.0 KB, 0 views)
File Type: gif print_yes_no_row.gif (1.4 KB, 0 views)
File Type: gif print_description_row.gif (2.4 KB, 0 views)
File Type: gif print_label_row.gif (1.1 KB, 0 views)
File Type: gif print_select_row.gif (1.5 KB, 0 views)
File Type: gif print_textarea_row.gif (2.4 KB, 0 views)
File Type: gif print_cp_message.gif (8.3 KB, 0 views)
File Type: gif print_cp_message_redir.gif (5.2 KB, 0 views)
File Type: gif table_complete.gif (3.0 KB, 0 views)
Reply With Quote
  #22  
Old 06-26-2007, 12:03 PM
Naxon Naxon is offline
 
Join Date: Oct 2006
Location: Israel
Posts: 122
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ok, Thank's, But how can I save it into the DB and use it on the tamplates? (Like FORUMDISPLAY).
Reply With Quote
  #23  
Old 06-27-2007, 01:54 PM
cassis2k cassis2k is offline
 
Join Date: Mar 2005
Location: Paris
Posts: 28
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

excellent, thank's
Reply With Quote
  #24  
Old 07-20-2007, 04:14 AM
Mythotical Mythotical is offline
 
Join Date: Jun 2004
Location: Booneville, AR, USA
Posts: 1,428
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is there a way to add an image to the right of an input row some how?

Here is my input row:
PHP Code:
print_input_row("Image""image"$sponsors['image'], $htmlise true$size 35$maxlength 100$direction ''$inputclass false); 
This is the code I need to show next to that:
PHP Code:
echo '<tr><td><img src="/sponsors/' $sponsors['image'] . '"></td></tr>'
Thanks
Steve
Reply With Quote
  #25  
Old 08-24-2007, 11:17 PM
aggiefan aggiefan is offline
 
Join Date: Apr 2005
Posts: 169
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

is there a way to restrict a dropdown to one part of the "print_cells_row"?

I'm looking to create a row with a few dropdowns in it...I can't seem to find anywhere where it says you can do that. Looks like you can only stack dropdowns on rows.
Reply With Quote
  #26  
Old 10-24-2007, 02:17 PM
foxfirediego foxfirediego is offline
 
Join Date: Aug 2005
Location: Brazil
Posts: 63
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

first thank you very much for this article.. really handy!!

and some of the link attachment images are broken, check out wich one:
Text area -> attachment.php/?attachmentid=27190
https://vborg.vbsupport.ru/attachmen...chmentid=27190

Yes / No / other radios -> attachment.php/?attachmentid=27275
https://vborg.vbsupport.ru/attachmen...chmentid=27275

"Yes" radio -> attachment.php/?attachmentid=27276
https://vborg.vbsupport.ru/attachmen...chmentid=27276

Multiple radios -> attachment.php/?attachmentid=27273
https://vborg.vbsupport.ru/attachmen...chmentid=27273

Select -> attachment.php/?attachmentid=27189
https://vborg.vbsupport.ru/attachmen...chmentid=27189

Single checkbox -> attachment.php/?attachmentid=27270
https://vborg.vbsupport.ru/attachmen...chmentid=27270

Password -> attachment.php/?attachmentid=27272
https://vborg.vbsupport.ru/attachmen...chmentid=27272

Date -> attachment.php/?attachmentid=27274
https://vborg.vbsupport.ru/attachmen...chmentid=27274

Submit and reset buttons -> attachment.php/?attachmentid=27143
https://vborg.vbsupport.ru/attachmen...chmentid=27143
Reply With Quote
  #27  
Old 10-25-2007, 03:05 AM
Dream's Avatar
Dream Dream is offline
 
Join Date: Oct 2001
Posts: 2,251
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks, this article is so old I can't remember how to do pages for the admincp anymore :P

j/k, but I have no intention of updating the images. they should be in this thread somewhere.
Reply With Quote
  #28  
Old 10-25-2007, 11:09 AM
foxfirediego foxfirediego is offline
 
Join Date: Aug 2005
Location: Brazil
Posts: 63
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok, sorry for that...
also, just for those that wonder, here is the code for hidden fields:
PHP Code:
construct_hidden_code('hiddeninputname'$variable); 
Reply With Quote
  #29  
Old 11-17-2007, 10:14 AM
Dream's Avatar
Dream Dream is offline
 
Join Date: Oct 2001
Posts: 2,251
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No problem, glad it was of help.

Anyone can take this article and redo it, add more info and repost it if they want. I won't be updating it.
Reply With Quote
  #30  
Old 11-17-2007, 10:27 AM
WhaLberg's Avatar
WhaLberg WhaLberg is offline
 
Join Date: Nov 2006
Location: Dersaadet
Posts: 569
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
PHP Code:
print_description_row('This is a description row'02'thead'); 
Just an additional note, you can also use this as:
PHP Code:
print_description_row('phrase'12optiontitle); 
Reply With Quote
  #31  
Old 12-04-2007, 08:27 AM
vuiveclub vuiveclub is offline
 
Join Date: Dec 2006
Posts: 78
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Where will the rows INSERT to?
Reply With Quote
Reply


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

Forum Jump


All times are GMT. The time now is 01:34 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05261 seconds
  • Memory Usage 2,407KB
  • Queries Executed 26 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (27)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (11)post_thanks_box
  • (2)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_attachment
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete