phpBB2Refugees.com Logo
Not affiliated with or endorsed by the phpBB Group

Register •  Login 

Continue the legacy...

Welcome to all phpBB2 Refugees!Wave Smilie

This site is intended to continue support for the legacy 2.x line of the phpBB2 bulletin board package. If you are a fan of phpBB2, please, by all means register, post, and help us out by offering your suggestions. We are primarily a community and support network. Our secondary goal is to provide a phpBB2 MOD Author and Styles area.

How do I make an ACP page?


 
Search this topic... | Search MOD Writing... | Search Box
Register or Login to Post    Index » MOD Writing  Previous TopicPrint TopicNext Topic
Author Message
Acaria
Board Member



Joined: 20 Feb 2009

Posts: 238



PostPosted: Fri Jul 03, 2009 5:17 pm 
Post subject: How do I make an ACP page?

Okay, so I'm working on this online mod Sylver Cheetah asked for.

I've got everything working, except I can't figure out how to make an ACP page.

Can anyone help me out? All I really need is, like, a template to make a blank ACP page. I can probably figure it out myself from there. :3
Back to top
Dog Cow
Board Member



Joined: 18 Nov 2008

Posts: 378


flag
PostPosted: Sun Jul 05, 2009 4:28 pm 
Post subject: Re: How do I make an ACP page?

OK, here's a "skeleton" page which you need to fill in with some meat:

File: admin/admin_foo.php
(The name must start with admin_ for it to appear on the left nav bar.)

Code:

<?php
// admin_foo.php
// Does foo and bar things...
// (c) for the world

define('IN_PHPBB', 1);

if( !empty($setmodules) )
{
   $file = basename(__FILE__);
   $module['General']['Foo_Bar'] = $file;
   return;
}

//
// Let's set the root dir for phpBB
//
$phpbb_root_path = "./../";
require($phpbb_root_path . 'extension.inc');
require('./pagestart.' . $phpEx);

////////// Everything thing above this line is required!!!! ///////////



//// The rest of this is like any other phpBB page ///////
$template->set_filenames(array(
   "body" => "admin/foo_bar_body.tpl")
);

$template->assign_vars(array('FOO_BAR' => 'This is some foobar'));

$template->pparse("body");


////////// Special admin page_footer ///////////

include('./page_footer_admin.'.$phpEx);

?>

_________________
Moof!
Lincoln's Tomb, Oak Ridge Cemetery, Springfield ILMac 512K BlogMac GUI
Back to top
Ram
Board Member



Joined: 23 Dec 2008

Posts: 100
Location: Somewhere over the rainbow


flag
PostPosted: Sun Jul 05, 2009 5:32 pm 
Post subject: Re: How do I make an ACP page?

http://www.phpbb.com/kb/article/creating-a-new-admin-page/
Back to top
Acaria
Board Member



Joined: 20 Feb 2009

Posts: 238



PostPosted: Sun Jul 05, 2009 5:47 pm 
Post subject: Re: How do I make an ACP page?

Thank you both!

Now I have the Admin Page looking good. Just need to get the SQL to update. o 3o
Back to top
Acaria
Board Member



Joined: 20 Feb 2009

Posts: 238



PostPosted: Mon Jul 06, 2009 1:29 am 
Post subject: Re: How do I make an ACP page?

Okay, I'm having issues. Here's what I've got in the ACP page:

Code:

//
// Something goes here, I know it...
//
if($action == "")
{

}
//
// But what goes there? D:
//

//
// Save the changes
//
if ($action == "change")
{
$location = '<a href="'.append_sid($file.'?action=settings').'" class="nav">Submitted Settings</a>';

   //
   // Time to execute these terrible, terrible SQLs
   //

   $sql = "UPDATE ".$table_prefix."config SET config_value = '".$newguestnum."' WHERE config_name = 'guest_add' ";
   $sql = "UPDATE ".$table_prefix."config SET config_value = '".$newregnum."' WHERE config_name = 'reg_add' ";
   $sql = "UPDATE ".$table_prefix."config SET config_value = '".$newhiddennum."' WHERE config_name = 'hidden_add' ";

}
//
// Done saving it
//


And this is the TPL file:

Code:

  <table width="100%" cellspacing="2" cellpadding="2" border="0" align="center">
   <tr>
     <td align="left"><span class="nav">{LOCATION}</span></td>
   </tr>
  </table>

  <table width="99%" cellpadding="4" cellspacing="1" border="0" align="center" class="forumline">
   <tr>
     <th class="thHead" colspan="4">{L_USE_TITLE}</th>
   </tr>
<tr>
<form action="change" method="post">
  <td width="33%" class="row1" >Registered Users Added: <input type="text" name="newregnum" /></td>
  <td width="33%" class="row1" >Hidden Users Added: <input type="text" name="newhiddennum" /></td>
  <td width="33%" class="row1" >Guest Users Added: <input type="text" name="newguestnum" /></td>
