Need help creating ACP module for my Mod

Discussion forum for MOD Writers regarding MOD Development.
User avatar
austin881
Registered User
Posts: 284
Joined: Wed Jan 30, 2008 9:58 pm
Location: Boise, Idaho, USA
Name: Austin Maddox
Contact:

Need help creating ACP module for my Mod

Post by austin881 » Fri Nov 20, 2009 8:30 pm

How does a mod writer create ACP control for a mod?

All I want is some simple radio buttons to turn things on and off. I'm working on the ModernDignity Flash Animated Cumulus Tag Cloud and want to expand its functionality by converting this code to an ACP module instead:

Code: Select all

/*** Cumulus Cloud Config section ********************/
// variables passed to template
$cloud_width = 500;					// width of flash stage
$cloud_height = 300;				// height of flash stage
$cloud_bgcolor = "111111";			// background color of flash stage (without leading '#')
$cloud_global_color = "ffffff";		// global tag color
$cloud_global_color2 = "12A2EA";	// global tag color for less important tags. creates a gradient of the two colors
$cloud_global_hi_color = "ffff00";	// global tag mouseover highlight color
$cloud_distr = "true";				// distribute tags evenly over the surface of the sphere (true|false)
$cloud_speed = 100;					// rotation speed of sphere. 25 and 500 range works best
$cloud_trans = false;				// background transparency enabled (true|false)
$cloud_xml = false;					// use XML file for input. look in the 'contrib' folder for this file and instructions how to use an XML file for input.
// variables used locally in this file
$cloud_max_words = 200;				// maximum num of tags to show in cloud
$cloud_font_size_floor = 4;			// smallest font size (em)
$cloud_font_size_ceiling = 24;		// largest font size (em)
$cloud_counts = true;				// show tag counts next to the tag? (true|false)
/*** Cumulus Cloud Config section *********************/
I've read the wikis on creating modules and adding modules and they just plain don't work.

I've also tried mirroring the acp_board module because the modes like "settings" and "features" seem to be just simple on|off radio buttons. I created these 4 files:

includes/acp/acp_cumulus_cloud.php
includes/acp/info/acp_cumulus_cloud.php
adm/style/acp_cumulus_cloud.html
language/en/mods/info_acp_cumulus_cloud.php

Then attempted to add the modules in the ACP > System > Module Management but I add them and they don't show up under the .MODS tab. I'm at a loss.

Can someone help get me started?
Available for paid phpBB help! PM me.

My Extensions/MODS: 475 Narius Categorized Smilies for phpBB3, Simplified & Compacted All-Members page, Flash Animated Cumulus Tag Cloud, "Hello" Name Tag of Newest User, AWS S3
phpBB portfolio: chevy truck forum, chevy astro van forum

User avatar
imkingdavid
Former Team Member
Posts: 2667
Joined: Sun Jul 26, 2009 7:59 pm
Location: EST
Name: David King

Re: Need help creating ACP module for my Mod

Post by imkingdavid » Fri Nov 20, 2009 8:36 pm

Here's a stupid question, but did you make sure to click "enable" after you added the modules to the .MODS tab?
Don't forget to smile today. :)
Please do NOT contact for support via PM or email.
Remember, the enemy's gate is down.

User avatar
austin881
Registered User
Posts: 284
Joined: Wed Jan 30, 2008 9:58 pm
Location: Boise, Idaho, USA
Name: Austin Maddox
Contact:

Re: Need help creating ACP module for my Mod

Post by austin881 » Fri Nov 20, 2009 8:42 pm

bzzt...stupid question, try again. :lol:

yes i did enable it.
Last edited by austin881 on Wed Dec 02, 2009 7:06 pm, edited 1 time in total.
Available for paid phpBB help! PM me.

My Extensions/MODS: 475 Narius Categorized Smilies for phpBB3, Simplified & Compacted All-Members page, Flash Animated Cumulus Tag Cloud, "Hello" Name Tag of Newest User, AWS S3
phpBB portfolio: chevy truck forum, chevy astro van forum

User avatar
austin881
Registered User
Posts: 284
Joined: Wed Jan 30, 2008 9:58 pm
Location: Boise, Idaho, USA
Name: Austin Maddox
Contact:

Re: Need help creating ACP module for my Mod

Post by austin881 » Fri Nov 20, 2009 9:02 pm

Okay I got the .MODS tab to show up now and I have a page. Success for my previous issue. Now I need to code the backend.
Last edited by austin881 on Wed Dec 02, 2009 7:19 pm, edited 2 times in total.
Available for paid phpBB help! PM me.

My Extensions/MODS: 475 Narius Categorized Smilies for phpBB3, Simplified & Compacted All-Members page, Flash Animated Cumulus Tag Cloud, "Hello" Name Tag of Newest User, AWS S3
phpBB portfolio: chevy truck forum, chevy astro van forum

User avatar
austin881
Registered User
Posts: 284
Joined: Wed Jan 30, 2008 9:58 pm
Location: Boise, Idaho, USA
Name: Austin Maddox
Contact:

Re: Need help creating ACP module for my Mod

Post by austin881 » Mon Nov 23, 2009 3:33 am

Hey look at me go, I've got a page now. Unfortunately the only part I have done is the HTML file (adm/style/acp_cloud.html)
Image

There is no coding behind this page. I'm not sure how to do it. Can someone help me with the acp files? This is what I have so far...

root/includes/acp/acp_cloud.php

Code: Select all

<?php

/*
root/includes/acp/acp_cloud.php
*/

class acp_cloud
{
   var $u_action;
//   var $new_config;
   
	function main($id, $mode)
	{
	global $db, $user, $auth, $template;
	global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;

	$this->page_title = 'ACP_CLOUD';
	$this->tpl_name = 'acp_cloud';

   }
}

?>
root/includes/acp/info/acp_cloud.php

Code: Select all

<?php

/*
root/includes/acp/info/acp_cloud.php
*/

/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
	exit;
}

class acp_cloud_info
{
    function module()
    {
        return array(
            'filename'	=> 'acp_cloud',
            'title'		=> 'ACP_CLOUD',
            'version'	=> '1.2.3',
            'modes'		=> array(
            	'index'		=> array('title' => 'ACP_CLOUD_INDEX_TITLE', 'auth' => 'acl_a_cloud_auth', 'cat' => array('ACP_CLOUD')),
            ),
        );
    }

    function install()
    {
    }

    function uninstall()
    {
    }
}

?>
Available for paid phpBB help! PM me.

My Extensions/MODS: 475 Narius Categorized Smilies for phpBB3, Simplified & Compacted All-Members page, Flash Animated Cumulus Tag Cloud, "Hello" Name Tag of Newest User, AWS S3
phpBB portfolio: chevy truck forum, chevy astro van forum

User avatar
austin881
Registered User
Posts: 284
Joined: Wed Jan 30, 2008 9:58 pm
Location: Boise, Idaho, USA
Name: Austin Maddox
Contact:

Re: Need help creating ACP module for my Mod

Post by austin881 » Thu Dec 03, 2009 8:39 pm

Anybody at all? Is this microphone on? Echo echo echo...
Available for paid phpBB help! PM me.

My Extensions/MODS: 475 Narius Categorized Smilies for phpBB3, Simplified & Compacted All-Members page, Flash Animated Cumulus Tag Cloud, "Hello" Name Tag of Newest User, AWS S3
phpBB portfolio: chevy truck forum, chevy astro van forum

User avatar
mjimeyg
Registered User
Posts: 840
Joined: Sat Aug 29, 2009 7:38 pm
Location: London

Re: Need help creating ACP module for my Mod

Post by mjimeyg » Thu Dec 03, 2009 9:00 pm

Best way to learn this one is by opening another acp function file and examining it, here's a simple one for a Google Earth mod I made, this is just the code for the main function:

Code: Select all

global $config, $db, $user, $auth, $template, $cache;
		global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix, $file_uploads;

		// Add the additional language file.
		$user->add_lang('mods/earthmapper');
		
		// Set the template details.
		$this->tpl_name = 'acp_earthmapper';
		$this->page_title = 'ACP_EARTHMAPPER';
		
		// Retrieve the action and submit values.
		$action		= request_var('action', '');

		$submit		= isset($_POST['submit']) ? true : false;

		// Set the form name and add the form key.
		$form_name = 'acp_earthmapper';
		add_form_key($form_name);
		
		
		// Process the submit action.
		if($submit)
		{
			$google_maps_key	= request_var('google_maps_key', '');
			$kml_path 			= request_var('kml_path', '');
			$icon_path			= request_var('icon_path', '');
			$placemark_text		= request_var('placemark_text', '');
			
			set_config('earthmapper_google_maps_key', $google_maps_key, true);
			set_config('earthmapper_kml', $kml_path, true);
			set_config('earthmapper_icon_path', $icon_path, true);
			set_config('earthmapper_placemark_text', $placemark_text, true);
			
			trigger_error($user->lang['ACP_EM_OPTIONS_SAVED'] . adm_back_link($this->u_action));
		}
				
		$template->assign_vars(array(
			'GOOGLE_MAPS_KEY'			=> $config['earthmapper_google_maps_key'],
			'KML_PATH'					=> $config['earthmapper_kml'],
			'ICON_PATH'					=> $config['earthmapper_icon_path'],
			'PLACEMARK_TEXT'			=> $config['earthmapper_placemark_text'],
			'U_ACTION'					=> $this->u_action,
		));
	}