<td width="100%" class="row1" ><span class="gen"><input type="hidden" name="action" value="change"><input type="submit" class="mainoption" value="Submit"></span></td>
</form>
</tr>


<br />

<br   clear="all" />


When I click the "Submit" button, nothing changes.

I know something has to go in that main body page to define those input fields, but I'm totally lost now.

What would go there?
Back to top
Dog Cow
Board Member



Joined: 18 Nov 2008

Posts: 378


flag
PostPosted: Mon Jul 06, 2009 5:10 pm 
Post subject: Re: How do I make an ACP page?

Acaria wrote:
Okay, I'm having issues.


Here's the fixed version of your page:
Code:

//
// Something goes here, I know it...
//
if($action == "")
{

}
//
// But what goes there? D:
//

//
// Save the changes
//
$action = (isset($HTTP_POST_VARS['action'])) ? $HTTP_POST_VARS['action'] : '';
$newregnum= (isset($HTTP_POST_VARS['newregnum'])) ? intval($HTTP_POST_VARS['newregnum']) : 0;
$newguestnum= (isset($HTTP_POST_VARS['newguestnum'])) ? intval($HTTP_POST_VARS['newguestnum']) : 0;
$newhiddennum= (isset($HTTP_POST_VARS['newhiddennum'])) ? intval($HTTP_POST_VARS['newhiddennum']) : 0;

if ($action == "change")
{
$location = '<a href="'.append_sid($file.'?action=settings').'" class="nav">Submitted Settings</a>';

   //
   // Time to execute these terrible, terrible SQLs
   //

   $sql = "UPDATE ".$table_prefix."config SET config_value = '".$newguestnum."' WHERE config_name = 'guest_add' ";
   $sql = "UPDATE ".$table_prefix."config SET config_value = '".$newregnum."' WHERE config_name = 'reg_add' ";
   $sql = "UPDATE ".$table_prefix."config SET config_value = '".$newhiddennum."' WHERE config_name = 'hidden_add' ";

}
//
// Done saving it
//
message_die(GENERAL_MESSAGE, 'Online users updated OK');


You will still need to add the $template lines, and include the footer.

_________________
Moof!
Lincoln's Tomb, Oak Ridge Cemetery, Springfield ILMac 512K BlogMac GUI
Back to top
Sylver Cheetah 53
Board Member



Joined: 17 Dec 2008

Posts: 426
Location: Milky Way


flag
PostPosted: Tue Jul 07, 2009 5:47 am 
Post subject: Re: How do I make an ACP page?

I think it would be easyer to just add a line in General Configuration. icon_smile.gif
_________________
Image link
My Forum || My Blog

phpBB2 forever! icon_smile.gif
Back to top
Dog Cow
Board Member



Joined: 18 Nov 2008

Posts: 378


flag
PostPosted: Tue Jul 07, 2009 3:35 pm 
Post subject: Re: How do I make an ACP page?

Especially since these values are going in the config table. That's a good point, Sylver Cheetah 53.
_________________
Moof!
Lincoln's Tomb, Oak Ridge Cemetery, Springfield ILMac 512K BlogMac GUI
Back to top
drathbun
Board Member



Joined: 24 Jul 2008

Posts: 729
Location: Texas


flag
PostPosted: Fri Aug 28, 2009 11:08 pm 
Post subject: Re: How do I make an ACP page?

Know that if you do add something to the general config, the admin config page does not do inserts only updates. That got me for the first few times I created MODs that used the phpbb_config table... icon_redface.gif

You have to insert the value manually (using SQL or some php page) before the config page will be able to manage it.

_________________
phpBBDoctor Blog
Back to top
Dog Cow
Board Member



Joined: 18 Nov 2008

Posts: 378


flag
PostPosted: Sun Aug 30, 2009 2:22 pm 
Post subject: Re: How do I make an ACP page?

Right. And the best, most user-friendly way to handle it is to check if isset($board_config['my_var_name']))

If not, then INSERT it into the table. Silently. icon_smile.gif

_________________
Moof!
Lincoln's Tomb, Oak Ridge Cemetery, Springfield ILMac 512K BlogMac GUI
Back to top
Display posts from previous:   
Register or Login to Post    Index » MOD Writing  Previous TopicPrint TopicNext Topic
Page 1 of 1 All times are GMT - 4 Hours
 
Jump to:  

Index • About • FAQ • Rules • Privacy • Search •  Register •  Login 
Not affiliated with or endorsed by the phpBB Group
Powered by phpBB2 © phpBB Group
Generated in 0.0501 seconds using 16 queries. (SQL 0.0090 Parse 0.0009 Other 0.0402)
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com Moments of Light Logo