The bit to note is the "if($submit)" block.

When you click the submit button on your ACP page, this is the code that gets executed. So you begin retrieving your form values with the request_var function. You then process them however you need (storing them in files or databases).

Sometimes you might need functionality that shouldn't run if the submit button isn't clicked. So you can append an "else" block.

But you can generally assign the template variables to be displayed after the "if($submit)" block.

Remember, all of this goes in the "function main($id, $mode)" function.

Hope this helps.
Questions answered via forums only, no pms or emails. Thank you.

ConSof Alternate Login for phpBB

Image Image

User avatar
austin881
Registered User
Posts: 284
Joined: Wed Jan 30, 2008 9:58 pm
Location: Boise, Idaho, USA
Name: Austin Maddox
Contact:

Re: Need help creating ACP module for my Mod

Post by austin881 » Fri Dec 04, 2009 6:12 pm

Thank you so much mjimeyg! After looking at your code (and several other mods that have ACP modules) I've been able to successfully model mine after them and it works!

So far I've got the On|Off boolean codes all finished. They work perfectly. :mrgreen:

Now I want to teach myself how to properly code the text fields so that admins can choose a selection of color, width, size, etc. What would be even better is if I could reuse the phpbb Web-safe colour swatch in this mod so the admins can just point and click the colors they want.

Anyone care to offer advice on how to do that?
Available for paid phpBB help! PM me.

My Extensions/MODS: 475 Narius Categorized Smilies for phpBB3, Simplified & Compacted All-Members page, Flash Animated Cumulus Tag Cloud, "Hello" Name Tag of Newest User, AWS S3
phpBB portfolio: chevy truck forum, chevy astro van forum

mtrs
Registered User
Posts: 2049
Joined: Sat Sep 22, 2007 2:39 pm

Re: Need help creating ACP module for my Mod

Post by mtrs » Sun Dec 06, 2009 10:26 pm

austin881 wrote:Now I want to teach myself how to properly code the text fields so that admins can choose a selection of color, width, size, etc. What would be even better is if I could reuse the phpbb Web-safe colour swatch in this mod so the admins can just point and click the colors they want.

Anyone care to offer advice on how to do that?
Take a look at Username color change MOD, I used phpBB colour swatch at ACP user overview.
I abandoned all of my mods.

User avatar
austin881
Registered User
Posts: 284
Joined: Wed Jan 30, 2008 9:58 pm
Location: Boise, Idaho, USA
Name: Austin Maddox
Contact:

Re: Need help creating ACP module for my Mod

Post by austin881 » Mon Dec 07, 2009 5:16 pm

Thank you mtrs! That was most helpful. I've created a "[ Web-safe colour swatch ]" link next to each color field. Very cool!


Now for my next task, I'd like to create a drop-down menu in my ACP module for selecting between 3 "modes". I'll start looking digging around through code to see if there is another module I can mirror but in the meantime feel free to chime in if you know a way to do this.
Available for paid phpBB help! PM me.

My Extensions/MODS: 475 Narius Categorized Smilies for phpBB3, Simplified & Compacted All-Members page, Flash Animated Cumulus Tag Cloud, "Hello" Name Tag of Newest User, AWS S3
phpBB portfolio: chevy truck forum, chevy astro van forum

mtrs
Registered User
Posts: 2049
Joined: Sat Sep 22, 2007 2:39 pm

Re: Need help creating ACP module for my Mod

Post by mtrs » Mon Dec 07, 2009 9:06 pm

If it is only for 3 modes, you may prefer radio buttons. Take a look at Duplicate user IPs mod, it uses a three mode radio buttons at ACP.
I abandoned all of my mods.

User avatar
austin881
Registered User
Posts: 284
Joined: Wed Jan 30, 2008 9:58 pm
Location: Boise, Idaho, USA
Name: Austin Maddox
Contact:

Re: Need help creating ACP module for my Mod

Post by austin881 » Mon Dec 07, 2009 9:15 pm

Thanks but too late! I've already figured out how to do a drop-down. I think about ready to package this thing up and release it.
Available for paid phpBB help! PM me.

My Extensions/MODS: 475 Narius Categorized Smilies for phpBB3, Simplified & Compacted All-Members page, Flash Animated Cumulus Tag Cloud, "Hello" Name Tag of Newest User, AWS S3
phpBB portfolio: chevy truck forum, chevy astro van forum

User avatar
JesusADS
Registered User
Posts: 140
Joined: Tue Oct 27, 2009 2:26 pm
Location: Venezuela

Re: Need help creating ACP module for my Mod

Post by JesusADS » Thu Dec 10, 2009 5:01 pm

HI! I'm creating an ACP module too, but i'm also stuck in your first question, what do you do to make your mod shows in the MOD tab?? :oops:

Thanks :)

User avatar
austin881
Registered User
Posts: 284
Joined: Wed Jan 30, 2008 9:58 pm
Location: Boise, Idaho, USA
Name: Austin Maddox
Contact:

Re: Need help creating ACP module for my Mod

Post by austin881 » Thu Dec 10, 2009 5:19 pm

JesusADS wrote:HI! I'm creating an ACP module too, but i'm also stuck in your first question, what do you do to make your mod shows in the MOD tab?? :oops:
I found that mine would not show up because of the "auth" I was using.

root/includes/acp/info/acp_cloud.php

Code: Select all

<?php

/*
root/includes/acp/info/acp_cloud.php
*/

/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
	exit;
}

class acp_cloud_info
{
    function module()
    {
        return array(
            'filename'	=> 'acp_cloud',
            'title'		=> 'ACP_CLOUD',
            'version'	=> '1.2.3',
            'modes'		=> array(
            	'index'		=> array('title' => 'ACP_CLOUD_INDEX_TITLE', 'auth' => 'acl_a_cloud_auth', 'cat' => array('ACP_CLOUD')),
            ),
        );
    }

    function install()
    {
    }

    function uninstall()
    {
    }
}

?>
I changed

Code: Select all

'auth' => 'acl_a_cloud_auth',
to

Code: Select all

'auth' => 'acl_a_board',
and it started working. It makes sense. :)

Should be fine if you just use an 'auth' like acl_a_board because your new page will be available to the same users with permission to view the ACP "board"... which is probably only Administrators.
Available for paid phpBB help! PM me.

My Extensions/MODS: 475 Narius Categorized Smilies for phpBB3, Simplified & Compacted All-Members page, Flash Animated Cumulus Tag Cloud, "Hello" Name Tag of Newest User, AWS S3
phpBB portfolio: chevy truck forum, chevy astro van forum

User avatar
JesusADS
Registered User
Posts: 140
Joined: Tue Oct 27, 2009 2:26 pm
Location: Venezuela

Re: Need help creating ACP module for my Mod

Post by JesusADS » Thu Dec 10, 2009 7:57 pm

austin881 wrote: I changed

Code: Select all

'auth' => 'acl_a_cloud_auth',
to

Code: Select all

'auth' => 'acl_a_board',
and it started working. It makes sense. :)

Should be fine if you just use an 'auth' like acl_a_board because your new page will be available to the same users with permission to view the ACP "board"... which is probably only Administrators.
This is my includes/acp/info/acp_shareon.php...

Code: Select all

/**
* @package module_install
*/
class acp_shareon_info
{
	function module()
	{
		return array(
			'filename'	=> 'acp_shareon',
			'title'		=> 'Share On MOD',
			'version'	=> '0.0.5',
			'modes'	=> array(
			'index'	=> array('title' => 'SO_CONFIG', 'auth' => 'acl_a_board', 'cat' => array('SHARE_ON_MOD')),			
			),
		);
	}
}
i have 'auth' => 'acl_a_board' since the begining, but still doesn't shows in the MOD tab :(

I just put these files

root/includes/acp/info/acp_shareon.php
root/includes/acp/acp_shareon.php
root/language/es/mods/info_acp_shareon.php
root/adm/style/acp_shareon.html

and activate it, do i have to edit anything else in another file?

Locked

Return to “[3.0.x] MOD Writers Discussion”